← All articles

Rustem Feyzkhanov · Writing

Identity Is Part of the Action

Part 3 of Distributed Agents, Centralized Authorization. Part 2 ended with a question: once one service runs every tool, whose credentials should it use? Here is how I answer it with OpenAPPA, Claude Managed Agents custom tools and Composio.

Someone in Slack asks for an Acme rollout summary in #acct-acme. Acme shared “Acme × Us: Q1 rollout” with me and two colleagues. The agent reads it through my account, and the session’s readers narrow to #acct-acme. The bot posts the summary there under its own name with the footer “Summarized from Acme’s rollout doc via Rustem’s access.” A separate request to post to #sales-all is denied as the bot. A proposed post as me asks for my exact approval.

Acme, a customer, owns a Google Doc called “Acme × Us: Q1 rollout” and shared it with three people on our side, including me. Our agent isn’t on the share list; adding it would take a deliberate step on Acme’s side.

In Slack, someone asks the agent: “Post a summary of where Acme’s rollout stands to #acct-acme.” The steps shouldn’t all run as the same account:

  1. Read Acme’s doc: my account only. Acme decided who reads it, so there’s no grant for the agent’s own identity.
  2. Post the summary to #acct-acme: the agent’s bot. The private account channel holds roughly the people Acme shared with. The bot is the author: it’s the agent’s summary, not a status update I wrote.
  3. Post it to #sales-all: denied for the bot; as me, it asks first. That audience is far wider than the one Acme approved.
  4. Write anything back into Acme’s doc: as me, it asks first. It would appear under my name in the customer’s document.

The credentials can’t tell these cases apart. My OAuth token can read the doc, and the bot token can post to any channel the bot has joined. The difference is on the action side: which tool, which resource, what the session has read, and on whose behalf it runs.

Credentials say what’s possible, not what’s allowed

In a normal app, identity and permission mostly travel together. You sign in, get a token, and every request carries its scopes. The app may add its own checks, but the person picks the request.

Agents break that. The model picks the request. A bot token says the agent can post to any channel it has joined. It can’t say whether this agent, ten minutes after reading a customer’s doc, should post to #sales-all. So the decision has to move from the credential to the action: this tool, these arguments, this session’s history.

Once it does, identity takes on a second role. The account keeps its provider permissions, but identity also becomes one more fact about the action: on whose behalf it runs. The user, a service account, or someone else. And that fact belongs in the same rule as the tool and the resource, not in a separate “may act as X” grant.

Identity in the grant

Here is the example as OpenAPPA policy, trimmed from the app’s Acme example. The rule syntax is the one the public reference app already uses; grant routing and the Docs and Slack tools are in the private app for now:

# Routing: preference order. The grants decide which identity runs each call.
[[identity.tool]]
name = "googledocs_get_document"
candidates = ["service", "member"]
select = "granted"
on_missing = "deny"

# Acme's doc: only my account. Reading it limits the session's readers to the account channel.
[[policy.tool]]
name = "host/cma-custom/googledocs_get_document(_as:member,document_id:<ACME_DOC_ID>)"
delta = { audience = ["<ACCT_ACME_CHANNEL_ID>"] }

# The agent's voice: the bot posts only where every reader may already see the data.
[[policy.tool]]
name = "host/cma-custom/slackbot_send_message(_as:service,channel:*)"
requires = { audience = { contains = ["$channel"] } }

# My voice, in Slack or in Acme's doc: always my call.
[[policy.tool]]
name = "host/cma-custom/slack_send_message(_as:member,channel:*)"
requires = { attention = ["as-me"] }

[[policy.tool]]
name = "host/cma-custom/googledocs_insert_text(_as:member,document_id:<ACME_DOC_ID>)"
requires = { attention = ["as-me"] }

[[policy.authority]]
name = "me"
hint = "Review this exact action through your connected account."
[policy.authority.permits]
attention = ["as-me"]

Two sections, two jobs. [[policy.tool]] belongs to OpenAPPA and says who may do what; _as is just another argument to match, next to the document or the channel. A combination that isn’t listed is denied, with no broad fallback. [identity] belongs to the host and states a preference. With select = "granted", the host asks OpenAPPA’s contract matching which candidates a grant covers, before any decision, and takes the first one with an active connection. For Acme’s doc that’s only me.

