Security, Governance and PlatformAction authorization and policyPrincipal
How should an agent’s refund tool enforce credentials, approval and current user authority?
By Amit Kumar4 min readWorked answer includedReviewed 26 Sept 2026
The question
Interview question
Design the trust boundary for a support agent that reads account data and proposes refunds. Explain which identities and credentials each component uses, how approval binds the exact action, where current authorization is enforced, and what the audit record must show. The user loses refund authority while the run is paused. Also consider revocation racing with a request that has already been sent.
Draft your approach first
Take a few minutes before you read the answer. Name the constraint that matters most, the failure you are designing for and how you would know it worked.
Reveal the worked answerWorked answer
A refund tool needs to distinguish a request to do something from authority to do it. The model may identify a reason for a refund and propose arguments. A controlled service must determine whether the current user is allowed to cause that exact effect, then use credentials the model cannot access to carry it out.
Separate three identities. The human is the subject requesting work. The agent run is an actor working on that person's behalf. The gateway is the service that authenticates to the payment provider. Authentication establishes which identity is calling. Authorization decides whether that identity may perform this action on this resource under current conditions. A broad gateway credential proves the service can reach the API, not that every model-generated refund is allowed.
Keep provider secrets in a managed gateway or token broker, outside prompts, tool results and general agent sandbox environments. Use a narrowly scoped workload identity where the provider supports it, and limit the reachable operations and environment. If the downstream API accepts only a broad application credential, the gateway becomes a critical policy enforcement point. It must not expose a generic proxy that lets model-supplied arguments bypass those checks.
The proposal should identify the tenant, customer, original payment, amount, currency and reason. Resolve the requesting identity from trusted runtime state. Verify that the payment belongs to the tenant and customer and that the requested amount meets the business rules. Reading account information needs its own authorization and field minimization before the model receives it. Permission to inspect a payment is not permission to refund it.
An approval is a separate record binding an approver to a defined effect or disclosed range. In a hypothetical case, approval for a $40 refund on payment P-7 must not authorize $400 on payment P-8. Bind the relevant arguments, resource versions and policy conditions using a canonical representation. A fingerprint is a digest used to detect changes to that representation. If material arguments or assumptions change, require a new decision rather than relying on the old token's signature alone.
Some downstream systems support delegated tokens that identify both the subject and acting service. OAuth token exchange, RFC 8693, defines a protocol for such exchanges and delegation-related representations. It does not automatically grant refund authority or implement the business policy. Whether using a delegated token or a gateway credential, retain the on-behalf-of relationship and restrict audience and scope to the intended service.
Check authorization again immediately before a new refund submission. The check uses current grants, approval validity, tenant and resource state, and the exact operation. Attach the decision to a durable operation identity so retries do not become new business intents. The audit record needs the requesting subject, actor, approver, policy version, argument fingerprint, operation and attempt identities, provider reference and eventual outcome. Keep credentials and unnecessary account data out of general traces.
Now the user loses refund authority while the run waits. Under a policy where submission requires current user authority, the resumed runtime must not use the old approval to send the request. A signed access token can remain cryptographically valid after the underlying grant changes. The gateway therefore needs an explicit revocation contract, such as checking an authoritative grant version or consulting token status with bounded caching. OAuth token introspection, RFC 7662, provides a status-query mechanism, but its deployment still determines freshness and caching.
If the policy permits short-lived cached grants, document the resulting exposure window. “Short lived” is not immediate revocation. If the authorization service is unavailable and no valid decision can be established under the money-movement policy, leave the operation pending rather than treating the outage as permission. An independently authorized business service might have a different mandate, but that must be an explicit workflow contract, not an accidental consequence of retaining a service credential.
Revocation racing with submission has a hard boundary. A local check can prevent a later send. It cannot retract a request that has already reached the provider. Define the ordering point for the local authority decision, record when submission occurred and reconcile the provider outcome. A stronger promise that revocation prevents effects until remote commit requires the provider to participate. If the response is lost, record an unknown outcome rather than declaring the refund failed or cancelled.
Test changed amounts, cross-tenant payments, expired approvals, replayed requests, account switches and revocation immediately before and after submission. Verify both the denial and the resulting audit trail. The system should be able to explain who authorized which effect under which state, while preventing the model from turning a plausible proposal into its own permission.
Related questions
- How should emergency authorization work for an agent when policy and identity services are unavailable?Principal
- How do you keep authorization correct when a tool adds a field that changes its effects?Staff
- How should parallel agent actions share an aggregate credit cap when provider outcomes are unknown?Principal
Keep practising security, governance and platform
Follow another question in this area, or search the complete library.
Get my essays on AI engineering and distributed systems by email. Subscribe to ArchCrux