CertSafari
    Databricks Certified Context Engineer Associate· Lessons

    Domain 6 · Lesson 35/45

    Compaction failures: finding the discarded category

    Given a long running agent task that has been compacted and is now exhibiting downstream coherence failures, identify which category of information was incorrectly discarded during compaction and select the compaction prompt revision that preserves that category without significantly increasing the token cost of the summarized context.

    16 min read
    2.2% of exam
    7 sources
    Published 22 Oct 2026
    Docs as of 17 Oct 2026

    What you will be able to do

    • Recognise a post-compaction coherence failure and tell it apart from a general drop in model quality
    • Map an observed symptom to the category the compaction summary discarded: decisions, constraints, identifiers or task progress
    • Select the compaction prompt revision that keeps the missing category at almost no extra token cost, and reject revisions that only add volume

    Key concept

    Discarded category — When an agent loses coherence right after compaction, the summary has usually dropped one category of information: decisions, constraints, identifiers or task progress. The fix is to name that category in the compaction prompt so the summarizer keeps it in a compact form.

    1.Why coherence breaks right after compaction

    Compaction replaces an agent's growing history with a summary, and the agent carries on from that summary alone. Anything the summary leaves out is gone for the agent. It has no older transcript to look back at, so a fact dropped during compaction is as lost as a fact that was never said.

    A coherence failure after compaction has a recognisable shape. The agent worked correctly for an hour. A compaction event fired. On the next turn, or soon after, the agent contradicts its own earlier work: it repeats finished steps, breaks a rule it had been following, reopens a settled choice, or points at the wrong table. The model has not got worse. Its context has lost one specific kind of information, and the type of failure tells you which kind.

    The fix belongs in the instruction that tells the summarizer what to write. The compaction prompt as the tuning lever is where compaction quality is tuned. For this failure the angle is narrow: when one category was discarded, revise the prompt so it keeps that category. Don't swap compaction for trimming or some other strategy. The strategy worked. The summarizer was just never told that this category mattered.

    Confirm the diagnosis in the trace before you change anything. An MLflow trace of the run shows the spans before the compaction event and the summary that replaced them. Find the user message or tool result that held the missing fact, then check that the summary really says nothing about it. The same trace records token usage, so it also gives you the baseline cost that any revision has to stay close to.

    Checkpoint 1 of 8· Check yourself

    An agent ran correctly for an hour. Then a compaction event fired, and on the next turn the agent started rerunning diagnostics it had already finished. What should you do before changing anything?

    Sources12

    2.Four categories a compaction summary must keep

    Almost every post-compaction coherence failure traces back to one of four categories. Each one does a different job in the agent's next turn, and losing each one produces its own failure:

    • Decisions: choices made during the task, together with the reason for them. For example: "use an incremental MERGE, not a full overwrite, because the table is 4 TB." Lose these and the agent reopens settled questions or switches back and forth between approaches.
    • Constraints: standing rules that limit every later action, usually given by the user. For example: "only write to the dev catalog" or "exclude sales_2019_legacy." Lose these and the agent breaks a rule it had been following.
    • Identifiers: the exact names the work depends on, such as catalog.schema.table names, file paths, job IDs, ticket numbers and endpoint names. Narrative summaries paraphrase them ("the relevant sales tables"), and the agent then guesses.
    • Task progress: a ledger of completed actions with one-line outcomes, plus the steps still open. Lose this and the agent redoes finished work or declares the task done too early.

    A progress ledger is not raw tool output. Before compaction, the history is the ordered transcript of messages, tool calls and results. A ledger entry keeps the outcome of a tool call and drops the payload. "Ran a null count by partition on orders.ship_date; nulls appear only after 2026-09-01" costs one line. The 400-row result behind it costs thousands of tokens, and the agent can run the query again if it needs the rows. A summary that says "the agent investigated several possible causes" keeps neither the action nor the outcome. That is why an agent reruns diagnostics it has already finished.

    Decisions and constraints differ in how long they last. A decision can be revisited when new evidence arrives. A constraint holds until the user lifts it. A user's "don't include the deprecated table" sounds like a one-off choice, but it has to be carried forward as a standing constraint, because it governs every later edit to the table list. Narrative summaries are especially bad at this. They record what was done, and a prohibition leaves no action behind to record. "Configured the Genie space with the relevant sales tables" is accurate about the actions and says nothing about the exclusion, so on the next edit the deprecated table comes back.

    Checkpoint 2 of 8· Check yourself

    After compaction, a summary says only: "The agent investigated several possible causes of the null ship dates." The agent then reruns null-count queries it had already finished. Which revision to the compaction prompt fixes this and still keeps the summary small?

    Sources34

    3.Reading the symptom back to the missing category

    Diagnosis runs backwards, from what the agent did wrong to what it no longer knew. Each symptom points to one category:

    • It repeats a tool call or step it had already finished: task progress was dropped.
    • It does something the user explicitly ruled out, such as writing to prod or re-adding an excluded table: a constraint was dropped.
    • It reopens or reverses a choice made earlier, without any new evidence: a decision, or the reason behind it, was dropped.
    • It uses an approximate or invented name, path or ID: an identifier was dropped.
    • It stops while work remains, or loses track of what is left: the open-tasks part of progress was dropped.

    Wrong answer options usually name a real piece of information that had nothing to do with the failure. A simple test sorts them out: if this item had survived compaction, would it have prevented this exact failure? A collaborator's contact details or a dashboard's colour scheme would not have stopped a write to the production catalog. Only the dev-only rule would have. A pipeline's average runtime doesn't explain a re-added table either.

    A second group of distractors names information the agent can get back on its own. A table's full schema can be looked up with a tool. Row counts are live values that are stale as soon as they are copied. Neither belongs in a summary, and neither explains a lost rule or a repeated query. Databricks' memory pipelines, which distill conversations into durable facts, are built to skip these same two kinds of detail.

    Checkpoint 3 of 8· Check yourself

    Early in a session, a user told an agent to exclude sales_2019_legacy from a Genie space. After a compaction event, the agent adds that table back on its next edit. Which compaction prompt revision fixes this without inflating the summary?

    Checkpoint 4 of 8· Exam question

    A data-engineering agent has been running for over an hour, executing many diagnostic SQL queries against a Delta table to find the source of a null-value bug. A compaction event condenses the growing history into a narrative summary ("agent investigated several possible causes of the null values"). Immediately after, the agent reruns two diagnostic queries it had already executed and already had results for. Which category of information was incorrectly discarded, and which compaction prompt revision fixes this without materially increasing summary length?

    Checkpoint 5 of 8· Exam question

    While configuring a Genie space, an agent is explicitly told by the user to exclude the deprecated table "sales_2019_legacy" from the space. Several turns later, a compaction step summarizes the session as "configured Genie space with the relevant sales tables." On the next turn, the agent adds "sales_2019_legacy" back into the space's table list. Which category of information was incorrectly discarded during compaction?

    Checkpoint 6 of 8· Exam question

    Early in a session, a user tells an agent, "Only write results to the dev catalog, never to prod." Many turns later, after a compaction event summarizes the conversation as "agent has been writing pipeline outputs to Unity Catalog tables," the agent writes its next output directly to a table in the production catalog. Which category of information was incorrectly discarded during compaction?

    Sources4

    4.Revising the prompt to keep a category, not more volume

    The revision that works names the missing category and gives it a bounded form. "Write a more detailed summary" buys tokens across every category and still leaves it to chance whether the one that failed survives. A named field doesn't leave it to chance. Two examples:

    • Constraints: "Under Constraints, list every rule the user stated about what the agent must or must not do, including exclusions, as one short imperative line each. Keep each rule until the user revokes it."
    • Progress: "Under Completed, list each tool call as action → outcome on one line. Under Open, list the steps still remaining."

    A field like this adds a few dozen tokens to a summary of several thousand.

    Databricks' own memory instructions show the same move in a neighbouring setting. Instead of telling the agent to save more, they name what to save: a stable preference, fact, decision or ongoing project the user actually stated or decided. They also ask that each entry stand on its own out of context. That is a good rule for summary fields too. "Never write to prod" works on its own; "as discussed, avoid the other one" does not.

    To choose between candidate revisions, apply three tests in order:

    1. It names the category whose loss matches the symptom.
    2. It adds a bounded structure, such as a list of rules, identifiers or action-and-outcome pairs, rather than open-ended length.
    3. It adds nothing verbatim and nothing re-fetchable: no pasted ticket text, no full schemas, no raw tool output.

    Four kinds of fix fail these tests. A longer summary fails the second test. Restating the original ticket word for word, or re-embedding the schema, fails the third. Switching away from compaction fails the first, because it treats a prompt gap as a strategy problem. The fourth needs more explanation. Aggressive vs conservative compaction is a dial for the whole summary. Turning it toward conservative raises the cost of every compaction to rescue one category, when naming that category would have fixed it on its own.

    A summarization prompt registered as a versioned template in the MLflow Prompt Registry. Its one-line instruction is the vague shape that drops categories, and each revision can be committed as a new version.python
    # Version 1: Basic prompt
    prompt_v1 = mlflow.genai.register_prompt(
        name=PROMPT_NAME,
        template="Summarize this text: {{content}}",
        commit_message="v1: Basic summarization prompt"
    )

    Check the revision on the traces that failed. Run the old and new prompts on the same pre-compaction histories. Confirm the missing rule or ledger now appears in the summary and that the agent's next turn behaves correctly. Then compare the summary's token usage with the baseline. If the summary grew by more than a small field's worth, the revision is asking for volume, not a category.

    Checkpoint 7 of 8· Check yourself

    Your trace confirms the problem. The user said once that the agent may only write to the dev catalog, the summary left that rule out, and after compaction the agent wrote to prod. Which compaction prompt revision should you commit?

    Checkpoint 8 of 8· Fill the gap

    Each revision of the summarization prompt is stored as a new version, so you can test old and new versions on the same failed traces. Which call completes this sample?

    # Version 1: Basic prompt
    prompt_v1 = mlflow.genai. ? (
        name=PROMPT_NAME,
        template="Summarize this text: {{content}}",
        commit_message="v1: Basic summarization prompt"
    )

    Sources567

    Sources

    (7)

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

    1. 1.
      “Tracing records the inputs, outputs, latency, token usage, and cost of every intermediate step”
      ↩︎ Why coherence breaks right after compaction
      “Tracing records the inputs, outputs, latency, token usage, and cost of every intermediate step, mapping the full execution flow”
      ↩︎ Checkpoint
    2. 2.
      “As conversations grow longer, the harness decides what stays active and what gets summarized, a process known as context compaction.”
      ↩︎ Why coherence breaks right after compaction
      “As conversations grow longer, the harness decides what stays active and what gets summarized, a process known as context compaction.”
      ↩︎ Key concept
    3. 3.
      “the ordered transcript of messages, tool calls, and results”
      ↩︎ Four categories a compaction summary must keep
      “the ordered transcript of messages, tool calls, and results”
      ↩︎ Exam trap 3
      “the ordered transcript of messages, tool calls, and results”
      ↩︎ Prediction
    4. 4.
      “Corrections and explicit feedback, such as which source to use for revenue figures.”
      ↩︎ Four categories a compaction summary must keep
      “Details that the agent can look up with its tools, such as a table's schema.”
      ↩︎ Reading the symptom back to the missing category
      “Values from live sources that change over time, such as a table's current row count.”
      ↩︎ Reading the symptom back to the missing category
      “Details that the agent can look up with its tools, such as a table's schema.”
      ↩︎ Exam trap 2
      “Corrections and explicit feedback, such as which source to use for revenue figures.”
      ↩︎ Exam trap 4
    5. 5.
      “a stable preference, fact, decision, or ongoing project the user actually stated or decided”
      ↩︎ Revising the prompt to keep a category, not more volume
      “Write each memory so it stands on its own out of context”
      ↩︎ Revising the prompt to keep a category, not more volume
      “a stable preference, fact, decision, or ongoing project the user actually stated or decided”
      ↩︎ Exam trap 1
    6. 6.
    7. 7.
      “The total token usage throughout the trace is available in the token_usage field of the trace info object.”
      ↩︎ Revising the prompt to keep a category, not more volume

    Ready to test yourself?

    Practise Databricks Certified Context Engineer Associate in quiz mode.

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