Keep approval policy in data and deterministic code, not in an agent's prompt (opens in a new tab)
You will see why an AI agent should not decide business rules like discount approval, and how to structure it with an explicit approval matrix, gated tools, and a needs_human outcome.
Why read this
The code is generic Python rather than Salesforce-specific.
- Agent calls request_discount
- Look up approver in matrix
- Approver found: pending approval
- None available: needs human
The article argues that an AI agent is essentially an LLM in a loop, and that the difficulty in a company lies in the policy questions nobody has answered, such as who may approve a discount above a rep’s limit when the usual approver is unavailable. An agent should not invent such a policy, because any answer it gives looks like a decision but is only a guess.
The proposed design moves policy into data the business owns, such as a table or Custom Metadata listing discount thresholds, the role allowed to approve, and a backup role. A deterministic function looks up the approver and returns nothing when nobody is available, so the case escalates instead of being guessed. Tools that change money, prices or contracts never apply changes directly; they return a pending proposal that a gate handles.
The loop itself stays simple, but it needs a step limit, an allowlist of registered tools, and a first-class needs_human result that explains why the agent stopped. Read and write tools should be treated differently. The author also notes that decisions expressible as simple rules belong in Flow, Apex or plain code, and that agents suit cases needing interpretation of free text or messy context.
Read the original at dev.to (opens in a new tab)