CertSafari
    Databricks Certified Context Engineer Associate· Lessons

    Domain 1 · Lesson 2/45

    Just-in-Time Retrieval and Tool Result Scoping in Databricks Agents

    Given a Databricks agent design, identify which proactive context management strategies (e.g., minimal tool sets, just-in-time retrieval, tool result scoping) would reduce context window pressure before compaction becomes necessary.

    9 min read
    2.29% of exam
    6 sources
    Published 3 Oct 2026
    Docs as of 30 Sep 2026

    What you will be able to do

    • Recognize designs that load knowledge on demand through retriever tools, memory recall and skills instead of preloading it
    • Apply list-then-fetch retrieval so an agent pulls only the entries a question needs
    • Identify ways to scope what a tool returns or reads, such as views, hidden columns, direct asset references and deterministic tools
    • Match a symptom in an agent design to the proactive strategy that relieves it

    1.Just-in-time retrieval: load knowledge when it is needed

    Each turn re-sends the agent's whole context, so knowledge placed in the prompt up front is paid for on every turn, even turns that never use it. Just-in-time retrieval reverses this. Knowledge stays outside the context, and the agent pulls it in only when a question calls for it. Databricks supports several forms of this.

    The first is a retriever exposed as a tool. Databricks' guidance on connecting agents to unstructured data shows a VectorSearchRetrieverTool built over a vector search index. The agent receives the tool's definition, not the documents, and decides for itself when to query. That decision depends on a good description, so the docs advise you to provide a descriptive tool_description to help the agent understand the tool and decide when to invoke it.

    The second is reusable procedure. A task a team runs often can be captured once in a skill instead of being reasoned out from scratch each time. When a request matches, Genie Code loads the skill and runs its script. A multi-turn task becomes a single low-consumption turn, and the procedure costs nothing in context until it is actually needed.

    Checkpoint 1 of 6· Check yourself

    A team pastes a large product manual into its agent's system prompt so the agent can always answer product questions. Most conversations never touch the manual. Which change applies just-in-time retrieval?

    Sources12

    2.Deliberate memory recall: list first, fetch only what you need

    Databricks splits agent state into two stores. A session holds the working state of one interaction, most commonly the conversation transcript. Memory holds durable facts recalled across separate conversations, retrieved by semantic search. The two connect at a deliberate point: as a session accumulates, the agent or application distills the durable facts out of it and writes them to memory. The session can then be cleared, and the facts that matter survive in a store that is queried only on demand.

    How the agent queries memory is itself a context decision. The managed memory docs say this behavior belongs in the system prompt, and their example instructions open with "Use it deliberately, not by reflex." The example tells the agent to skip memory when the answer doesn't depend on who's asking, and not to re-list what it has already seen that turn. It also describes a two-step pattern. A list call returns short descriptions, and get_memory opens one full entry. For a broad question the agent works from the descriptions and reserves get_memory for the specific entry it needs.

    Checkpoint 2 of 6· Check yourself

    A user asks a broad question that touches many stored memories. According to the example memory instructions, what should the agent do?

    Checkpoint 3 of 6· Exam question

    A context engineer wants to compare two versions of a RAG agent's system prompt by running both against a held-out set of questions and scoring the responses with an LLM judge for correctness and relevance, then reviewing the results in a dashboard. Which tool is purpose-built for this?

    Sources34

    3.Tool result scoping: narrow what comes back

    Even a minimal tool set called only when needed can flood the context if each call returns too much. Tool result scoping narrows what a tool reads and returns.

    Genie Code's guidance names overly broad exploration as a common consumption driver: reading hundreds of assets when only a specific folder is needed. Its fix is to reference the exact table, file or notebook rather than having the agent find it. In an agent design, the matching move is to aim tools at the narrowest scope the task needs.

    Scoping can also be built into the data the tools touch. Genie Agents recommend creating views that exclude redundant or non-essential fields from raw tables, or hiding unneeded columns, so queries return only what matters. Trusted assets or views can encapsulate complex queries. Deterministic tools help too. Genie Code's guidance suggests reliable tools such as metric views and Unity Catalog functions for common operations, so the agent calls a known operation and gets a compact, predictable result instead of iterating toward one.

    Checkpoint 4 of 6· Check yourself

    An agent's SQL tool queries a raw table with dozens of columns, and most of them are irrelevant to the agent's task. Each result bloats the context. Which change scopes the tool's results at the source?

    Sources25

    4.Matching a design symptom to a strategy

    Exam scenarios describe an agent design and ask which change would reduce context pressure. Start by finding where the excess tokens come from: standing definitions, preloaded knowledge, oversized results, or one long context stretched across unrelated work. Then pick the strategy that acts at that point.

    Where the tokens come from, and the proactive strategy that addresses it
    Symptom in the designProactive strategy
    Many MCP servers or tools attached, few usedMinimal tool set: disable unused servers; provide only required tools
    Tools too numerous for one agent's schemaMulti-agent: each specialized agent owns a subset
    Large reference material preloaded in the promptJust-in-time retrieval through a retriever tool or skill
    Agent reads hundreds of assets or wide raw tablesTool result scoping: direct references, views, hidden columns
    One long session spanning unrelated tasksDistill durable facts to memory; start fresh context per task

    The last row is a boundary, not a reduction inside one context. Genie Code calls starting a new chat for each task the most effective lever, because a fresh context carries no tokens from unrelated work. Related work should still stay together so the agent keeps its context and reuses its prompt cache.

    Checkpoint 5 of 6· Match them up

    Match each design change to the proactive strategy it represents

    Tap a term, then the definition that fits it.

    Checkpoint 6 of 6· Exam question

    A developer wants an agent to execute governed, reusable business logic (such as a discount calculation) as a callable tool, with the logic managed under the same access controls as the organization's tables, and made available through frameworks like LangChain and OpenAI. Which tool should host this logic?

    Sources26

    Exam traps

    Each one states something that sounds right. Open it to see what is actually true.

    1. 1.To be safe, an agent should open every stored memory at the start of each turn so it never misses context.Why is that wrong?

      Databricks' example memory instructions tell the agent to recall deliberately, skip memory when the answer doesn't depend on the user, and work from list descriptions, opening only the entry it needs.

      Covered in Deliberate memory recall: list first, fetch only what you need

    2. 2.Letting the agent explore broadly is harmless, because it will discard what it doesn't need.Why is that wrong?

      Everything the agent reads while exploring enters its context and is re-sent on later turns. Databricks names broad exploration as a consumption driver and recommends narrow, direct references.

      Covered in Tool result scoping: narrow what comes back

    Sources

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

    1. 1.
      “Provide a descriptive tool_description to help the agent understand the tool and determine when to invoke it.”
      ↩︎ Just-in-time retrieval: load knowledge when it is needed
    2. 2.
      “Genie Code recognizes the request, loads the skill, and runs the script rather than planning, generating, and iterating on each run.”
      ↩︎ Just-in-time retrieval: load knowledge when it is needed
      “Overly broad exploration: Asking Genie Code to read hundreds of assets when it only needs a specific folder.”
      ↩︎ Tool result scoping: narrow what comes back
      “Give Genie Code reliable tools, such as metric views and Unity Catalog functions, for common operations.”
      ↩︎ Tool result scoping: narrow what comes back
      “Start a new chat for each task. This is the most effective lever.”
      ↩︎ Matching a design symptom to a strategy
      “Overly broad exploration: Asking Genie Code to read hundreds of assets when it only needs a specific folder.”
      ↩︎ Exam trap 2
      “point to it with @ instead of asking Genie Code to find it”
      ↩︎ Prediction
    3. 3.
      “As a session accumulates, an agent (or your application) distills the durable facts out of it and writes them to memory.”
      ↩︎ Deliberate memory recall: list first, fetch only what you need
    4. 4.
      “For a very broad question that touches many memories, summarize from the list's descriptions; reserve get_memory for the specific entry you actually need.”
      ↩︎ Deliberate memory recall: list first, fetch only what you need
      “Skip memory only when the answer truly doesn't depend on who's asking (general knowledge, math, coding) or you already have what you need.”
      ↩︎ Exam trap 1
    5. 5.
      “Use trusted assets or views to encapsulate complex queries.”
      ↩︎ Tool result scoping: narrow what comes back
      “create views to exclude redundant or non-essential fields from your raw tables”
      ↩︎ Checkpoint
    6. 6.
      “You have so many tools that fitting them all into one agent's schema is impractical; each agent can own a subset.”
      ↩︎ Matching a design symptom to a strategy
      “Provide only the tools and context your agent requires, rather than an unbounded set of APIs or large irrelevant context.”
      ↩︎ Checkpoint

    Ready to test yourself?

    Practise Databricks Certified Context Engineer Associate in quiz mode.

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