CertSafari
    Databricks Certified Context Engineer Associate· Lessons

    Domain 4 · Lesson 22/45

    Durable state vs in-context scratchpad for multi-step agents

    Identify when a Delta-backed state object is required over an in-context scratchpad for an agent operating on a multi-step task.

    14 min read
    2.25% of exam
    6 sources
    Published 22 Oct 2026
    Docs as of 17 Oct 2026

    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?

    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?

    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.

    What breaks when each trigger meets a scratchpad, and what a durable session store supplies instead
    TriggerFailure with an in-context scratchpadWhat a durable store provides
    Resume after failureProgress dies with the process or context on restartSession history that survives restarts and can be resumed later
    Step count beyond the windowEarly steps truncated or summarized awayEvery step kept as an item, read back on demand
    Concurrent writersEach writer works on its own invisible copyA deterministic order of items, with every operation authorized against the store
    AuditabilityNo record survives the turnImmutable 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.

    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?

    Sources213

    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?

    Checkpoint 6 of 8· Exam question

    Which statement accurately describes Lakebase as it relates to storing durable agent state on Databricks?

    Sources43

    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.

    OpenAI Agents SDK handler whose conversation state lives in a managed session store, not in the processpython
    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_output

    A 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.

    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_output

    Checkpoint 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?

    Sources526

    Sources

    (6)

    Every claim above is drawn from one of these pages, quoted as it was written on the date shown.

    1. 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. 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. 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. 4.
      “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. 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

    Ready to test yourself?

    Practise Databricks Certified Context Engineer Associate in quiz mode.

    Spotted a mistake, or was something unclear? Tell us.