What you will be able to do
- Decide whether a multi-step agent task can keep its working state in an in-context scratchpad or needs a durable, Lakebase-backed state store
- Name the four triggers (resume after failure, step count beyond the window, concurrent writers, auditability) and the failure each one causes when it is ignored
- Describe Lakebase as the durable store for agent state, and say what it is not
- Explain what a managed agent session does (appends each step durably and rebuilds context from it) and what it does not do (summarize, or carry state into a later conversation)
Key concept
Durable-state trigger rule — An in-context scratchpad is enough for a multi-step task until one trigger applies: the task must resume after a failure, its steps outgrow the context window, more than one writer updates its state, or its steps must be auditable. Any one of these makes a durable, table-backed store mandatory.
1.The in-context scratchpad and when it is the right choice
An in-context scratchpad is working state that exists only in the prompt the model sees and in the memory of the process running the agent. Plans, partial results, drafts and step counters written there cost nothing extra to store and nothing extra to read back, because they are already in context. The catch is that they share the fate of that process and that context window. If either ends, the state ends with it.
For transient reasoning, that limitation does not matter, and the scratchpad is the correct design. Take a support agent that answers one question by drafting an outline, refining it twice and writing the final reply, all inside a single turn that finishes in a few seconds. Nothing has to survive the turn. No other process reads the drafts, and nobody will audit them. Writing each draft to a Delta table, a Lakebase Postgres row or a governed Unity Catalog table adds a network round trip and a schema to maintain, and it buys nothing. The intermediate drafts belong in the scratchpad.
The question to ask is never "is this task multi-step?" Lots of multi-step reasoning fits comfortably in one turn. Ask instead whether anything about the task needs its state to exist outside the model's context and the agent's process. When something does, the scratchpad is no longer a design choice. It is a bug waiting for its first restart.
Checkpoint 1 of 8· Check yourself
In which of these scenarios can the agent no longer keep its working state in an in-context scratchpad?
Scratchpad state ends when the process or context window ends, so a task that has to resume after a restart needs its state held in a durable store outside the process. The other three are multi-step, but each finishes inside one turn with no restart, no other writer and no audit need, so the scratchpad is the right design for them.
“Persist an agent's conversation history so it survives restarts and can be resumed later.”Source: docs.databricks.com
Checkpoint 2 of 8· Exam question
A support agent answers a single user question by drafting an outline, refining it twice, and then producing a final reply, all within one short conversation turn that completes in seconds. Which memory approach is most appropriate for the intermediate outline and drafts?
Correct answer: B — Keep the drafts in the in-context scratchpad for the duration of the turn
- A. Incorrect: writing every intermediate draft to Delta adds durability overhead with no benefit, since the drafts are only needed within the single, short-lived turn.
- B. Correct: for transient reasoning that lives and dies within one turn, an in-context scratchpad is sufficient and avoids unnecessary persistence overhead.
- C. Incorrect: Lakebase is meant for durable, cross-session state; using it for throwaway intermediate drafts adds latency and cost without a durability need.
- D. Incorrect: Unity Catalog governs durable, shareable data assets, which is unnecessary overhead for transient in-turn reasoning that no other process needs.
Sources1
2.Four triggers that make a durable store mandatory
Resume after failure is the most common trigger. Picture a data migration that runs for three days on compute that sometimes restarts between steps. Progress kept in the context window vanishes when the process dies. The same goes for progress kept in a Python variable inside the agent process. Re-summarizing the conversation at the start of every step does not help either: the summary is still held in the same volatile context, so a restart wipes it out as well, and summaries lose detail besides. The design that works is to write each completed step to a Lakebase-backed state table, and on startup read that table to find the last completed step. The managed session store exists for this purpose. One stated use is to persist history "so it survives restarts and can be resumed later." On Model Serving, Lakebase-backed LangGraph checkpoints let an agent resume or fork from any earlier checkpoint.
Step count beyond the window applies even when nothing crashes. Every tool result and intermediate value written to the scratchpad takes up tokens. On a long task, the early steps either get cut off or get compressed into a lossy summary. A durable store keeps every step exactly, so the agent can read back the specific step it needs and does not have to carry all of them in context.
Concurrent writers cover any case where more than one process updates the task's state. That could be two workers splitting a batch, a human approving a step while the agent keeps going, or a retry overlapping the original attempt. A scratchpad belongs to one context window, so the other writers cannot see it. A transactional store gives every writer one shared, ordered record to read and update. Without one, each writer acts on its own stale copy of the progress.
Auditability applies when someone later has to prove what the agent did at each step: which rows it migrated, which approval it relied on. A scratchpad leaves no record once the turn ends. State rows in Lakebase can be captured by Lakebase Change Data Feed, where every change is "written as a new row in a Delta history table" in Unity Catalog, ready for audit queries.
| Trigger | Failure with an in-context scratchpad | What a durable store provides |
|---|---|---|
| Resume after failure | Progress dies with the process or context on restart | Session history that survives restarts and can be resumed later |
| Step count beyond the window | Early steps truncated or summarized away | Every step kept as an item, read back on demand |
| Concurrent writers | Each writer works on its own invisible copy | A deterministic order of items, with every operation authorized against the store |
| Auditability | No record survives the turn | Immutable items, each with an item_id and a create_time |
Checkpoint 3 of 8· Match them up
Match each durable-state trigger to what a durable session store gives the agent that an in-context scratchpad cannot
Tap a term, then the definition that fits it.
Each trigger matches a different scratchpad failure. A restart erases progress, the window cuts off early steps, other writers cannot see the scratchpad, and no record survives the turn. The session store fixes each one: history that persists, items kept exactly, a shared ordered record, and immutable timestamped items.
“The service maintains a deterministic order for a session's items and authorizes every operation against the session store.”Source: docs.databricks.com
Checkpoint 4 of 8· Exam question
An agent runs a multi-step data migration that can take up to three days to complete, with the underlying compute occasionally restarting between steps. The team needs the agent to resume exactly where it left off after any restart. Which memory design best fits this requirement?
Correct answer: B — Persist step progress to a Lakebase-backed state table and reload it on restart
- A. Incorrect: an in-context scratchpad is lost whenever the process restarts or the session ends, so it cannot survive a multi-day job with compute restarts.
- B. Correct: a Delta-backed state store like Lakebase persists across restarts and sessions, letting the agent read back exactly where it stopped and resume reliably.
- C. Incorrect: resummarizing conversation history does not recover durable checkpoint data and still depends on context that may already be gone after a restart.
- D. Incorrect: an in-process variable is held in memory and is wiped out the moment the process restarts, offering no durability.
3.Lakebase as the durable store for agent state
Lakebase is where durable agent state lives on Databricks. It is a fully managed Postgres database built into the platform, with automatic scaling, instant branching and native Unity Catalog integration. Being an OLTP database, it is designed for what agent state needs: many small writes (one per completed step) and fast reads of specific rows by key (the latest step for this task). Lakebase serves as the backend for agent memory, and agents built with LangGraph or the OpenAI Agents SDK store their conversation state in it.
Distractors about Lakebase usually describe it as something else. It is not an in-memory cache that throws state away when a session ends. Its whole purpose here is that state outlives the process. It is not only a vector index for semantic search over documents. Lakebase does offer hybrid vector and keyword search, but durable state is read back with ordinary keyed queries. And it has nothing to do with prompt templates or system instructions.
The phrase "Delta-backed state object" describes the pattern of a durable, table-backed record of task progress. On Databricks, the live state table sits in Lakebase Postgres, and Change Data Feed can mirror its rows into Unity Catalog Delta tables for audit and downstream pipelines.
Checkpoint 5 of 8· Check yourself
An architect wants a migration agent to save each completed step to Lakebase and to look up its last completed step there after a restart. What is Lakebase, and how does the agent read that step back?
Lakebase is a managed Postgres OLTP database built for many small writes and fast keyed reads, so the agent can read its last step back with an ordinary query. It is not a cache that loses state when a session ends, and its vector search is not how state is read back. Change Data Feed only copies the live rows into Delta tables for audit.
“Lakebase provides a fully managed Postgres backend for storing agent state and memory”Source: docs.databricks.com
Checkpoint 6 of 8· Exam question
Which statement accurately describes Lakebase as it relates to storing durable agent state on Databricks?
Correct answer: A — It is a fully managed Postgres database with instant branching and native Unity Catalog integration
- A. Correct: Lakebase is documented as a fully managed Postgres database offering automatic scaling, instant branching, and native Unity Catalog integration, making it suitable as a durable state store for agents.
- B. Incorrect: an in-memory cache that discards state at session end describes an ephemeral scratchpad, which is the opposite of what Lakebase provides.
- C. Incorrect: a vector index for semantic search describes AI Search, a retrieval component, not Lakebase's transactional Postgres role.
- D. Incorrect: a prompt template library relates to system prompt design, not to durable state storage.
4.Managed agent sessions: append each step, rebuild context
Managed agent sessions are the ready-made form of this durable store. A session store is a workspace-scoped container backed by Lakebase. A session is one durable interaction inside it, identified by an actor_id and a session_id. As the agent runs, it appends session items: messages, tool calls, tool results, reasoning blocks, or any other JSON-compatible state its framework serializes. At the start of the next request, or after a restart, the agent reads the items back in chronological order (order_by="create_time asc") and rebuilds its context from them. In practice, adopting sessions means replacing the agent's in-process history with the session store, as the adapter below does for the OpenAI Agents SDK.
async def handle_message(user_id: str, conversation_id: str, message: str) -> str:
session = session_store(conversation_id, actor=user_id, store=SESSION_STORE)
result = await Runner.run(agent, message, session=session)
return result.final_outputA session store has two limits, and both matter. First, it does not summarize. Items are opaque, the service does not inspect or validate their contents, and they are immutable once appended. The store gives back exactly what was written. If the rebuilt history is too big for the window, compacting it is still the agent's job. Second, it does not carry anything across sessions. A session holds the state of one interaction and is complete in itself. Facts that must hold up in a later, unrelated conversation belong in agent memory.
Choosing between those two stores is covered in Session state vs cross-session memory. For this decision, the rule is short: once multi-step task state has to persist, put it in a session store, unless it has to outlive the conversation.
No. The new conversation is a new session, and a session store does not carry state from one session into another. The agent can only answer if the facts were written to agent memory, or if the old session (or its audit trail) is queried directly.
Checkpoint 7 of 8· Fill the gap
This OpenAI Agents SDK handler needs to keep the conversation history in the managed session store, not in the process, so that the conversation survives a restart. Which call completes the handler?
async def handle_message(user_id: str, conversation_id: str, message: str) -> str:
session = ? (conversation_id, actor=user_id, store=SESSION_STORE)
result = await Runner.run(agent, message, session=session)
return result.final_outputsession_store() returns a Session backed by the managed session store. Runner.run loads the conversation's history from it and appends new items to it, so the state lives outside the process. A memory store holds facts that carry across separate conversations, and a checkpointer is the LangGraph adapter, not the one for the OpenAI Agents SDK.
Source: docs.databricks.comCheckpoint 8 of 8· Check yourself
A long-running agent appends every message, tool call and tool result to a managed session store. After a restart, the history it reads back in chronological order no longer fits in the context window. What happens next?
Session items are opaque and immutable, and the service returns exactly what was appended without looking at it. Fitting the rebuilt history into the window is still the agent's job. Going back to a scratchpad would bring back the restart problem the session store solves.
“the service persists and returns whatever your agent or framework appends, without interpreting it”Source: docs.databricks.com
Sources
(6)
Every claim above is drawn from one of these pages, quoted as it was written on the date shown.
- 1.
“Agents need persistent storage to maintain context across turns and sessions.”
↩︎ The in-context scratchpad and when it is the right choice“Supports LangGraph time travel to resume or fork conversations from any checkpoint.”
↩︎ Four triggers that make a durable store mandatory“Agents need persistent storage to maintain context across turns and sessions.”
↩︎ Key concept“Agents need persistent storage to maintain context across turns and sessions.”
↩︎ Prediction“Lakebase provides a fully managed Postgres backend for storing agent state and memory”
↩︎ Checkpoint - 2.
“Persist an agent's conversation history so it survives restarts and can be resumed later.”
↩︎ Four triggers that make a durable store mandatory“The service maintains a deterministic order for a session's items and authorizes every operation against the session store.”
↩︎ Four triggers that make a durable store mandatory“Items are immutable after they are appended.”
↩︎ Managed agent sessions: append each step, rebuild context“Persist an agent's conversation history so it survives restarts and can be resumed later.”
↩︎ Exam trap 1“Databricks assigns each item an item_id and a create_time and does not inspect or validate its contents.”
↩︎ Exam trap 2“For long-term memory that persists across conversations, use agent memory.”
↩︎ Exam trap 3“Persist an agent's conversation history so it survives restarts and can be resumed later.”
↩︎ Checkpoint“the service persists and returns whatever your agent or framework appends, without interpreting it”
↩︎ Checkpoint - 3.
“Every insert, update, and delete is captured from the write-ahead log and written as a new row in a Delta history table.”
↩︎ Four triggers that make a durable store mandatory“Lakebase serves as the backend for agent memory and real-time feature serving.”
↩︎ Lakebase as the durable store for agent state - 4.https://docs.databricks.com/aws/en/oltp/projectsOfficial docs
“with automatic scaling, instant branching, and native Unity Catalog integration”
↩︎ Lakebase as the durable store for agent state“with automatic scaling, instant branching, and native Unity Catalog integration”
↩︎ Exam trap 4 - 5.
“Replace your agent's in-process conversation history with the session store that you created in Step 2.”
↩︎ Managed agent sessions: append each step, rebuild context - 6.
“A session grows within the interaction and is complete on its own.”
↩︎ Managed agent sessions: append each step, rebuild context