Memory Architecture with Lakebase and MLflow · Topic 1 of 3
Memory Types and Persistent Memory with Lakebase
Databricks Context Engineer: match session, long-term and task memory to the need, use Delta state over a scratchpad, and resume sessions with Lakebase.
- 6 min
- Includes a diagram
- Session memory covers one thread; long-term memory covers a user or subject across threads.
- What the user said in this conversation beats anything recalled from long-term storage.
- Delta-backed state is required when the task outlives the run, is shared or audited, or holds exact values.
What it is
An agent's memory is any information it brings back into the context window that was not in the current request. Memory comes in different scopes, and each scope belongs in a different store.
The exam tests two skills: spotting when an agent reads from the wrong memory for the need, and knowing which durable store (a Delta table or Lakebase) the state must live in so it survives the run.
How it works
The memory types
| Memory type | Scope | Typical content | Where it lives |
|---|---|---|---|
| In-context (working) memory | The current model call | Messages, tool results, a scratchpad | The context window only |
| Session (short-term) memory | One conversation thread | The transcript and graph state of that thread | Lakebase, through a checkpointer keyed by thread ID |
| Long-term (cross-session) memory | A user or subject, across conversations | Preferences, stable facts, past decisions | Lakebase memory store, found by semantic search |
| Durable task state | One multi-step task, across runs | Progress, IDs processed, decisions, outputs | A Delta table |
Long-term memory is usually distilled from sessions rather than copied from them whole.
Spotting the mismatch
The mismatch runs in two directions, and the symptom tells you which.
| Symptom | Mismatch | Fix |
|---|---|---|
| The user said it three turns ago, but the agent answers from an old stored preference | Reading long-term storage when the fact is in the current session | Read the session history first; it is fresher and exact |
| The agent asks again for a preference the user gave last week | Relying on session history for a need that spans sessions | Persist the fact to long-term memory and recall it in new sessions |
| A new session starts with an empty history and the agent "forgets" the open case | No session persistence, or a new thread ID each time | Resume the same thread ID from the checkpointer |
| Long-term recall returns last month's address after the user corrected it today | Session update never written back to long-term memory | Write corrections to long-term memory and supersede the old entry |
Delta-backed state versus an in-context scratchpad
A scratchpad is notes the agent keeps in its own context. It is cheap, but it disappears on a restart or a compaction, and nobody outside the run can read it.
A Delta-backed state object is required when any of these holds:
- The task spans several runs, jobs or days, and a later run must continue where the last stopped.
- Other agents, jobs or people must read the state, or audit it later.
- The state is exact data (processed record IDs, counts, approval flags) that a summary must not blur.
- A crash or compaction would otherwise lose work and cause repeated or skipped steps.
For a short, single-run reasoning chain, a scratchpad is fine. Worked case: a job reconciles 40,000 invoices in batches of 2,000 and fails at batch 13. With progress only in context, the next run cannot tell what finished; a Delta table of completed batch IDs lets it resume at batch 13.
Persistent session memory with Lakebase
Lakebase is the Databricks managed Postgres (OLTP) database, built for low-latency lookups of agent state. With LangGraph, a checkpointer saves the graph state after each step, and passing the same thread ID resumes the conversation after an interruption.
In an async agent, use LangGraph's AsyncPostgresSaver with an async connection pool to the Lakebase instance, await setup() once to create the checkpoint tables, and pass the saver to compile.
from langgraph.checkpoint.postgres.aio import AsyncPostgresSaver
checkpointer = AsyncPostgresSaver(pool)
await checkpointer.setup()
graph = builder.compile(checkpointer=checkpointer)
config = {"configurable": {"thread_id": "case-4812"}}
await graph.ainvoke({"messages": [user_msg]}, config)
The databricks_langchain package also offers a Lakebase-backed CheckpointSaver used with an instance name. Newer Databricks docs describe managed agent sessions and agent memory stores, both backed by Lakebase, with memory pipelines that distill durable facts from sessions into memory.
How the exam asks about this
- "Mid-conversation the user changes the delivery city, but the agent keeps using the city saved in its profile memory." The fact is in the current session; read session history before long-term memory.
- "A multi-day data migration agent repeats batches after every restart." Keep progress in a Delta-backed state table, not a scratchpad.
- "An async LangGraph agent must resume threads stored in Lakebase." AsyncPostgresSaver with the async pool, await setup(), then
compile(checkpointer=...)and the same thread_id.
What to remember for the exam
- Session memory covers one thread; long-term memory covers a user or subject across threads.
- What the user said in this conversation beats anything recalled from long-term storage.
- Delta-backed state is required when the task outlives the run, is shared or audited, or holds exact values.
- A scratchpad is lost on restart or compaction.
- Lakebase checkpointers persist thread state; the thread ID is what resumes a session.
- In async code,
AsyncPostgresSaverneedsawait checkpointer.setup()before use.
A new thread ID for every request silently disables session memory. The checkpoints are saved, but nothing ever reads them back.
Common mistakes
Sending every lookup to long-term memory. Long-term search is slower, less exact and may be stale. If the information was given in this conversation, the session history is the right source.
Treating a long context as persistence. A huge window still empties when the session ends or the agent restarts. Cross-session needs require a durable store.
Using a scratchpad for shared task progress. Other runs, agents and reviewers cannot see the context window, so shared task state belongs in a Delta table.
Check yourself
A user gave their preferred report format in a chat last week, and today's new chat ignores it. What is the mismatch?
The agent relies on session history, but the need spans sessions, so the preference must be stored in and recalled from long-term memory.
When must a multi-step agent use a Delta-backed state object instead of a scratchpad?
When the state must survive restarts or compaction, be read by later runs, other agents or people, or hold exact values such as processed IDs.
What resumes an interrupted LangGraph conversation stored in Lakebase?
A Postgres checkpointer backed by Lakebase, called with the same thread_id in the config, which reloads the saved thread state.
Topic 1 of 3 in Memory Architecture with Lakebase and MLflow
Test yourself on Memory Architecture with Lakebase and MLflow
The full Databricks Context Engineer Associate question bank has 600 questions, with timed practice exams and an explanation for every answer.
This study guide is independent and is not affiliated with, endorsed by, or sponsored by Databricks. Vendor names, certification names and exam codes are trademarks of their respective owners and are used for identification only.