Wiring Per-User Agent Identity to Durable Runtime State in a Multi-Tenant Product
Binding each user's identity to agent state keeps tenants separate.

Per-user persistent AI agent deployment at scale requires a durable link between each user’s verified identity and the agent’s machine, memory, credentials, retrieval, and logs. A dedicated agent needs its own identity and state while sharing platform services.
Why identity-to-state binding is the core problem in multi-tenant agents
The user authenticates, takes actions, and leaves. A persistent agent does not leave in the same way, because it keeps state, resumes across sessions, and can act between user interactions. The user’s session may end while the agent’s work continues. That gap makes managing state part of maintaining identity beyond login.
The CoSAI Agentic IAM paper describes the traditional assumption as “authenticate once, trust for the session.” That assumption breaks when agents compose tasks and their security context changes during execution. An agent correctly authorized at turn one may, by turn ten, be reading another tenant’s memory, credentials, or retrieval results. The password was never the problem here. The failure is state drift, in which stored context and current authority no longer belong together.
This is also a correctness failure, even without an attacker. An agent can produce an answer from the wrong customer’s records while appearing to complete its task successfully. Its machine environment, working memory, credential store, retrieval index, and audit log each offer a place for that separation to fail. A tenant label in the prompt only tells the model what the application hopes is true about who owns those resources.
What “durable binding” actually means across the five surfaces an agent touches
Durable binding means that the user’s verified identity remains attached to every place the agent reads or writes, including after an interruption. The machine environment has its filesystem, processes, and network. Working memory includes the in-flight conversation buffer and scratch state for the current task. Credentials are the tokens and keys used to call external services. These surfaces define both what the agent can see and what it can do.
Retrieval adds the documents and records the agent reads, while logs record what happened and for whom. These are not separate exceptions to the identity rule. A retrieval result needs the same tenant boundary as a scratch file, and an audit event needs enough identity context to attribute the action. The binding must cover all five surfaces together. Otherwise, one correctly isolated component can still consume another component’s incorrectly scoped output.
Re-assertion is different because it accepts a fresh claim about the tenant without grounding that claim in runtime-held identity. The claim might come from the prompt, a model-chosen tool argument, or a request body the browser can write. None is an authority simply because it contains a tenant ID. Both the subject of an action and the actor performing it belong in authenticated session context outside the prompt. “Durable” describes that continuing relationship.
Why one identity is not enough: the agent, the user, and the delegated task context
A user ID alone still leaves important questions unanswered. A production action has at least four distinguishable identity layers, namely the requesting principal, the workload, the agent execution, and the delegated credential. The requesting principal identifies the user and tenant. The workload identifies the running software, while the execution identifies the particular session and purpose. The delegated credential defines the authority available for that operation.
Collapsing those layers into automation@company.com strips away the distinctions receiving systems need. Consider a support agent that reads a customer record, drafts a refund, requests approval, and instructs a payment system. A shared account cannot, by itself, show who initiated the task, which agent instance acted, or whether a human approved the consequential step. It also cannot establish whether the credential covered that tenant and operation. The chain of authority has become a single name.
That collapse allows an agent’s access to be mistaken for permission to fulfill a particular request. The CoSAI paper recommends a short-lived, unique agent identity bound to verifiable claims, such as the signature of its current code and model. Critical operations require validation of that identity and its claims. Credentials follow Zero Standing Privilege principles, with short-lived entitlements bound to the task and context in place of broad standing access. The distinction is between being a recognized agent and being authorized to perform this task.
Establishing the binding at runtime: the container boundary is the identity boundary
The architectural response is to make the container or machine boundary the identity boundary. The runtime enforces which identity and state belong inside it, rather than leaving that decision to application checks scattered through the workflow. Those checks can be skipped or misconfigured. A prompt can also change what the application does without changing the user’s authority. Runtime enforcement keeps that authority outside the model’s control.
In this design, the container holds the agent runtime, its identity, and its session state. Shared services that cost a lot stay outside it and use tenant-scoped addressing to serve agents. That separation gives requests leaving the container a trusted identity context from which authorization can proceed. The application no longer has to recover the tenant from whatever text happens to accompany the request.
The credential surface has a corresponding enforcement pattern. An agent container can have no outbound network access except to a sidecar reachable only over loopback. The sidecar injects authentication, forwards the request to the real service, and strips authentication metadata from the response. The agent process never gets the credential itself. Under that arrangement, compromising the agent process does not give it a secret it can simply send elsewhere, though the requested operation still needs authorization.
How do you deploy thousands of persistent agents without duplicating the whole stack?
The expensive mistake is treating a dedicated agent as a dedicated copy of every service. Each agent needs its own runtime process while it runs, its own identity bundle, and its own live session state. The bundle includes its system prompt, agent-scoped credentials, and fine-tuned configuration. Its session state holds its conversation buffer, working memory, and scratch files. Those are the parts that distinguish one agent from another.
Message routing, the cron-like scheduler, file serving, metrics, and the reverse proxy can remain shared. They use tenant-scoped addressing to serve the fleet, so each customer can use them without a separate installation. Shared infrastructure can then scale sublinearly with agent count. The boundary establishes ownership. A shared file server still has to resolve each request against the correct tenant’s files.
Idle agents also do not need idle processes. Keeping state outside the process lets agents wake on messages, schedules, and webhooks, with one turn running at a time per agent. That makes persistent memory compatible with scale-to-zero execution. Persistence belongs to the agent’s state and identity.
The same split applies to agent definitions. One definition with per-customer configuration is the right pattern in nearly every case described here. With separate copies, every prompt fix, tool change, model upgrade, and evaluation has to be done again for each copy. The configuration for each customer is tenant data stored under the tenant key.
Keeping the binding alive across a persistent agent’s full lifecycle
Sleep, resume, snapshot, migration, and crash recovery all create opportunities for identity to separate from state. A saved conversation is not enough on its own. The checkpoint must keep the identity binding so that work that resumes does not get its authority from stale or changed configuration. Snapshot and resume therefore affect both correctness and performance.
Temporal, Restate, and LangGraph’s checkpointer provide mechanisms for preserving progress after steps so execution can resume. That durability does not remove the identity requirement. The saved state must include the binding needed to reconnect the task to its verified owner. Otherwise, the framework can faithfully restore a task whose tenant context is no longer trustworthy. Execution durability and identity durability have to agree.
The lifecycle starts when a trusted backend establishes identity from a verified token, never from the prompt or request body. On suspension, the checkpoint retains the identity bundle while idle billing stops. On wake, identity is re-verified against the runtime-held token before the first action of the new turn. During migration or upgrade, the bundle travels with the checkpoint rather than being re-derived from configuration that may have changed.
Deleting a customer, user, or thread requires cascading removal of its agents, histories, files, and per-tenant keys. Deriving keys from the platform’s own IDs makes that cascade tractable. Long-running asynchronous work also needs credentials that refresh across providers without the user having to step in. Refresh must keep tenant isolation in place and keep credentials out of the LLM context window.
Authorizing tool calls without trusting the model’s arguments
A runtime-bound identity becomes useful at the point where a tool decides whether to act. The model reads untrusted user messages, web pages, ticket bodies, and PR comments, and its arguments reflect whatever it chose after reading them. A plausible-looking request is still only a request. The tool needs an independent source of authority.
For example, a prompt-injected agent may set customerId to “someone-else.” If the tool accepts that field as the requesting customer, the injection succeeds regardless of the system prompt’s instructions. The correct enforcement pattern takes who is asking from verified identity and checks ownership of every object named in the arguments on every call. Row-level checks belong in the tool.
The CoSAI paper’s capability–risk classification adds the agent’s declared purpose and current delegation chain to that decision. Permission to read a record for user A does not grant permission to write a record for user B. A well-formed argument cannot extend that delegation. Likewise, a customer’s CRM OAuth token stays in the backend, where tools select it using verified identity. It never needs to appear in either the prompt or the arguments.
Controls on usage need the same tenant context because agents can loop and spend money. Budgets per agent and per run, sender rate limits, and quota checks before a message reaches the agent all meter by tenant. That lets billing and abuse detection work from the same record of usage. The practical payoff is a consistent enforcement path from runtime identity to each tool call, rather than a developer having to remember which model-supplied fields are unsafe.
Proving the binding held: audit logs that reconstruct the full chain of authority
An audit trail has to show more than which service account called a tool. It must preserve the chain from the requesting principal through the workload and execution to the delegated credential. Otherwise, an incident review cannot distinguish an authorized task from an agent using valid access for the wrong purpose. The evidence needs the same structure as the decision.
At each boundary, that structure records the user/session ID and tenant, plus the workload certificate or deployment identity. The record of the execution also has a trace ID, purpose, policy version, and model/tool configuration. The credential record adds audience, scopes, resource, expiry, and actor claim. A standardized telemetry trace correlating session, tenant, tool, and credential lets security monitoring, incident response, and per-action compliance review query the same data. Separate teams do not have to invent separate accounts of the event.
In regulated workloads such as healthcare, lending, and insurance, immutable audit trails tied to the user record provide evidence of valid delegation and declared purpose. For PHI access, that evidence shows whether the minimum-necessary standard was applied. The same structure also makes precise revocation possible. It identifies which agent sessions used a compromised credential, for which tenants, and during which time window, allowing unaffected workflows to continue.
When the runtime is bound to the right identity, audit events get their identity context as work happens. The team still needs structured logging, but it does not need to do separate forensic work to guess who owned each action. A team that skips the binding faces that reconstruction after a breach. By then, the missing chain of authority may be impossible to recover.


