Cert EspressoLearn. Practise. Find your flow.

A LITTLE FOCUS.
A BIG NEXT STEP.

Your pace. Your space.
Databricks · Databricks Context Engineer Associate

Task State and Semantic vs Structured Memory

Databricks Context Engineer Associate · Lesson 11 of 18 · 1:17:36

YouTube loads only after you press play. This chapter opens at its timestamp in the full course. Watch on YouTube ↗

Learning with these videos? Subscribe for new courses and exam-style questions.

In this lesson

Prepare for the Databricks Certified Context Engineer Associate exam. In this lesson: when a multi-step task needs a durable state object in Delta or Lakebase rather than an in-context scratchpad, semantic search versus structured queries for memories, and static versus dynamic retrieval from Lakebase. Includes three original practice questions.

Study notes

The text of this lesson, to read at your own pace. Information as of November 2026.

Two hundred units, one lost list

Thistledown's inspection agent plans the yearly safety checks of two hundred units, over several hours. Halfway through, a restart wipes its notes, and it starts again from unit one. This lesson covers when a task needs a durable state object, how to search memories in Lakebase, and when to load memory once or fetch it on demand.

Scratchpad or durable state

A scratchpad is a set of notes kept in the context window, and it suits short tasks that end within one session. But it grows with every step, it can be lost when the context is compacted or the agent restarts, and no other agent can see it. A durable state object, like a Delta table or a Lakebase table, sits outside the context window. It is required when a multi step task must resume after a failure, run longer than one session, be shared between agents, or leave an audit trail. The agent then keeps only a short summary in context, and reads or writes the state object when a step needs it.

Semantic search or structured query

Memories persisted in Lakebase can be retrieved in two ways. A semantic search, like Databricks AI Search or the search of a memory store, ranks entries by meaning, for fuzzy questions, like what this tenant cares about, or how they like to be contacted. A structured query uses exact filters, for questions about IDs, dates, counts, and the latest record of something, like the last repair done in unit twelve B. A similarity search answers those exact questions badly, since a close match is not the right row. And many agents combine both: a filter first, then a semantic ranking within it.

Static or dynamic retrieval

Static retrieval loads memory once, at the start of a session, like a tenant's profile and preferences. It is fast and predictable, with no extra calls, but it can go stale during a long session, and it spends tokens on facts the task may never use. Dynamic retrieval fetches memory from Lakebase when a step needs it, so it stays current and targeted, at the cost of extra calls and latency. A common mix loads a small, stable profile up front, and fetches the rest on demand.

Putting it together

Pick each mechanism from the question in front of you. Fuzzy, meaning based questions go to semantic search, while exact, filtered ones go to structured queries. Stable facts needed in every turn are loaded statically, while changing or rarely needed facts are fetched dynamically. And task progress that must survive restarts, or be shared, goes to a durable state object, never only to the context window.

Recap

Let's recap. A scratchpad suits short tasks, but it grows, it can be lost, and no other agent can see it. A durable state object in Delta or Lakebase is required to resume, share, run long, or audit. Semantic search fits fuzzy questions, and structured queries fit exact filters, IDs, dates, and counts. Static retrieval is fast but can go stale, while dynamic retrieval stays current at the cost of calls. And a common mix loads a stable core up front, and fetches the rest on demand.

Quick checks for this lesson

The 3 questions of this lesson, as plain text. The button above runs them with shuffled choices and the reason behind every choice.

  1. A billing agent reconciles thousands of payments overnight, and finance must check in the morning which payments it matched, and why. Where should the agent keep its progress?

    • In a Delta table of progress and decisions
    • In scratchpad notes inside its context
    • In a model with a larger context window
    • In its final message to the team
    Show the answer

    In a Delta table of progress and decisions

    A Delta table of progress survives restarts, holds every decision for the audit, and stays out of the context window. “In scratchpad notes inside its context” is wrong, since notes in the context are lost on restart, and leave no trail for the team. “In a model with a larger context window” is wrong, since a larger window only delays the problem, and still keeps no record. And “In its final message to the team” is wrong, since the final message alone cannot show which payments were matched, and why.

  2. A manager asks how many repair requests unit 12B opened since March 1. Repairs are stored in a Lakebase table. Which retrieval mechanism fits?

    • A semantic search for repairs in unit 12B
    • The tenant’s stored preferences
    • Every repair of the building, loaded up front
    • A structured query filtered on unit and date
    Show the answer

    A structured query filtered on unit and date

    A structured query with exact filters on the unit and the date returns the exact count. “A semantic search for repairs in unit 12B” is wrong, since a semantic search ranks similar text, and cannot count rows reliably. “The tenant’s stored preferences” is wrong, since the tenant's preferences hold no repair history. And “Every repair of the building, loaded up front” is wrong, since loading every repair of the building wastes tokens, and leaves the counting to the model.

  3. During a two-hour planning session, a manager changes a renovation’s budget limit several times. The agent loaded it once, and keeps using the first value. Which change fits?

    • Load the budget once more, at a later point
    • Fetch the budget from Lakebase before each step
    • Search memory semantically for the budget
    • Write the budget into a longer system prompt
    Show the answer

    Fetch the budget from Lakebase before each step

    Fetch the budget dynamically from Lakebase before each step that depends on it, so the agent always uses the current value. “Load the budget once more, at a later point” is wrong, since loading the budget once again only moves the stale value to a new point in time. “Search memory semantically for the budget” is wrong, since a semantic search for budget may return an older value that only looks similar. And “Write the budget into a longer system prompt” is wrong, since a longer system prompt still holds the stale figure.