What you will be able to do
- Tell session state apart from long-term memory, and pick the right store for each
- Create a session store, then append, read, fork and delete conversation history
- Save and search memory entries, and let an agent decide what to remember through tools
- Partition memory with actor_id, and use separate stores to enforce isolation
- Recognize the legacy Unity Catalog memory store and when its governance model is what a requirement asks for
Key concept
Sessions versus memory — A session holds the working state of a single interaction, usually the ordered conversation transcript, and the agent replays it to continue that interaction. Memory holds durable facts about a subject, such as a user's preferences, and the agent recalls them in later, unrelated conversations.
1.Two kinds of agent state
An LLM call has no memory of its own. If a support agent is to answer "and what about the second cluster?" or remember next week that a customer prefers email, that context has to be written to a datastore and read back. Databricks offers two managed stores for this. Both run on Lakebase, its managed Postgres, and both work with agents built on any framework.
Agent sessions hold one interaction's state. Usually that means the transcript of messages, tool calls and results, though it can be any state a framework persists, such as a LangGraph graph. The agent reads the session at the start of a turn and appends to it as it runs. Agent memory holds durable facts, preferences and decisions. The agent finds them by search in later, separate conversations.
The two differ in scope. A session belongs to one conversation and is complete in itself. A memory belongs to a subject, usually a user or a team, and it still matters when that subject starts an unrelated conversation. Most agents use both: sessions keep a conversation coherent, and memory carries knowledge from one conversation to the next. Sessions alone are enough when the agent only needs in-interaction state. Memory alone fits when the framework already manages session state.
There are three ways for a fact to move from a session into memory: the agent writes it, the application writes it, or a memory pipeline distills it. A pipeline reads the conversations in a session store, pulls out the durable facts, and writes them to a memory store. It can run on demand or on a schedule, so the agent needs no memory-writing tools. Once a fact is in memory, it no longer depends on the session it came from. The session can be cleared or age out and the fact remains. This is the reason the two stores are independent.
Checkpoint 1 of 7· Match them up
Match each agent requirement to the store setup it calls for.
Tap a term, then the definition that fits it.
Sessions hold the state of one interaction, and memory holds facts about a subject that carry across conversations. Use sessions alone when you only need in-interaction state, memory alone when the framework already manages session state, and both for most agents.
“Use sessions alone when you only need in-interaction state, or memory alone when your framework already manages session state.”Source: docs.databricks.com
Sources1
2.Session stores, sessions and items
Agent sessions are organized in three levels.
- A session store is the workspace-scoped container. Creating one provisions its Lakebase storage automatically, and its name must be unique in the workspace and 3 to 63 characters long.
- A session is one durable interaction, typically a conversation thread. It carries a required
actor_id(who it belongs to), an optionalsession_id(generated by the service if you omit it), and an optionalparent_session_id(the session it was forked from). - A session item is one entry in the session's ordered history. It holds an opaque, JSON-compatible value such as a message, tool call, tool result or reasoning block.
The service gives each item an item_id and a create_time but never inspects or validates the contents. Items cannot be changed after they are appended.
from databricks.sdk import WorkspaceClient
from databricks_agentkit import AgentKitClient
client = AgentKitClient(WorkspaceClient())
client.session_stores.create("support-agent-sessions", description="Support agent conversations")
client.memory_stores.create("support-agent-memory", description="Support agent long-term memory")A turn follows the same pattern in most frameworks. The agent reads the history, runs, and appends the new items. One detail catches people out: list_items returns the newest item first, so to rebuild context in conversation order you have to request order_by="create_time asc". The example below also checks ownership, because looking up a session by session_id is not scoped to an actor. Without that check, any user who knows another user's conversation ID could resume it.
def handle_message(user_id: str, conversation_id: str, message: str) -> str:
session = session_store.get(conversation_id)
if session.actor_id != user_id:
raise PermissionError("This conversation belongs to a different user.")
# Rebuild context from the stored history, oldest first.
history = [item.data for item in session.list_items(order_by="create_time asc")]
user_item = {"type": "message", "role": "user", "content": message}
reply = run_agent([*history, user_item]) # Your framework or model call.
session.append_items([user_item, {"type": "message", "role": "assistant", "content": reply}])
return reply| Framework operation | Session store call |
|---|---|
| Read history | list_items in chronological order (order_by="create_time asc") |
| Add turn items | append the new items |
| Undo last item | pop the most recent item |
| Clear the thread | clear the session's items |
Branching and deletion are built on the parent link. Forking a conversation produces an independent copy, optionally cut off at a specific item, and the new session's parent_session_id points back to the original. That is how a UI can let a user retry from an earlier turn. Because of these links, deleting a session that has children fails unless you pass a force option, for example session.delete(force=True), which cascades the delete to the children.
The store keeps whatever the framework appends, and nothing more. Runs, checkpoints and approvals are not first-class resources. A framework that serializes that kind of state can still persist it as items.
Checkpoint 2 of 7· Check yourself
A per-user support app creates each session with actor_id set to the verified user. A handler loads a conversation with session_store.get(conversation_id), using an ID taken from the request, and then appends the new turn. If user B sends user A's conversation ID, what happens?
A session_id lookup is not scoped to an actor, and actor_id only groups sessions. The application has to compare session.actor_id with the requesting user before it resumes the conversation.
“Looking up a session by session_id isn't scoped to an actor, so check that the session belongs to the requesting user before you resume it.”Source: docs.databricks.com
Checkpoint 3 of 7· Fill the gap
This line rebuilds a session's history so the agent can replay the conversation in the order it happened. Which value completes it?
history = [item.data for item in session.list_items(order_by=" ? ")]list_items returns the newest item first by default. To replay the conversation in the order it happened, you have to request create_time ascending.
Source: docs.databricks.com3.Saving and searching memory entries
A memory store is the workspace-scoped container for long-term memory. As with session stores, creating one provisions its Lakebase storage, and Databricks runs the indexing and search. The store's display_name must be 3 to 56 characters: lowercase letters, numbers and hyphens, starting with a lowercase letter and ending with a letter or number. A name like Support_Memory is rejected.
Each memory entry has free-form content and a short description that improves retrieval. Its fields are a required actor_id (whose memory it is), an optional session_id (which session it came from, for provenance), and a required path that organizes entries within an actor, such as /preferences/communication.md. The combination of actor_id, session_id and path uniquely identifies an entry.
Entries can be retrieved in two ways, and both are scoped to one actor. List returns an actor's entries, optionally filtered by session_id or a path prefix, which suits a page showing everything the agent knows about a user. Search takes a natural-language query and ranks the actor's entries by full-text BM25 relevance. Use search at answer time, when the agent needs whatever bears on the current question.
To let the agent decide what to remember, wrap search and add as tools and use the system prompt to say when to call them. The important part is what the tools leave out: actor_id is bound in application code when the tools are built, so the model can choose the query, path and content but never whose memory it reads or writes. The same wrapping works for the OpenAI Agents SDK, the Claude Agent SDK and other frameworks.
def make_memory_tools(memory_store, actor_id: str):
@function_tool
def search_memory(query: str) -> str:
"""Search long-term memory for relevant facts about the user."""
results = memory_store.search(actor_id=actor_id, query=query, limit=10)
return "\n\n".join(f"{r.memory.path}: {r.memory.content}" for r in results) or "No memory found."
@function_tool
def save_memory(path: str, content: str, description: str = "") -> str:
"""Save a durable, long-term memory about the user."""
memory_store.add(actor_id=actor_id, path=path, content=content, description=description)
return f"Saved memory at {path}"
return [search_memory, save_memory]Checkpoint 4 of 7· Check yourself
Your team is giving a multi-user support agent search_memory and save_memory tools so it can decide for itself what to remember. Which design stops the model from reading or writing another user's memories?
actor_id is bound in trusted code when the tools are created, so the model controls what it searches or saves but never whose memory it is. A system-prompt instruction still lets the model choose the actor. A session_id filter doesn't decide whose entries are returned. actor_id is a required field, so the store does not fill it in for you.
“Never let the model choose whose memory to read or write.”Source: docs.databricks.com
Sources4
4.Partitioning with actor_id and securing the store
In both stores, actor_id decides whose data a read returns, and every list and search covers a single actor. Choose the value according to who should share what.
| Strategy | actor_id value | Example |
|---|---|---|
| Private memory for each user | The verified end-user identity | A support agent remembers one user's communication preferences and past tickets |
| Shared memory for a group | A fixed key such as a team, project or organization ID | A team agent remembers a shared glossary of company terms |
| Memory split by something else | A composite such as {tenant}:{user} | Each customer's users in a multi-tenant app stay isolated from one another |
Set actor_id in application code from trusted request context, never from model output or a value the user typed. If your strategy depends on an end-user identity and a request arrives without one, reject the request. Do not fall back to a shared actor_id. A fallback like that quietly puts anonymous users' facts into one pool that every one of them can read.
actor_id organizes data. It does not grant or restrict access, in either store. Both store types are workspace-scoped and authorize access at the store level, so any principal that can reach a store can read and write every entry for every actor. The store is the security boundary. When tenants must be strictly isolated, give each tenant its own store, or its own pair of session and memory stores. To let a principal such as the agent's service principal use a store, call that store's grant-permission operation: memory_store.grant_permission(principal_id) or session_store.grant_permission(principal_id).
Checkpoint 5 of 7· Match them up
Several teams are designing their agents' memory. Pair each requirement with the setup that meets it.
Tap a term, then the definition that fits it.
actor_id only decides whose entries a list or search returns, so the right value depends on who should share memories. It is not an access control. Any principal that can reach a store can read every actor's entries, so strict tenant isolation needs a separate store for each boundary.
“For strict isolation between tenants or users, create a separate memory store per boundary.”Source: docs.databricks.com
5.The Unity Catalog memory store
Before the Lakebase-backed agent memory, Databricks offered a managed memory store governed by Unity Catalog. It is now deprecated for new agents. It still matters because its governance model differs from the current store's. In that design, a memory store is a Unity Catalog securable that acts as a container for entries, created under a schema by a principal holding the CREATE MEMORY STORE privilege on that schema. Like any Unity Catalog asset, it inherits governance, access control and lineage. Agents across different projects can share it, and Unity Catalog decides who can reach it.
Entries in the legacy store are identified by a scope and a path. The scope plays the role actor_id plays now: the application sets it on every read and write, and a search only returns entries with a matching scope. A scope keeps one user's memories private or shares them across a group, but nothing beyond that. It does not make a user's private entries visible to other agents.
| Requirement | Agent memory (Lakebase-backed) | Managed agent memory (legacy, Unity Catalog) |
|---|---|---|
| What the store is | Workspace-scoped container addressed by display_name | Unity Catalog securable under a schema |
| Who may create one | Any principal able to create stores in the workspace | A principal with CREATE MEMORY STORE on the parent schema |
| How access is controlled | Store-level grant via grant_permission | Unity Catalog governance, access control and lineage |
| Partition key inside the store | actor_id | scope |
Checkpoint 6 of 7· Check yourself
Durable knowledge must be shared by agents across several projects, and governance requires Unity Catalog to enforce access control and record lineage for it. Which store meets that requirement?
Only the earlier managed memory store is a Unity Catalog securable, so it inherits Unity Catalog governance, access control and lineage. The Lakebase-backed store is workspace-scoped and uses store-level grants. A shared actor_id only groups entries, and checkpointers don't provide Unity Catalog lineage.
“Managed agent memory (legacy): the earlier managed memory store, governed by Unity Catalog.”Source: docs.databricks.com
Checkpoint 7 of 7· Exam question
A platform team wants multiple agents across different projects to share durable, long-term knowledge about company policies, and they need Unity Catalog to enforce access control and lineage on that knowledge. Which persistence approach satisfies these requirements?
Correct answer: A — Use a managed agent memory store that each agent reads from and writes to; as a Unity Catalog securable object, it takes grants and lineage from the catalog like other assets.
- A. A managed agent memory store is a Unity Catalog securable object. Access control and lineage come from the catalog like any other governed asset, and agents in different projects can share the durable policy knowledge it holds.
- B. A self-managed Lakebase database is a Postgres instance the team runs themselves. Its tables are not tracked in Unity Catalog lineage or covered by catalog access control without extra work, so the governance requirement is not met.
- C. A LangGraph checkpointer saves conversation state per thread so one agent can resume a session. It is not a long-term knowledge store, its checkpoints are not governed by Unity Catalog grants, and it does not share company policy knowledge across projects.
- D. The
user_clientscope keeps entries private to an individual end user instead of sharing them. Scoping the store this way keeps company-wide policy knowledge from being shared across agents and projects.
Sources
(5)
Every claim above is drawn from one of these pages, quoted as it was written on the date shown.
- 1.
“Sessions are scoped to one interaction: the working state the agent replays to continue that interaction, such as its conversation transcript.”
↩︎ Two kinds of agent state“A memory pipeline reads the conversations in a session store, extracts the durable facts, and writes them to a memory store”
↩︎ Two kinds of agent state“Managed agent memory (legacy): the earlier managed memory store, governed by Unity Catalog.”
↩︎ The Unity Catalog memory store“Memories are scoped to a subject, not an interaction”
↩︎ Key concept“deleting a session, or an entire session store, does not delete memory retained in a memory store.”
↩︎ Exam trap 2“deleting a session, or an entire session store, does not delete memory retained in a memory store.”
↩︎ Prediction“Use sessions alone when you only need in-interaction state, or memory alone when your framework already manages session state.”
↩︎ Checkpoint - 2.
“parent_session_id (optional): links a session to the one it was forked from, to represent branched conversations.”
↩︎ Session stores, sessions and items“Items are immutable after they are appended.”
↩︎ Session stores, sessions and items“list_items defaults to newest-first and auto-pages”
↩︎ Session stores, sessions and items“Deleting a session that has child sessions requires a force option to cascade the deletion to them”
↩︎ Session stores, sessions and items“The actor_id and metadata fields support grouping and filtering only; they do not grant or restrict access.”
↩︎ Partitioning with actor_id and securing the store - 3.
“Looking up a session by session_id isn't scoped to an actor”
↩︎ Session stores, sessions and items“A session store name must be 3 to 63 characters.”
↩︎ Session stores, sessions and items“The store is the security boundary: any principal with access to a store can read and write all of its entries.”
↩︎ Partitioning with actor_id and securing the store“Looking up a session by session_id isn't scoped to an actor, so check that the session belongs to the requesting user before you resume it.”
↩︎ Checkpoint - 4.
“An entry is uniquely identified by the combination of actor_id, session_id, and path.”
↩︎ Saving and searching memory entries“Search returns the most relevant entries ranked by a full-text (BM25) relevance score.”
↩︎ Saving and searching memory entries“Never let the model choose whose memory to read or write.”
↩︎ Saving and searching memory entries“the pipeline can rewrite, merge, split, or delete the entries your agent saves for any actor it processes.”
↩︎ Saving and searching memory entries“reject requests that don't carry one rather than falling back to a shared actor_id.”
↩︎ Partitioning with actor_id and securing the store“actor_id separates memories, but it is not an access control.”
↩︎ Exam trap 1“For strict isolation between tenants or users, create a separate memory store per boundary.”
↩︎ Checkpoint - 5.
“This is an earlier version of the managed agent memory store and is deprecated.”
↩︎ The Unity Catalog memory store“The CREATE MEMORY STORE privilege on the parent schema to create memory stores.”
↩︎ The Unity Catalog memory store“a search only returns entries with a matching scope”
↩︎ The Unity Catalog memory store“A memory store inherits the same governance, access control, and lineage as any other Unity Catalog asset.”
↩︎ Exam trap 3