CertSafari
    Databricks Certified Context Engineer Associate· Lessons

    Domain 1 · Lesson 1/45

    Retrieval vs Memory: Fixing Missing, Wrong or Forgotten Knowledge

    Given a described agent failure, identify the context management technique that would most directly address it.

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

    What you will be able to do

    • Recognise when an agent's failure comes from knowledge it never had, and pick RAG as the fix
    • Match a retrieval symptom to the right technique: semantic, keyword or hybrid search, query rewriting, filter extraction, or re-ranking
    • Tell apart failures fixed by managed agent sessions (within one interaction) and those fixed by managed agent memory (across conversations)

    1.The agent never had the knowledge: add retrieval

    The simplest design, an LLM with a prompt, answers from what it learned in training. That works for generic questions, but such a model is often disconnected from your real business data. You can embed some data in the system prompt. When the knowledge is proprietary, changes often or is domain-specific, though, the more direct fix is retrieval-augmented generation. RAG also lets the model cite its sources, and its retrieval step can enforce access control based on the user's credentials.

    So when an agent states things that were never true for your business, or were true once but have since changed, it is usually missing knowledge, not reasoning badly. A deterministic RAG chain runs the same three steps for every request, in a fixed order the developer defines. The model doesn't decide the order, which makes the chain predictable and easy to audit.

    Checkpoint 1 of 6· Put it in order

    Put the steps of a deterministic RAG chain in order

    1. 1.Generate a response by sending the augmented prompt to an LLM
    2. 2.Retrieve top-k results from a vector index relevant to the user request
    3. 3.Augment a prompt by combining the user request with the retrieved context

    Sources12

    2.The agent retrieved, but retrieved the wrong thing

    Adding retrieval brings a new failure. When the harness pulls the wrong material from search or memory, the model can still answer confidently. Databricks splits RAG problems into retrieval quality (did the right information come back?) and generation quality (did the model use it well?). These overlap: generation can't recover from context that is missing key information or full of superfluous material.

    The fix depends on the pattern of wrong results. The examples in the table come from the Databricks RAG quality guide.

    Retrieval symptoms and the technique that targets each
    SymptomTechnique
    Users' words differ from the documents' words ("turn my phone on" vs a section called "toggling the power")Semantic search
    Queries hinge on specific technical terms ("what does model HD7-8D do?")Keyword search (e.g. BM25)
    Queries mix concepts and exact terms ("how do I turn on my HD7-8D?")Hybrid search
    Ambiguous query or multi-turn chat that doesn't match document terminologyQuery rewriting
    Query names a time period, product or place ("reports from 2023")Filter extraction plus metadata filtering
    Relevant chunks come back but are poorly orderedRe-ranking

    Some of these fixes need changes in more than one place. Retrieval quality depends on both the offline data pipeline (parsing, chunking, metadata, embedding model) and the online chain (query transformation, number of chunks, re-ranking). Filter extraction is a clear example: it only works if the pipeline has extracted the metadata fields and the retriever accepts and applies the filters.

    The same reasoning applies to structured data. If a Genie Agent picks the wrong table because tables overlap, remove the unnecessary ones. If it filters on "California" when the column stores "CA", turn on example values and value dictionaries so it can see the real values.

    Checkpoint 2 of 6· Check yourself

    Support users ask questions such as "what does model HD7-8D do?". The retriever returns manual pages that are conceptually similar but about other models. Which retrieval approach fits this query pattern best?

    Checkpoint 3 of 6· Exam question

    An agent has been running for over an hour on a data-cleaning task, and its context now contains dozens of prior tool calls and their outputs. When given a new sub-task that requires a different approach, the agent instead re-issues the same sequence of tool calls it used earlier in the session, seemingly anchored to the pattern already present in its context rather than reasoning about the new sub-task. Which failure mode is this?

    Sources3456

    3.The agent forgot: sessions or memory?

    Forgetting comes in two kinds, and Databricks has a separate managed store for each, both backed by Lakebase. A managed agent session holds the state of the interaction in progress, usually the ordered transcript of messages, tool calls and results. The agent reads it at the start of each turn and appends to it as the interaction continues. This lets an interaction survive a restart and rebuild its full context on a follow-up. Managed agent memory holds durable facts, preferences and decisions about a subject, which the agent recalls in later, unrelated conversations.

    The two stores connect: as a session builds up, the agent or application extracts the durable facts and writes them to memory. The stores are independent, so clearing a session doesn't remove anything from memory. To let an agent decide when to save and recall, wrap the store's operations as tools and explain in the system prompt when to use them.

    Wrapping managed memory search as an agent tool; actor_id is fixed by the application, not passed in by the modelpython
    def make_memory_tools(memory_store, actor_id: str):
        @function_tool
        def search_memory(query: str) -> str:
            """Search long-term memory for relevant facts about the user."""
            results = memory_store.search(actor_id=actor_id, query=query, limit=10)
            return "\n\n".join(f"{r.memory.path}: {r.memory.content}" for r in results) or "No memory found."

    Checkpoint 4 of 6· Fill the gap

    Which memory store operation completes the save tool?

        @function_tool
        def save_memory(path: str, content: str, description: str = "") -> str:
            """Save a durable, long-term memory about the user."""
            memory_store. ? (actor_id=actor_id, path=path, content=content, description=description)

    Checkpoint 5 of 6· Check yourself

    An agent's serving process restarts in the middle of a multi-step interaction. When the user follows up, the agent has lost the transcript, including its earlier tool calls. What addresses this most directly?

    Checkpoint 6 of 6· Exam question

    A retrieval step returns three chunks: one relevant passage about a product's warranty policy and two unrelated chunks about a different product line that happened to match on shared keywords. The agent's final answer paraphrases details from one of the unrelated chunks instead of the relevant warranty passage. Which failure mode best explains this behavior?

    Sources78

    Exam traps

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

    1. 1.Retrieval problems belong to the data pipeline, so re-chunking or re-embedding is always the fix.Why is that wrong?

      Retrieval quality also depends on the RAG chain: query rewriting, how many chunks are retrieved, and re-ranking. Some fixes, such as filter extraction, need changes to both.

      Covered in The agent retrieved, but retrieved the wrong thing

    2. 2.Long-term memory is the right place for an agent's in-conversation history, and deleting a session also wipes what was learned.Why is that wrong?

      Short-term history within an interaction belongs in managed agent sessions. The two stores are independent, so deleting a session doesn't delete memory.

      Covered in The agent forgot: sessions or memory?

    3. 3.When memory is exposed as a tool, the model can pass in whichever actor_id fits the request.Why is that wrong?

      The application sets actor_id from the verified end-user identity. The model must never choose whose memory it reads or writes.

      Covered in The agent forgot: sessions or memory?

    Practise it for real

    Save a user preference to a managed memory store and recall it with a natural-language search, as an agent would at the start of a new conversation.

    1. 1.Make sure you have a memory store named support-agent-memory (creating a store provisions its Lakebase storage automatically), and set DATABRICKS_HOST and DATABRICKS_TOKEN.

      Why: Both calls below address the store by its display name.

      You should see: A workspace-scoped store you can write entries to.

    2. 2.POST to /api/2.0/agents/memory-stores/support-agent-memory/entries with actor_id "user-123", path "/preferences/communication.md", content "Prefers email over phone." and description "Communication preferences".

      Why: actor_id says whose memory it is, path organises it, and description improves retrieval.

      You should see: A new entry, uniquely identified by actor_id, session_id and path.

    3. 3.POST to /api/2.0/agents/memory-stores/support-agent-memory/entries:search with actor_id "user-123" and query "communication preferences".

      Why: This is the recall step that fixes 'the agent forgot between conversations'.

      You should see: The email-preference entry, returned among the most relevant entries for that actor.

    Stuck? Get a nudge

    Search is scoped to an actor. If nothing comes back, check that the actor_id matches the one you saved with.

    Sources

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

    1. 1.
      “This approach is especially valuable for answering questions about proprietary, frequently changing, or domain-specific information.”
      ↩︎ The agent never had the knowledge: add retrieval
      “Up-to-date information: A RAG application can supply the LLM with information from an updated knowledge base.”
      ↩︎ Prediction
    2. 2.
      “This design is good for simple or generic queries but is often disconnected from your real-world business data.”
      ↩︎ The agent never had the knowledge: add retrieval
      “The LLM does not make decisions about which tools to call or in what order.”
      ↩︎ The agent never had the knowledge: add retrieval
      “Augment a prompt by combining the user request with the retrieved context.”
      ↩︎ Checkpoint
    3. 3.
      “When the harness pulls in the wrong information from memory or search systems, the model may confidently generate incorrect answers.”
      ↩︎ The agent retrieved, but retrieved the wrong thing
    4. 4.
      “It's difficult to generate high-quality RAG output if the context provided to the LLM is missing important information or contains superfluous information.”
      ↩︎ The agent retrieved, but retrieved the wrong thing
      “Retrieval quality can be influenced by both the data pipeline”
      ↩︎ Exam trap 1
    5. 5.
      “Filter extraction must be done in conjunction with changes to both metadata extraction data pipeline and retriever chain components.”
      ↩︎ The agent retrieved, but retrieved the wrong thing
      “Scenarios requiring precise keyword matches, ideal for specific term-focused queries such as product names.”
      ↩︎ Checkpoint
    6. 6.
      “verify that relevant columns have Example values and Value dictionaries enabled.”
      ↩︎ The agent retrieved, but retrieved the wrong thing
      “If possible, remove unnecessary or overlapping tables or columns.”
      ↩︎ The agent retrieved, but retrieved the wrong thing
    7. 7.
      “sessions give the agent continuity within a conversation, and memory gives it continuity across conversations.”
      ↩︎ The agent forgot: sessions or memory?
      “deleting a session, or an entire session store, does not delete memory retained in a memory store.”
      ↩︎ Exam trap 2
      “Remember a user's preferences, facts, and decisions across separate conversations”
      ↩︎ Prediction
      “Persist and resume an agent's session state so an interaction survives restarts”
      ↩︎ Checkpoint
    8. 8.
      “For short-term conversation history within a single interaction, use managed agent sessions.”
      ↩︎ The agent forgot: sessions or memory?
      “Set the actor_id in trusted application code from the verified end-user identity.”
      ↩︎ The agent forgot: sessions or memory?
      “Never let the model choose whose memory to read or write.”
      ↩︎ Exam trap 3

    Ready to test yourself?

    Practise Databricks Certified Context Engineer Associate in quiz mode.

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