Per-User Data Isolation
Scope user-owned AgentOS data and resources to the caller's user ID.
Authorization controls which operations a caller can perform. Per-user data isolation controls access to user-owned rows in built-in AgentOS routes. Opt in with user_isolation=True:
from agno.os import AgentOS
agent_os = AgentOS(
id="my-agent-os",
agents=[agent],
authorization=True,
user_isolation=True,
)With verified JWT identity, AgentOS uses the token's sub claim as the user_id:
| Operation | Behavior with user_isolation=True |
|---|---|
| User-owned reads | Scoped to the caller's user_id. Other users' rows are not returned. |
| User-owned writes | user_id is coerced to the caller's sub. A caller cannot persist rows attributed to another user. |
| Cancel / resume / continue routes | Require session_id and verify the caller owns the run. |
| WebSocket reconnect | Requires session_id (and workflow_id) for non-admins. |
Under the default scope provider, a caller holding admin_scope (default agent_os:admin) bypasses isolation and sees all data. Admins can pass user_id to filter results to one user. Set a custom override with admin_scope="ops:admin". A managed-role or custom-provider admin grant does not automatically bypass per-user isolation: token scopes provide that bypass only when they are an active grant source, such as with trust_token_scopes=True. An admin service-account PAT also bypasses self-scoping.
Some domains expose shared rows with no user_id, including shared knowledge and workspace service-account metadata. A scoped non-admin may read these rows but cannot mutate them. This does not grant access to another user's private rows.
Isolation covers built-in routes only; custom routes must apply Agno's user-scope helpers explicitly.
Isolation is off by default: with user_isolation=False, JWT and scope checks still apply, but data is not scoped per user. Isolation requires a database that records user_id (PostgreSQL recommended for production).
With and Without Authorization
Isolation is a top-level AgentOS flag, separate from authorization, so it can also run without authentication.
| With authorization | Without authorization | |
|---|---|---|
| User ID comes from | The token's sub claim | The caller: a user_id query parameter on reads, a form field on runs |
A user_id the caller sends | Ignored for scoped callers; admins can use it to filter | Used to scope the request |
| No user ID | 403 | Not scoped; returns every user's data |
| Enforcement | Enforced | Advisory; callers can choose any ID |
os.agno.com sends the signed-in username automatically when authorization is off. The legacy AuthorizationConfig(user_isolation=True) setting is still accepted with authorization=True.
Multitenancy and Shared Resources
Per-user isolation keys ownership to one user ID. It does not create an organization or tenant namespace from arbitrary JWT claims such as tenant_id. Two users in the same tenant remain distinct owners; sharing access between them requires an application policy. Keep subjects unique across tenants when they share an AgentOS database.
| Resource | Isolation boundary |
|---|---|
| Built-in user-owned rows, including sessions, memories, and stored Studio components | Scoped to the verified caller's user_id when isolation is enabled. |
| Code-defined Registry | Shared within the AgentOS instance; GET /registry has no user or tenant filter. |
| Custom queries, knowledge searches, tool clients, credentials, and files | Your application must select the tenant context and enforce its access policy. |
For a shared deployment, verify tenant membership at authentication, use resource permissions or a custom provider to restrict which agents, teams, and workflows callers may access, and apply tenant filters in database queries and tools. Separate AgentOS instances with separate registries, databases, and credentials provide distinct deployment boundaries when required.
Service Accounts
Service account principals (sa:<name>) are always scoped to themselves. The scoping decision runs in this order:
- A caller with an authoritative admin scope is never scoped. This includes admin PATs, and JWT scopes when the scope provider is an active grant source.
- A service account is scoped to its own
sa:<name>principal, even whenuser_isolation=False. - JWT callers are scoped to their
subonly whenuser_isolation=True.
A machine token stamps its sessions and memories with its own principal, so an unscoped default would read every user's history. If you need a token that reads across users, mint one with the admin scope.
Next Steps
| Task | Guide |
|---|---|
Issue tokens with the sub claim | Tokens |
| Mint machine tokens | Service Accounts |
| See the user isolation cookbook example | user_isolation.py |