Who proposes the identity is a design choice, not part of the thesis. The host can hide it from the agent: Acme’s doc has one grant, so the read runs as me and the agent never sees a choice. The agent can propose it: posting to #sales-all as me means choosing the user-token tool, and that choice is untrusted input, so the grant asks me first. Or the person can choose, as when I approve a post under my name. What doesn’t change is that the identity is part of the action the policy judges: picked once, never retried as someone else after a denial, and bound into any approval.

“Member” means the owner of the application thread, the person who asked. Not whoever typed the latest Slack message, or whoever pressed Approve. My “service” connection for Slack is the bot.

The model proposes a call without identity. The host asks the grants which roles have an explicit contract for this call; none denies before dispatch. It resolves the first granted role with an active connection in preference order, or stops when none is connected, then stores it and attests its role. OpenAPPA checks role, action, resource and history, then allows, requests review of the exact call and role, or denies without trying another identity.

The example’s tests evaluate each decision directly, in two sessions. Expected outcomes, condensed:

session A
googledocs_get_document  service  <ACME_DOC_ID>   deny: no grant, and no review can create one
googledocs_get_document  member   <ACME_DOC_ID>   allow, then readers = #acct-acme
slackbot_send_message    service  #acct-acme      allow
slackbot_send_message    service  #sales-all      deny: #sales-all is not a reader
slack_send_message       member   #sales-all      authority me (as-me)
googledocs_insert_text   member   <ACME_DOC_ID>   authority me (as-me)

session B, no customer read
slackbot_send_message    service  #sales-all      allow

Three details matter.

The identity is picked once. If OpenAPPA denies the bot’s post to #sales-all, the host doesn’t retry as me. A denial never falls back to another identity.

Approval can’t change the identity. When I approve a post as me, I approve this exact call under this exact identity. A different identity is a different call with its own decision.

Switching accounts doesn’t launder state. The session’s readers are shared across identities. After the read, every bot post is checked against the account channel, and every post as me asks first.

Read identity isn’t write identity

The session reads as me and writes as the agent, on purpose. The grants force my account for the read, because Acme shared the doc with me. The policy lets the bot write, because the summary is the agent’s work. Each action gets its account from its own grant, not from whichever credential the session used last.

Two lanes, me and the bot. Reading Acme's doc runs in my lane, because only my grant matches. The bot then posts to #acct-acme as the author, and its post to #sales-all is denied because #sales-all is not a reader. Later, a post to #sales-all as me is a different tool and asks me first; the denied bot post is never retried as me. Below the lanes, the session's readers change from anyone before the read to #acct-acme after it, and every bot post is checked against that list.

History limits destinations, not authors

The read changes what the session holds, not what the agent may do. OpenAPPA compares reader IDs exactly, so the account channel’s ID stands in for the readers: after the read, the session’s audience is #acct-acme. The bot’s post requires that the destination is already a reader (contains = ["$channel"]), so #acct-acme passes and #sales-all doesn’t. Before the read, the same bot could post to either.

Four bars of increasing width: Acme's share list of three people; #acct-acme, the account channel and the session's readers after the read, where the bot may post; #sales-all, wider than Acme approved, where the bot is denied and a post as me asks first; and the whole company, where the bot is denied and a post as me asks first. A note says the channel ID stands in for Acme's share list and the policy won't notice if either changes. The bar widths are illustrative. The policy compares exact channel IDs.

The channel ID is a stand-in for Acme’s share list, and the policy won’t notice if they drift apart. OpenAPPA can read real membership from a provider (@slack:channel/$channel_id), but my app doesn’t run one yet.

”The agent publishes what it can’t read”

That’s the confused-deputy objection: the bot posts, under its own name, content from a doc its identity can’t open. Three answers:

  • It’s a rule, not an accident. One exact grant lets the bot post, and one exact delta says where the content may go.
  • The destination is no wider than Acme’s audience. Wider channels are denied.
  • The write says where it came from. The bot’s post carries a footer that the host builds from the member reads it can verify: the doc’s title and my display name, as in “Summarized from Acme’s rollout doc via Rustem’s access.” OpenAPPA’s trajectory records each decision. The agent is the author; I’m accountable. That’s Part 2 again: owning the tool is what lets you attach that record to every write.

Custom tools already know who’s asking

In Part 2, custom tools moved execution into my own service. CMA emits agent.custom_tool_use and waits for my user.custom_tool_result. That gave me the policy hooks and the memory between them. It also gives me identity almost for free: the event arrives on a session my app created, for a thread that has an owner. The service already knows who “member” means before the model asks for anything.

