What does “on behalf of” mean for an AI agent?
An AI agent acts on behalf of a user when the agent keeps its own identity while exercising a limited set of authority delegated by that user. A downstream service should be able to determine both the subject whose authority is being used and the actor performing the operation. This is delegation, not simply copying the user's credential or presenting the agent as if it were the user.
Delegation creates an attributable chain of authority: “agent A performed action X on behalf of user U.” It does not prove that user U intended action X. A prompt injection, malicious tool result, or planning error can steer an authenticated agent while it continues to use valid delegated credentials. Identity establishes who is involved; runtime authorization must still decide whether a specific action should proceed.
Controlling user (subject) | | delegates bounded authority vLogical agent (actor) | policy and capability profile | | executed by vWorkload identity | deployed process or job | | presents delegated authority vTarget resource | validates and executes the actionWhich identities exist in an agentic workflow?
Agentic identity is not one identifier. A production workflow can involve at least five distinct principals or security contexts:
| Identity | What it represents | Example |
|---|---|---|
| Controlling user | The human or organization whose authority and data are involved | user:alice |
| Logical agent | The named agent, policy profile, or capability set proposing actions | agent:invoice-reviewer |
| Executing workload | The deployment, process, job, or service instance running the agent | workload:prod/invoice-worker |
| OAuth client | The software registered to request or exchange tokens | client_id:agent-runtime |
| Target resource | The API or service that validates authority and executes the action | aud:payments-api |
These identities may map to the same component in a simple application, but they answer different security questions. The user explains whose authority is in use. The logical agent identifies which policy and capabilities apply. The workload proves which deployed software is executing. The OAuth client identifies who requested a token. The target resource constrains where that token is valid.
Do not accept an agent or user identifier merely because it appears in a request body, prompt, or model-generated tool argument. Identity used for authorization must come from a trusted issuer, authenticated session, workload credential, or server-controlled mapping.
Where do OpenID Connect and workload identity fit?
OpenID Connect authenticates the user and gives the application verifiable identity claims. An OIDC ID token is evidence for the client that authentication occurred; it is not a general-purpose credential to forward to downstream APIs. OAuth access tokens carry delegated API authorization, while the authorization server and resource server define what their scopes and claims mean.
Workload identity authenticates the software instance executing the agent. It can prove that a token exchange request came from the production invoice worker rather than a developer laptop or an arbitrary process holding a copied user token. Validate workload issuer, audience, environment, deployment, and service constraints before mapping that workload to a logical agent.
The logical agent identity sits above the workload. Several short-lived workers may execute the same agent:invoice-reviewer policy, while one workload may host several agents with different capability sets. Preserve both when the distinction affects authorization or audit. Do not assume that an OAuth client_id, workload subject, and logical agent name are interchangeable.
OIDC session | Which user authenticated? +-- subject: user:alice
SPIFFE/SPIRE | Which deployed process is running? +-- workload: prod/invoice-worker
Application map | Which logical agent policy applies? +-- actor: agent:invoice-reviewerAuthentication, delegation, and impersonation are different
Authentication verifies a principal. Delegation allows one principal to retain its identity while representing another. Impersonation makes the actor indistinguishable from the subject within the rights granted by the token.
| Model | What the resource sees | Audit consequence |
|---|---|---|
| Direct access | The user acts as the user | The subject and actor are the same |
| Delegation | The agent acts while representing the user | Both user and current actor remain visible |
| Impersonation | The agent appears to be the user in the token's rights context | The resource may not know a separate actor exists |
OAuth 2.0 Token Exchange defines these delegation and impersonation semantics. Delegation is usually the safer model for agents because it preserves attribution and lets policy distinguish the agent from the user. Impersonation may be necessary for a legacy resource, but it weakens local auditability and should be narrowly scoped, short-lived, and recorded by the token service.
How OAuth token exchange represents “on behalf of”
RFC 8693 defines an OAuth extension in which a client presents one security token and requests another token appropriate for a target resource. For delegation, the request can contain:
- a
subject_tokenrepresenting the party on whose behalf the request is made; - an
actor_tokenrepresenting the acting party; resourceoraudiencevalues restricting the target service; andscopevalues describing the requested authority at that target.
A simplified token exchange request looks like this:
Authorization server | receives +-- subject_token +-- actor_token | | validates delegation, | audience, and scope vDownscoped access token | vTarget resource APIPOST /oauth/token HTTP/1.1Host: identity.exampleContent-Type: application/x-www-form-urlencoded
grant_type=urn:ietf:params:oauth:grant-type:token-exchange&subject_token=USER_ACCESS_TOKEN&subject_token_type=urn:ietf:params:oauth:token-type:access_token&actor_token=AGENT_WORKLOAD_TOKEN&actor_token_type=urn:ietf:params:oauth:token-type:jwt&resource=https://payments.example/api&scope=invoices:read payments:createThe authorization server must authenticate the client, validate both input tokens, confirm that this actor may receive delegated authority from this subject, and apply policy for the requested resource and scope. The exact token types, claims, actor mapping, and support for token exchange depend on the identity provider.
Request one target and the minimum scopes required for the next operation. RFC 8693 notes that combining multiple audiences or resources with multiple scopes creates the Cartesian product of those rights. Broad exchange requests are therefore easier to misuse and harder to reason about than one audience-specific, downscoped token.
How do the sub, act, and may_act claims work?
When the issued credential is a JWT, RFC 8693 defines claims that can preserve delegation semantics:
subidentifies the subject whose delegated authority the token represents.actidentifies the current actor to whom that authority has been delegated.may_actcan state which party is eligible to become an actor for the subject.
An illustrative delegated token could contain:
{ "iss": "https://identity.example", "aud": "https://payments.example/api", "sub": "user:alice", "act": { "sub": "agent:invoice-reviewer" }, "scope": "invoices:read payments:create", "exp": 1786467600}The top-level claims define the token's validity and authority. Claims inside act identify the actor; expiry, audience, and other token-validity claims are not meaningful inside that object. A resource server should validate the top-level issuer, signature, audience, time bounds, and scopes before using sub and the current act identity in policy.
The presence of act is not evidence that delegation is valid by itself. Trust comes from the issuer's signature and the resource server's decision to trust that issuer for this audience and claim model. Likewise, may_act is an input to authorization-server policy, not a replacement for validating the actor or applying deployment-specific delegation rules.
How should multi-agent delegation chains work?
An orchestrator may delegate work to a specialist agent, which may call another service. RFC 8693 permits nested act claims: the outermost act is the current actor, while nested actors form a historical chain. The least recent actor appears deepest in the structure.
{ "sub": "user:alice", "act": { "sub": "agent:payments-specialist", "act": { "sub": "agent:finance-orchestrator" } }}For access-control decisions, RFC 8693 requires the consumer to consider the top-level token claims and the current, outermost actor. Prior actors are informational history, not principals whose permissions should be accumulated. Never union scopes or roles across the chain; every hop should preserve or reduce authority, set the next audience, and produce a new short-lived credential when practical.
Limit delegation depth and reject loops. Record the full chain for investigation, but keep authorization policy focused on the subject, current actor, target resource, and requested action. If a downstream service cannot validate the chain format or issuer, fail closed rather than silently treating the current agent as the user.
Why “on behalf of” does not prove user intent
A valid delegation proves a chain of authority, not approval for every action taken through that chain. Human permissions often cover work a person may perform over months. An agent is completing one task now, and untrusted content can change the plan while the credential remains valid.
For example, a user may authorize an email agent to read messages and draft replies. A malicious document can instruct the agent to attach confidential data to an external message. The token correctly proves which user and agent are involved, and the send operation may fall within a broad email:send scope. None of those facts establishes that the user intended this recipient, attachment, or disclosure.
This is an agentic confused-deputy problem: an attacker influences software that already possesses legitimate authority. Arcjet's analysis of the two speeds of AI agent runtime security describes the boundary this creates. Identity and delegation establish who the agent represents. Least privilege defines the outer boundary. Runtime governance decides whether this action should proceed now.
Authorize the action as well as the token
The target service should evaluate delegated identity together with application context immediately before a consequential operation. A useful runtime decision can include:
- controlling subject, current actor, workload, and tenant;
- token issuer, audience, client, scopes, age, and delegation depth;
- tool name, operation, arguments, and target object;
- data classification, recipient, amount, and reversibility;
- the user's task, recent approvals, and workflow state;
- prompt-injection or bot signals; and
- per-user, per-agent, and per-organization budgets.
Authorization must be object-level and action-specific. A token permitting payments:create should not automatically permit every amount, recipient, funding account, or sequence of changes. Query resources through the subject's tenant boundary, validate model-generated arguments as untrusted input, and apply agent-specific restrictions in addition to the user's permissions.
High-impact actions may require step-up authentication or explicit approval. Bind an approval to a canonical representation of the operation—such as action type, resource, amount, recipient, and expiration—so it cannot be replayed for a materially different call. Keep the gated set small enough that reviewers inspect the request rather than approving automatically.
The AI agent runtime security guide explains how these checks fit at tool and action boundaries, including prompt-injection detection, sensitive-data controls, sequence-aware policy, and budgets.
The action gate belongs before the tool creates its side effect:
Model proposes tool call | vApplication validates arguments | vRuntime policy evaluates: subject + actor + workload resource + action + approval | +-- deny | stop and record reason | +-- approval required | bind approval to exact action | +-- allow execute and record outcomeProvider-neutral pseudocode makes the separation explicit:
const action = { type: "payments.create", resource: invoice.id, amount: invoice.total, recipient: invoice.paymentAccount,};
const decision = await authorize({ subject: session.userId, actor: agent.id, workload: workloadIdentity.subject, tenant: session.tenantId, action, approval: workflow.approvalFor(action),});
if (decision.status !== "allow") { return handleDeniedAction(decision);}
const result = await payments.create(action);await audit.record({ action, decision, result });What if there is no controlling user?
Not every agent acts for an individual. A queue-driven invoice processor, scheduled monitor, or incident-response agent may run under organizational authority. Do not invent a human subject merely to fit an on-behalf-of model.
Give an autonomous agent a dedicated workload and logical-agent identity. Restrict it with service-owned scopes, tenant and resource constraints, short-lived credentials, budgets, and approval requirements for irreversible actions. Audit records should state that the agent acted under a service or organization policy rather than attributing the operation to the last person who deployed it.
When a human later approves a specific action, record that approval as separate evidence. The approver is not necessarily the subject of every prior read or planning step, and the agent remains the actor that executes the approved operation.
Constrain token lifetime, audience, and revocation
Delegated tokens should be short-lived, audience-restricted, and downscoped. Avoid placing a user's general access token in agent memory, logs, prompts, tool arguments, or long-running workflow state. Exchange it for a credential usable only by the intended resource, and store credentials outside model-visible context.
Token exchange is an issuance event, not a permanent link between input and output tokens. RFC 8693 token processing notes that exchanging a token does not invalidate the input token and does not automatically propagate later renewal or revocation to the output token. If rapid revocation matters, design it explicitly through short expirations, introspection, a revocation registry, session versioning, or provider-specific propagation.
Validate at least the signature, trusted issuer, exact intended audience, expiration and not-before times, subject, current actor, client where relevant, tenant boundary, and required scope. Reject unsupported token types or signing algorithms, unsupported delegation forms, excessive chain depth, and tokens intended for another environment or service.
What should an agentic identity audit record contain?
Record enough structured evidence to answer who acted, under whose authority, what happened, why it was allowed, and which workflow produced it:
- subject, current actor, logical agent, workload, OAuth client, and tenant;
- issuer, audience, scopes, token identifier or safe fingerprint, and delegation depth;
- tool, action, target resource, and normalized high-level parameters;
- policy version, decision, reason code, and approval reference;
- workflow and correlation IDs linking related steps; and
- timestamp, outcome, and reversible or irreversible status.
Do not copy bearer tokens, prompts, complete documents, or sensitive tool arguments into logs. Use opaque identifiers and redacted structured fields. Keep attacker-controlled evidence separate from trusted summaries so an audit or MCP tool cannot turn stored input into a new prompt-injection channel.
Tools for agentic identity and delegated authorization
No single tool implements the complete on-behalf-of chain. User authentication, delegated token issuance, workload identity, object-level authorization, and runtime action enforcement are separate jobs. Choose a component for each job and test the claims passed between them.
Which identity and authorization capabilities do AI agents need?
| Need | Representative tools | What the component establishes | What it does not establish |
|---|---|---|---|
| User authentication and consent | Auth0, Descope, Keycloak | The user authenticated and granted a defined authorization | Which deployed workload is acting or whether the current action is safe |
| Connected-account credentials | Auth0 Token Vault, Descope Agentic Identity Hub | A service can obtain a scoped credential for a user-approved external account | Object-level permission or current user intent at the target tool |
| Workload identity | SPIFFE and SPIRE | Which attested workload is executing the agent | Delegated user authority or permission to a business resource |
| Token exchange and downscoping | RFC 8693-capable authorization servers, including Keycloak for supported flows | A short-lived credential is intended for a target audience and reduced scope | That the user intended the agent's specific arguments or action sequence |
| Object-level authorization | OpenFGA, Auth0 FGA | A subject or actor has a modeled relationship to a resource | Workload authenticity or dynamic facts not supplied to the decision |
| Contextual runtime policy | OPA or an in-code authorization guard | The current identity, action, resource, and workflow facts satisfy policy | Identity claims that were not independently authenticated |
Which commercial identity platforms support AI agents?
- Auth0 for AI Agents provides user authentication and a Token Vault for storing external-provider credentials and exchanging an Auth0 token for a connected account's access token. It fits agents that need user-consented access to services such as Google, GitHub, Microsoft, or Slack. Check whether each target integration preserves the actor identity you need; a provider access token may represent only the user and client.
- Descope Agentic Identity Hub provides inbound OAuth applications, outbound connected applications, credential storage, user consent, and MCP authorization tooling. It fits systems that need to expose an application to agents and connect those agents to external tools. Verify tenant isolation, scope mapping, token export, and audit behavior against the target APIs you use.
- Managed fine-grained authorization, including Auth0 FGA, can store relationships such as
user U can approve invoice Ioragent A may read documents delegated by U. This answers object-access questions, but it does not authenticate the workload or prove that the current action matches the user's intent.
Managed token vaults reduce the need to store refresh tokens in application infrastructure. They do not make model context a safe place for access tokens, and they do not replace an application check before a payment, message, deletion, or data export.
Which open-source tools support agentic identity?
- Keycloak supports standard OAuth token exchange for issuing a token to another client in the same realm. Its current standard implementation can filter audiences and enforce downscoping, but RFC 8693 delegation with
may_actis experimental. Do not base a production actor chain on Keycloak's experimental delegation feature without accepting that compatibility risk. - SPIFFE and SPIRE attest nodes and workloads and issue X.509 or JWT SVIDs. Use SPIRE to prove which deployed workload is executing the agent. An SVID identifies the workload; it does not carry user consent or delegated user authority by itself.
- OpenFGA is a CNCF open-source relationship-based authorization system. It can model user, agent, tenant, and resource relationships and answer object-level access questions. Keep volatile request facts such as amount, prompt-injection risk, and current workflow state in the runtime decision rather than forcing every fact into the relationship graph.
- Open Policy Agent evaluates policy over structured input using Rego. It can combine token claims, workload identity, tool arguments, resource attributes, and workflow state. The application remains the enforcement point: it must query the policy before the operation and handle allow, deny, and unavailable results explicitly.
Which identity tools should an AI agent combine?
For a managed deployment, use Auth0 for AI Agents or Descope for user consent and connected-account credentials, then add object-level authorization and an in-code guard before consequential tools. For a self-hosted deployment, one division of responsibility is Keycloak for user identity and token exchange, SPIRE for workload identity, OpenFGA for durable resource relationships, and OPA for contextual policy.
Do not add every component by default. A small agent that calls one internal API may need an existing OIDC provider, a short-lived audience-restricted token, and application authorization. Add a token vault when the agent connects to external user accounts, workload identity when deployment provenance affects trust, and a separate policy engine when policy must be shared across several services or languages.
Agentic identity anti-patterns
- Sharing the user's bearer token: the agent receives all token capabilities, and downstream services cannot distinguish actor from subject.
- One credential for every agent: actions cannot be attributed to a logical agent or isolated by capability, environment, or tenant.
- Trusting prompt-provided identity: model output or request metadata chooses the user, role, or delegation chain.
- Treating OAuth scopes as user intent: a broad capability is accepted as approval for every concrete action.
- Forwarding one token to every API: audience boundaries disappear and a compromised service can replay the credential elsewhere.
- Accumulating delegation rights: downstream agents union permissions from prior actors instead of reducing authority at each hop.
- Long-lived refresh tokens in workflows: compromise creates durable access after the task and user session end.
- Audit logs with only the user: the agent, workload, client, and delegation path disappear from incident evidence.
On-behalf-of implementation checklist
- Identify the controlling subject, logical agent, workload, OAuth client, and target resource separately.
- Choose delegation over impersonation when the target can represent both subject and actor.
- Authenticate users and workloads through trusted issuers; never accept identity from prompts or model arguments.
- Exchange credentials for one target audience with the minimum scopes and lifetime needed for the next operation.
- Validate subject and actor tokens and explicitly authorize the actor to receive delegated authority.
- Preserve the current actor in a signed claim or trusted server-side session, and retain prior actors only as audit history.
- Reduce authority at every delegation hop; limit chain depth and reject loops.
- Keep credentials outside prompts, model context, tool output, and logs.
- Enforce tenant, object, action, recipient, amount, and budget policy at the execution boundary.
- Bind approvals to the exact consequential action and expire them quickly.
- Record subject, actor, workload, policy decision, and workflow correlation without logging bearer credentials.
- Test cross-tenant access, actor substitution, audience confusion, scope escalation, replay, expired approval, chain splicing, and prompt-driven misuse.
Frequently asked questions
Should an AI agent use the user's access token?
Avoid giving an agent a general user access token. Prefer a short-lived credential restricted to the intended resource and minimum scopes, while preserving the user as subject and the agent as actor. Keep all credentials outside prompts, model context, tool arguments, and logs.
What is the difference between delegation and impersonation?
Delegation preserves separate subject and actor identities: the agent acts while representing the user. With impersonation, the agent appears to be the user within the token's authorized context. Delegation usually provides stronger attribution and more precise agent-specific policy.
Does OAuth delegation prove that the user intended an agent action?
No. Delegation proves that an actor received authority associated with a subject. It does not prove the user intended a specific recipient, amount, tool call, or action sequence. Enforce object-level and action-specific policy immediately before consequential operations.
How should autonomous AI agents be identified?
Give an autonomous agent a dedicated logical-agent and workload identity under organizational authority. Do not attribute its actions to an arbitrary human. Restrict its scopes, resources, budgets, credential lifetime, and irreversible operations through service policy and approval gates.
Which tools support on-behalf-of identity for AI agents?
Managed options such as Auth0 for AI Agents and Descope Agentic Identity Hub handle user consent, connected accounts, and token storage. Open-source deployments can combine Keycloak for identity and token exchange, SPIFFE and SPIRE for workload identity, and OpenFGA or OPA for authorization. Runtime checks are still required before consequential actions.
AI runtime security in your code
Protect your AI agent workflows with Arcjet
Arcjet runs inside your application, where it can use runtime context to enforce agent actions and budgets, detect prompt injection, and protect sensitive information before a workflow acts.