Sessions & Identity¶
Everything in Athena is scoped by a three-level identity hierarchy. Understanding it is a prerequisite for every other page.
The hierarchy¶
| Level | Meaning | Example |
|---|---|---|
tenant_id |
The isolation boundary: a customer, organization, or platform | tenant_acme |
user_id |
A human (or principal) within the tenant | user_123 |
agent_id |
One of possibly many agents serving that user | support-bot |
The hierarchy is embedded in every artifact Athena creates:
- Redis STM keys:
stm:{tenantId}:{userId}:{agentId} - Task queues:
memory_processing_queue:v1:{tenantId}:{userId}:{agentId} - MongoDB documents, Milvus vectors, and ArangoDB nodes/edges all carry the scope fields and every query filters on them
Scoping rules by tier¶
STM is agent-scoped. Each agent has its own window, so two agents serving the same user don't pollute each other's working memory.
MTM and LTM are user-scoped. Cognitive chains and graph knowledge belong to the user, across agents. SearchMemory deliberately searches all of a user's chains regardless of which agent created them: what a user told the support agent is retrievable by the sales agent, inside the same tenant.
Tenant is the hard wall
Nothing crosses tenant_id: not searches, not analytics, not graph traversals. User-scoping shares memory within a tenant only.
Sessions¶
A session is a handle for a sequence of interactions, created with CreateSession:
POST /api/v1/sessions
{"tenant_id": "acme", "user_id": "user_123", "agent_id": "support-bot", "metadata": {...}}
The returned session_id goes into the path of every subsequent call (/api/v1/sessions/{session_id}/...). Sessions resolve to their (tenant, user, agent) scope on every request; the memory itself is keyed by scope, not by session, so a new session with the same identity picks up exactly where the old one left off. That is the point: sessions are ephemeral, memory is not.
Sessions are stored in MongoDB with their metadata. GetSession returns a session's scope and activity, and DeleteSession erases what was stored through it: its STM entries, events, blobs, and the MTM chains and vectors formed from them. Every event records the session it came through, so this works even though memory is keyed by scope. To erase a person, an agent or a tenant entirely, across all their sessions, use EraseMemory; see the API Reference.
Where identity comes from¶
Identity comes from the caller's credentials:
- A JWT names the tenant, the user and optionally the agent.
CreateSessiontakes them from the token and refuses a body naming anyone else, and a session can only be used by callers whose token matches its tenant, user and (if named) agent. - A tenant API key fixes the tenant the same way; the user and agent come from the request.
- A service API key, held by a trusted backend serving many tenants, names the tenant in each request.
Calls on another tenant's session return NotFound. Running with no authentication (MEMORY_OS_ALLOW_UNAUTHENTICATED=true) trusts the request body completely and is for local development only. Details: Security Model.
Choosing your granularity¶
- One
agent_idper distinct assistant persona. Don't reuse one agent ID for functionally different bots; their STM windows will interleave. - Use metadata, not identity, for request-level context (conversation channel, locale, app version).
- Multi-agent workflows that share one logical task should share
workflow_id/execution_idin event metadata; the pipeline uses these for coalescing and to avoid false topic breaks between steps of the same execution.