---
title: How to give AI agents an identity (and let them act on behalf of users safely)
url: https://opencontroller.lyzr.com/blog/ai-agent-identity-on-behalf-of-delegation
published: 2026-11-11
updated: 2026-11-11
author: Lyzr
---

# How to give AI agents an identity

**Give every AI agent its own workload identity, never a shared key. When an agent acts for a person, use delegated on-behalf-of tokens that carry both the user and the agent, scoped to one resource and a short lifetime.** Then authorize each action against what *both* are allowed to do, and keep the ability to revoke the agent without touching the user.

## Why shared API keys and service accounts fail

Most early agents run on a shared service account or a long-lived API key. That breaks three things at once:

- **Attribution.** Logs show "svc-ai-prod" did it. Which agent? Which version? For whom?
- **Least privilege.** The key needs the union of every agent's permissions, so every agent gets all of them.
- **Containment.** To stop one agent you rotate a key that ten agents use.

Agents also differ from classic workloads: they decide at runtime which tool to call, and they often act for a human who never sees the individual calls.

## The three identities in every agent action

| Identity | Example | What it should prove |
| --- | --- | --- |
| The caller | A user in Entra ID, an application, or another agent | Who asked for the work |
| The agent | "Refund assistant v14" with its own workload identity | Which software is acting, at which version |
| The resource | The refunds API, a CRM, an MCP server | Who the token is meant for |

A sound design keeps all three visible in every token and every log line.

## Step by step: an identity model for agents

1. **Register the agent first.** Identity attaches to a registry record with an owner, purpose and version. No registry entry, no identity.
2. **Issue a workload identity per agent.** Use your cloud's workload identity (IAM roles, managed identities, service accounts with federation) or SPIFFE-style identities, federated to your identity provider. Avoid static secrets where federation is possible.
3. **Authenticate users with your existing IdP.** OIDC SSO with Entra ID, Okta or similar. Provision with SCIM so leavers lose access everywhere.
4. **Delegate with token exchange.** When a user asks an agent to act, exchange the user's token for a new one under OAuth 2.0 Token Exchange (RFC 8693). The new token identifies the user as the subject and the agent as the actor (the `act` claim).
5. **Restrict audience and scope.** Request tokens for one resource using Resource Indicators (RFC 8707), with only the scopes that task needs and a short lifetime. Never pass a user's original token through to downstream tools.
6. **Authorize the intersection.** At the enforcement point, allow an action only if the user may do it *and* the agent is approved to do it. A junior analyst's agent should not gain an admin's reach, and an admin's agent should not gain everything the admin can do.
7. **Gate consequential actions.** For payments, deletions or external messages, require a human approval tied to the request.
8. **Log the chain.** Record user, agent, version, resource, scopes, policy decision and outcome together.
9. **Make revocation instant.** Blocking an agent should invalidate its identity and in-flight delegations without disabling the user.

## Background agents: the hard case

Scheduled and long-running agents act when the user isn't present. They need a stored delegation grant: what the user approved, for which agent, which resources, and until when. Treat this as a high-scrutiny design. Bound grants in time and scope, record consent, re-check the user's status (still employed? still in the group?) at each use, and allow the user and the owner to revoke.

## How MCP fits

The Model Context Protocol authorization specification treats MCP servers as OAuth resource servers. Tokens must be issued for that specific server, and servers must not pass client tokens through to upstream APIs. In practice that means MCP tool calls should carry agent-scoped, audience-restricted tokens, ideally issued through your control plane ([MCP governance](/blog/how-to-govern-mcp-servers)).

## Emerging standards to watch

Cross-application delegation for agents is still being standardised. Examples include identity-provider features built for agents, such as Microsoft Entra Agent ID, and IETF drafts such as the Identity Assertion JWT Authorization Grant used in Okta's Cross App Access. These are drafts or vendor features, not settled standards, so design so you can adopt them without re-plumbing every agent.

## Checklist

- [ ] Every agent has a distinct, revocable identity
- [ ] No shared or long-lived keys for production agents
- [ ] Delegated tokens carry both user and agent
- [ ] Tokens are audience-restricted and short-lived
- [ ] Authorization checks the user-agent intersection at the action
- [ ] Consequential actions require approval
- [ ] One log line ties user, agent, version, resource and decision
- [ ] Revoking an agent takes effect in seconds, not a key-rotation cycle

## How Opencontroller does this

[Opencontroller](/blog/what-is-opencontroller) provides OIDC SSO, delegated on-behalf-of identity and agent workload identity federation, with per-agent Block and Quarantine controls on each agent's identity and access panel. Policies are expressed as code, and decisions are traced with the agent, version and caller.

## Frequently asked questions

**Can an agent have more permissions than its user?**
For delegated actions it shouldn't. Some autonomous agents have their own grants, but those should be explicit, owned and reviewed.

**Do we need a new identity provider for agents?**
No. Agent identities should federate into the IdP you already run.

**What about agents on SaaS platforms we don't control?**
Register them, map their service identities to an owner, and route their calls to your systems through an enforcement point where possible.

## Related

- [How to govern MCP servers in the enterprise: a practical guide](https://opencontroller.lyzr.com/blog/how-to-govern-mcp-servers.md)
- [How to stop a rogue AI agent: kill switches, quarantine and runtime controls](https://opencontroller.lyzr.com/blog/how-to-stop-a-rogue-ai-agent.md)
- [What is an AI agent control plane?](https://opencontroller.lyzr.com/blog/what-is-an-ai-agent-control-plane.md)
- [More on Agent identity and access](https://opencontroller.lyzr.com/blog/cluster/agent-identity-and-access)