In my app, the model never names the identity. The model-facing tool schema has no _as field, and strict input validation rejects one if the model invents it. The service resolves and stores the connection, and the policy helper attests _as into the call that OpenAPPA evaluates. Nothing the model sees through CMA carries the role or the connection ID. The selected role does show up for the person reviewing, because it’s part of what they approve.

There’s nothing new to sign. When one system asks another to “act as Alex”, the receiver needs a way to trust that claim: a signed assertion, or an opaque token backed by a lookup. Here, no such claim is ever sent. The role is derived inside the app’s own trust boundary.

Each part reads what it needs from where it lives: the thread owner and connection from the app database, the tool call from CMA’s event history, the policy state from the last committed checkpoint. The host hands the role to its policy helper as plain structured input. After a crash, the next worker rebuilds the same picture from those records. Approvals are bound to the call, role and policy, and checked against stored state, not a signing key.

Signatures don’t disappear. Slack requests and Anthropic webhooks are verified on the way in, and services still authenticate to each other. The trust question just gets simpler: which components can write those records.

Why not an MCP gateway?

The obvious alternative is to put Docs and Slack behind your own MCP server and do all of this there. It can be done, but identity makes it much harder than it looks.

After a worker restarts, custom tools recover a known session and call using CMA event history, application records for the owner, selected connection, execution and approval, and the last policy checkpoint. The proposed MCP gateway first validates a bearer credential and maintains a vault-token-to-execution-to-context binding, including provisioning, request correlation and retirement. It then restores the same kinds of records. Both designs preserve execution state and hold uncertain writes.

On its own, the gateway doesn’t know who’s asking. In CMA an MCP server is declared with a name and a URL, and its credential comes from a vault attached when the session is created. A request carries that credential, not my thread-owner mapping. The obvious design is a token per agent execution, attached through a vault and mapped to the session, thread and owner. MCP doesn’t require it, but something has to do that job. It’s context my app already has, rebuilt next to it.

And the token has to prove itself. That token now carries “act as Alex” across a network boundary, so it’s a credential in its own right. Opaque or signed, it needs an audience, an expiry that outlasts a slow review, and a way to revoke it when the session stops. It’s still a bearer token: whoever holds it is Alex until it expires. Signing it doesn’t change that. Custom tools never create this credential.

The easy shortcut gives the identity to the model. The tempting fix is one credential per identity: a slack-member server and a slack-bot server. Each server’s identity is now fixed, and choosing between them is choosing a tool. The model picks the identity, unless another policy layer stops it. Fixed credentials alone can’t express “read as me, post as the bot, and only to #acct-acme once the customer doc is read.” A gateway can, but only with the routing and state this post is about.

The decision needs memory. Step 3 from the opening depends on what the session read before. The gateway has to keep its own label for each session, keyed by that token mapping, and clean it up when the session ends.

Review holds a request open. If the gateway waits for a person before it returns, timeouts set how long a reviewer gets. MCP Tasks can fix that with a durable handle, but only where both client and server support it. With custom tools the session simply waits for user.custom_tool_result.

The approval has to bind the identity. The gateway has to fingerprint the call together with the identity itself, so an approval given for the member can’t be replayed as the service account.

Composio fits either design. A gateway would call the same proxy. What changes is where the trusted “on whose behalf” comes from: a token mapping you maintain, or a session you already own.

A gateway still wins when the same tools must be reachable from agent hosts you don’t run. Custom tools exist only inside your app’s own sessions. For Claude Code, Cowork or ChatGPT you need an MCP front door, which is what I built for delegation. There, the identity is the person signing in over OAuth, not a per-call choice.

Why not domain-wide delegation?

Google Workspace offers a shortcut: a service account with domain-wide delegation can impersonate any user in the domain, so the agent could read Acme’s doc as me without my connection.

That erases the line this post draws. One token that can become anyone is identity decided on the credential side: whoever holds it picks the person, and no rule sees the choice. Acme shared the doc with me, not with anything our admin can make look like me. The agent’s identity here has no delegation: it’s a bot token in Slack and nothing in Google.

Composio is an execution proxy, not just a vault

A credential vault stores tokens and hands them to your code when asked. Then your service holds the token, your logs can see it, and a bug can send it anywhere.

Composio can be used differently. Each user’s connections are connected accounts under their user_id, and its proxy execute endpoint takes the provider request without the provider credential. My service authenticates with its own Composio project key, and Composio injects the account’s credential on its side. Composio now points new projects to its session-based API; this is the direct proxy the app uses today.

