Managed agent sessions
This feature is in Beta.
Managed agent sessions give your agents a durable, framework-agnostic store for session state: the state an agent or framework keeps for one interaction. Most commonly this is the conversation history, the ordered transcript of messages, tool calls, and results that an agent reads at the start of a turn and appends to as it runs. It can also be any other state a framework persists for the interaction, such as a LangGraph graph. Databricks stores it in Lakebase and manages the storage for you, so you don't build or operate the database.
During the preview, you are billed for the underlying Lakebase instance that stores your sessions. No additional charges apply for managed agent sessions itself. Pricing is subject to change as the preview progresses.
Use managed sessions when you want to:
- Persist an agent's conversation history so it survives restarts and can be resumed later.
- Reconstruct full context (including tool calls and reasoning) on a follow-up message.
- List, resume, and branch past conversations from your own UI.
Managed sessions hold the state of a single interaction (short-term, in-session state). For durable, long-term memory that persists across conversations, use managed agent memory.
How managed sessions work
Managed sessions have three levels:
- A session store is the workspace-scoped container for an agent's sessions. Creating a store provisions the backing Lakebase storage automatically. You choose a workspace-unique
session_store_name. - A session is one durable interaction (typically a conversation thread) within a store. A session is identified by:
actor_id(required): who the session belongs to, such as an end user or another agent. It groups all of one subject's sessions so you can list and filter them together. When you build a per-user app, setactor_idto the user's ID (for example, the verified end-user identity from your app's authentication) so each user's sessions stay grouped. Set it from trusted application context, never a model- or user-supplied value.session_id(optional): a caller-chosen ID for the interaction. The service generates one when you omit it.parent_session_id(optional): links a session to the one it was forked from, to represent branched conversations.
- A session item is one entry in a session's ordered history. Each item holds an opaque, JSON-compatible
datavalue, such as a message, tool call, tool result, or reasoning block. Databricks assigns each item anitem_idand acreate_timeand does not inspect or validate its contents. Items are immutable after they are appended.
The service maintains a deterministic order for a session's items and authorizes every operation against the session store.
Requirements
- Python 3.10 or above, to use Mason (Databricks' Python client and CLI for agent APIs), which the examples below use. You can also call the REST API directly from any language, with no Python requirement.
Get started
These examples set up managed sessions for a support agent: they create a session store, start a session for one conversation, append the conversation's turns, and read the history back on a later request. Choose the client that fits your project.
- Mason
- REST API
Mason is Databricks' Python client and CLI for agent APIs. It authenticates with the Databricks SDK's WorkspaceClient.
-
Install Mason:
Bashpip install databricks-mason -
Create a session store, then start a session for one conversation.
actor_idis who the conversation belongs to; the optionalsession_iduniquely identifies this conversation:Pythonfrom databricks.sdk import WorkspaceClient
from databricks_mason import MasonClient
mason = MasonClient(WorkspaceClient())
session_store = mason.session_stores.create("support-agent-sessions")
session = session_store.add(actor_id="customer-123", session_id="case-456") -
Append the conversation's turns as the agent runs. Each item is any JSON-compatible value:
Pythonsession.append_items(
[
{"type": "message", "role": "user", "content": "I need help with my cluster."},
{"type": "message", "role": "assistant", "content": "Let's take a look."},
]
) -
On a follow-up request, reload the session and read its full history in order to rebuild context:
Pythonsession = session_store.get("case-456")
# Request chronological order; list_items defaults to newest-first and auto-pages.
history = [item.data for item in session.list_items(order_by="create_time asc")]
The clients call the REST API under /api/2.0/agents/session-stores. Call it directly for languages other than Python.
-
Generate an OAuth token with the Databricks CLI:
Bashdatabricks auth login --host ${DATABRICKS_HOST}
export DATABRICKS_TOKEN=$(databricks auth token | jq -r .access_token) -
Create a session store for your agent:
Bashcurl -X POST "https://${DATABRICKS_HOST}/api/2.0/agents/session-stores?session_store_name=support-agent-sessions" \
-H "Authorization: Bearer ${DATABRICKS_TOKEN}" -H "Content-Type: application/json" \
-d '{"description": "Support agent conversation history"}' -
Start a session for one conversation.
actor_idis who it belongs to;session_iduniquely identifies this conversation:Bashcurl -X POST "https://${DATABRICKS_HOST}/api/2.0/agents/session-stores/support-agent-sessions/sessions?session_id=case-456" \
-H "Authorization: Bearer ${DATABRICKS_TOKEN}" -H "Content-Type: application/json" \
-d '{"actor_id": "customer-123"}' -
Append a conversation turn as the agent runs:
Bashcurl -X POST "https://${DATABRICKS_HOST}/api/2.0/agents/session-stores/support-agent-sessions/sessions/case-456/items:append" \
-H "Authorization: Bearer ${DATABRICKS_TOKEN}" -H "Content-Type: application/json" \
-d '{"items": [{"data": {"type": "message", "role": "user", "content": "I need help with my cluster."}}]}' -
Read the history back in chronological order to rebuild context:
Bashcurl -G "https://${DATABRICKS_HOST}/api/2.0/agents/session-stores/support-agent-sessions/sessions/case-456/items" \
-H "Authorization: Bearer ${DATABRICKS_TOKEN}" --data-urlencode "order_by=create_time asc"
The clients also support removing the most recent item, clearing a session's items, and forking a conversation into an independent copy (optionally up to a specific item). Deleting a session that has child sessions requires a force option to cascade the deletion to them (for example, session.delete(force=True)).
Back an agent framework's session with managed sessions
Agent frameworks such as the OpenAI Agents SDK and the Claude Agent SDK read conversation history at the start of a run and append new items at the end. The session store maps directly onto that pattern:
Framework operation | Session store call |
|---|---|
Read history |
|
Add turn items |
|
Undo last item |
|
Clear the thread |
|
Scope and access
Managed sessions store a session's items as opaque, JSON-compatible values: the service persists and returns whatever your agent or framework appends, without interpreting it. It doesn't add execution-control resources such as runs, checkpoints, or approvals as first-class concepts, though a framework that serializes such state can persist it as items.
Session stores are workspace-scoped, and access is authorized at the store level. The actor_id and metadata fields support grouping and filtering only; they do not grant or restrict access. Set the actor_id from trusted application context rather than a model- or user-supplied value.
To let another principal, such as your agent's service principal, use a store, grant it access with the store's grant-permission operation (session_store.grant_permission(principal_id) in Mason).
Managed sessions and managed memory are independent. Deleting a session or session store does not delete memory retained in a memory store.