There’s no general “service account” in Composio: an auth config has an auth scheme (OAuth2, API key, bearer token or basic), and the connected credential decides who the account is. Slack has two integrations: slackbot acts as the bot with a bot token, and slack acts as a user with a user token, each with its own auth config. Google Docs is OAuth2 only, which is why the agent’s own write goes to Slack, not to an internal doc.

A bot post through the proxy, abbreviated:

{
    "user_id": identity.composio_user_id,
    "connected_account_id": identity.connected_account_id,
    "endpoint": "/chat.postMessage",
    "method": "POST",
    "body": {"channel": channel, "text": text, "blocks": [summary, footer]},
}

Three things follow from that.

  • The provider token never enters my app. The connection registry stores only the mapping: connection ID, member or service, owner, toolkit, Composio user ID and connected account ID. No OAuth tokens. The only secret is the Composio project key, and only the scheduler can read it.
  • The proxy stays in its lane. Composio rejects cross-domain requests, so a Google connection can only call its toolkit’s domain. The handler builds the endpoint from typed arguments; the model never writes a URL.
  • Picking an identity is just picking an ID. Switching from member to service is a different connected_account_id in the same request. No token exchange, no second client.

Put together, one call goes like this:

For the bot’s post to #acct-acme, CMA sends a custom-tool event. The host resolves the stored service connection and asks OpenAPPA to authorize the call as service. After allowance, the scheduler calls Composio using connection IDs and its project key. Composio injects the Slack bot token for chat.postMessage and returns Slack’s response. The host delivers the result to CMA after OpenAPPA admits it.

The grants pick the identity, and my service resolves it to a connection from trusted context. OpenAPPA then decides whether that identity may take this action on this resource, given the session’s history. Composio executes as that account, and OpenAPPA checks the result before the model reads it. The credential never moves. The decision does.

What it doesn’t solve

The example has two identities; the pattern isn’t tied to two. To OpenAPPA, _as is just another argument, so a new identity is a connection kind, a rule that resolves it from trusted context, and grants that name it: a team account from the Slack workspace, the reviewer from who approved, or the person behind an agent on the MCP front door from their OAuth sign-in. The policy engine doesn’t change. That’s the point of putting identity into the action.

What the pattern doesn’t solve:

  • Only tools you execute. Built-in tools and MCP servers that CMA calls itself bypass your service and run with their session’s credential, or none.
  • The mapping is the trust. Nothing is signed, so whoever can change thread owners or connection records can make the agent act as someone else. The registry is as sensitive as the credentials it replaced.
  • Two permission systems must agree. The provider enforces its sharing settings; the policy knows only what it declares and won’t notice if Acme adds people to the doc or someone joins #acct-acme. What’s allowed is what both allow, and aligning them is on you.
  • The proxy holds every key. Tokens leave your code by gathering in one place: one Composio project key can call any connected account, and one outage stops every tool.
  • State is shared across identities. That blocks laundering, but reading Acme’s doc also narrows every bot post in that session, even one that doesn’t use it.
  • Replies aren’t policy-checked. The label governs tool calls, not the agent’s own answer in the thread. Ask about Acme’s doc in a wide channel, and the channel sees the answer.
  • Identity doesn’t make writes safe to retry. The decision comes before the call, so a timed-out write stays uncertain until a person decides.
  • Delegation is a modeling question. When an agent acts for an agent acting for a person, any of them can be _as; the architecture can’t tell you which the grant should name.

The reference code is narrower than this post. The Acme example and grant routing are merged into the private app (pull request #12), where they ran end to end in a dev Slack workspace against a real Doc. The public repo has the rule syntax but not identity routing yet.

The takeaway

For agents, a credential says what an account can do. It can’t say what this action should do. Put the identity into the action: one grant says who, what and where, and the policy decides with the session’s history in view. Read with the account the owner trusted, write with the account that did the work, and let history decide where it may go. Custom tools give you the trusted context to pick the identity, with nothing new to sign. An MCP gateway can do the same, but it has to rebuild that context and protect the token that carries it, or it ends up letting the model pick. An execution proxy like Composio lets you use the identity without ever holding the credential.

How do you decide whose identity your agents act under?


Public reference app: ryfeus/managed-agent-web-slack. Acme example: policy, walkthrough and tests at commit bde199e, merged from pull request #12, in a private repository for now; public example links are pending. A reference implementation, not a production-readiness claim.

#AIAgents #AgentSecurity #Identity #Authorization #Anthropic