CertSafari
    Databricks Certified Context Engineer Associate· Lessons

    Domain 2 · Lesson 10/45

    Revising a Miscalibrated Agent System Prompt

    Given a miscalibrated Databricks agent system prompt and its observed failure pattern, select the targeted revision strategy that resolves the failure with the least increase in token cost and maintenance burden.

    15 min read
    2.25% of exam
    12 sources
    Published 3 Oct 2026
    Docs as of 30 Sep 2026

    What you will be able to do

    • Use traces and evaluation results to identify the failure pattern behind a miscalibrated agent before editing its system prompt
    • Rank candidate revisions, from a one-line instruction fix to splitting the work into multiple LLM calls, by how much they add to token cost and maintenance burden
    • Choose the smallest revision that fixes the observed failure, then confirm it with versioned prompts and a consistent evaluation set

    Key concept

    Targeted revision — A change to an agent's system prompt aimed at one failure pattern you have observed, sized to fix that failure and nothing more. You don't rewrite the prompt. The best revision is the one that fixes the failure while adding the fewest tokens to every request and the least text for someone to maintain later.

    1.Start from the failure pattern, not the prompt

    On the exam, questions in this subdomain give you two things: a system prompt and a description of how the agent misbehaves. For example, it ignores a formatting rule, answers questions outside its scope, refuses things it should handle, or follows an instruction too literally. Before choosing a fix, decide what kind of failure this is. Databricks splits quality problems for retrieval-backed agents into two kinds. Retrieval quality asks whether the right context reached the model. Generation quality asks whether the model used that context well. The docs describe generation problems as ones that show up as hallucinations, inconsistent output, or answers that miss the user's question.

    The difference matters because only one of these is a system prompt problem. If the trace shows the retriever returned the wrong chunks, no wording change will fix the answer. Adding instructions just makes every request more expensive and leaves the real problem in place. MLflow traces let you open a failing request and look at each step's inputs and outputs, so you can find the step where things went wrong before you touch any text. Your first job is to confirm that the prompt really is the problem.

    Once the prompt is the culprit, the revision should match the symptom. The Databricks evaluate-and-improve tutorial shows one example. Its improved sales-email prompt adds a line saying to follow the user's instructions exactly, tells the model to use customer context only where it is relevant, and tells it to reference customer information only if it is directly relevant to the instructions. That is a small, symptom-specific edit for an agent that ignored instructions and padded its output. The sources do not give a fix for each symptom, so treat the following as a reasoning heuristic. For scope creep or padding, add or tighten one relevance guideline. For over-literal compliance or over-refusal, look first for the one existing instruction that is over-weighted or ambiguous and reword it, rather than adding more rules on top.

    The same logic applies when the agent is a Genie agent, where the equivalent of a prompt is its configuration. Databricks says table and column descriptions and synonyms help Genie choose the right column and write more accurate SQL. It says instructions that dictate which tables or columns to use are really the job of descriptions and synonyms. If Genie confuses two similar columns, such as a gross and a net revenue field, the targeted fix is a clearer column description or a synonym, not a new text instruction. The docs also describe prompt matching, which helps Genie match values in a user's question and correct spelling. For a mismatch between how users phrase a value and how it is stored, check prompt matching and example SQL before adding rules. Databricks says to use text instructions only as a last resort, and to put hardcoded-value logic in the data layer or in an example query. A data-layer change such as removing a table is a different lever from a targeted configuration fix, and the docs reserve it for universal rules.

    Checkpoint 1 of 8· Check yourself

    A RAG agent gives confident but wrong answers. Its trace shows the retrieval span returned chunks unrelated to the question. What is the most appropriate first step?

    Checkpoint 2 of 8· Exam question

    A Genie space consistently queries the deprecated table "marketing_v1" instead of the current "marketing_v2" when users ask about marketing performance, because the agent selects tables by name similarity rather than purpose. Which revision resolves this with the least added token cost and maintenance burden?

    Sources12345

    2.A ladder of revisions, cheapest first

    The Databricks evaluate-and-improve tutorial lists common improvement strategies. Prompt engineering covers refining the system prompt for a specific failure, adding explicit guidelines for edge cases, and including examples. Guardrails means validation steps and post-processing in application logic. Reasoning enhancements include breaking a complex task into multiple spans or adding verification steps. The docs list these strategies but do not rank them by cost. The ordering below is this lesson's own rule of thumb: roughly, prefer changes that add the fewest tokens per request and the fewest new parts to maintain. Guardrails break the pattern, because they add code to maintain but little prompt growth. The useful skill is matching the failure to the cheapest strategy that actually fixes it.

    Revision strategies in a rule-of-thumb order from smallest to largest added cost (the lesson's heuristic, not a documented ranking), with the failure pattern each one fits
    Observed failure patternTargeted revisionAdded token / maintenance cost
    One instruction is vague, over-weighted, or contradicts anotherReword or remove the offending instructionNear zero; the prompt may even get shorter
    Correct in general, wrong on one specific edge caseAdd one explicit guideline for that edge caseA sentence per request; one rule to maintain
    Instruction is understood but output format or style driftsInclude an example demonstrating correct handlingTypically larger: example tokens on every request
    Output must never violate a hard rule, whatever the wordingGuardrail: validation or post-processing in application logicCode to maintain; little or no prompt growth
    One prompt is juggling several complex logic stepsReasoning enhancement: break the task into multiple spans or callsUsually highest: extra LLM calls and added latency

    Pay attention to the guardrail row. If a rule must hold on every response (a forbidden output, a required field), restating it in the prompt over and over gives no guarantee and costs tokens each time. A deterministic check in code can be the cheaper and more reliable fix, even though it adds code to maintain. The tutorial describes guardrails as validation in application logic and post-processing before the output reaches users.

    Genie agents have their own version of this ladder. Databricks recommends prioritizing SQL expressions and example SQL over text instructions, and describes text instructions as the last resort. Column descriptions and synonyms sit at the cheap end because they are scoped to the agent and shape how Genie picks columns. A complete example query suits a hard, multi-part question. A plain-text instruction is for global context that fits nowhere else, such as a fiscal-year rule or a formatting rule. Choosing the right lever keeps the instruction set small, and Databricks warns that too many instructions can reduce effectiveness.

    Checkpoint 3 of 8· Match them up

    Match each observed failure to the revision strategy that targets it most directly

    Tap a term, then the definition that fits it.

    Checkpoint 4 of 8· Exam question

    Users asking about "revenue" get totals from the gross_revenue column, but they actually mean net_revenue after returns, so reported figures are consistently too high. What is the most targeted way to revise the agent's configuration to fix this?

    Sources34

    3.Weighing token cost against maintenance burden

    Every system prompt token is sent with every request, so a revision that adds a paragraph adds to the cost of the whole workload, not just the failing cases. Databricks treats this as something you measure. Overall latency and token consumption are metrics you compute alongside quality, so you can compare the token count of a proposed revision with the current version before you accept it. Genie agents make the same point: their text instructions and metadata are converted into tokens, and Databricks suggests streamlining descriptions, pruning redundant example queries, and simplifying instructions to cut the count.

    Maintenance burden is the other cost. Every added rule is something a future editor has to understand, keep consistent with the other rules, and re-check when requirements change. Databricks' Genie guidance says to avoid conflicting instructions and to keep consistency across all instruction types, and warns that too many instructions can reduce effectiveness. Splitting work into multiple LLM calls is at the top of the ladder for a reason. The Databricks RAG cookbook says decomposition can improve results but notes that it adds latency in exchange for finer control. Databricks agent design guidance points the same way: start simple and add complexity only when you truly need it.

    Checkpoint 5 of 8· Check yourself

    Two revisions fix the same failure equally well on the evaluation set. Revision A rewords one existing instruction. Revision B adds a 300-token section of new rules. Which should you choose, and why?

    Sources6789410

    4.Verify the revision and keep it reversible

    A targeted revision only counts once you have shown it works. The MLflow Prompt Registry stores prompts as versioned artifacts in Unity Catalog, with commit messages, aliases, and rollback. Registering each revision as a new version, with a commit message explaining which failure it targets, keeps maintenance manageable. A later editor can see why each rule exists and can roll back a revision that caused a regression.

    Registering a prompt version with a commit message, then pointing a production alias at itpython
    # Register a prompt template
    prompt = mlflow.genai.register_prompt(
        name="docs.default.customer_support",
        template="You are a helpful assistant. Answer this question: {{question}}",
        commit_message="Initial customer support prompt"
    )
    print(f"Created version {prompt.version}")  # "Created version 1"
    
    # Set a production alias
    mlflow.genai.set_prompt_alias(
        name="docs.default.customer_support",
        alias="production",
        version=1
    )

    Checkpoint 6 of 8· Fill the gap

    You want a later maintainer to see which failure this prompt version was meant to fix. Which parameter records that reason?

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

    Run the old and new versions against the same evaluation dataset, and include the failing cases that prompted the revision as well as cases that already worked. That shows two things: the target failure is fixed, and the change did not break behavior that was correct before. If the evaluation also records token counts, you can see in one comparison whether the revision paid for itself.

    Checkpoint 7 of 8· Check yourself

    You have revised a system prompt to fix a scope-creep failure. How should you compare it with the previous version?

    Checkpoint 8 of 8· Exam question

    When a user asks about sales in "Australia," a Genie agent's query returns zero rows because the region column stores three-letter codes like "AUS" rather than full country names. Which revision most directly and cheaply fixes this failure?

    Sources1112

    Exam traps

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

    1. 1.Rewriting the whole system prompt into a comprehensive guideline list is the safest way to fix one observed failure.Why is that wrong?

      Databricks recommends targeted changes driven by evaluation results. A full rewrite adds tokens to every request, adds more for someone to maintain, and can introduce new failures in behavior that already worked.

      Covered in A ladder of revisions, cheapest first

    2. 2.Any wrong answer from an agent means the system prompt needs more instructions.Why is that wrong?

      Bad responses can come from faulty retrieval even when generation is fine. Check the trace first; a prompt edit cannot supply context that was never retrieved.

      Covered in Start from the failure pattern, not the prompt

    3. 3.Splitting one prompt into several chained LLM calls is a low-cost fix for any instruction-following problem.Why is that wrong?

      Decomposition can improve control, but it adds LLM calls and latency. Use it when one prompt really is carrying too much logic, not as a first response to a single misworded instruction.

      Covered in Weighing token cost against maintenance burden

    Sources

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

    1. 1.
      “Issues here can manifest as hallucinations, inconsistent output, or failure to directly address the user query.”
      ↩︎ Start from the failure pattern, not the prompt
    2. 2.
      “Investigate failing traces, find errors, examine span trees, pinpoint root causes”
      ↩︎ Start from the failure pattern, not the prompt
    3. 3.
      “Only reference customer information if it's directly relevant to the user's instructions”
      ↩︎ Start from the failure pattern, not the prompt
      “Refine system prompts to address specific failure patterns, add explicit guidelines for edge cases, include examples demonstrating correct handling”
      ↩︎ A ladder of revisions, cheapest first
      “Reasoning enhancements: Break complex tasks into multiple spans, implement chain-of-thought techniques, or add verification steps for critical outputs.”
      ↩︎ A ladder of revisions, cheapest first
      “When creating an improved version, focus on targeted changes based on evaluation results.”
      ↩︎ Key concept
      “When creating an improved version, focus on targeted changes based on evaluation results.”
      ↩︎ Exam trap 1
      “Guardrails: Implement validation steps in application logic and add post-processing to check outputs before presenting to users.”
      ↩︎ Checkpoint
    4. 4.
      “Quality column descriptions and synonyms help Genie understand the column better, choose it for relevant questions, and write more accurate SQL.”
      ↩︎ Start from the failure pattern, not the prompt
      “Prompt matching allows Genie to match values that are most relevant to the user's question and correct spelling issues in user prompts.”
      ↩︎ Start from the failure pattern, not the prompt
      “Use text instructions only as a last resort”
      ↩︎ A ladder of revisions, cheapest first
      “Avoid conflicting instructions: Ensure consistency across all instruction types.”
      ↩︎ Weighing token cost against maintenance burden
    5. 5.
      “Dictate which tables or columns to use. This is the job of Table/Field Descriptions and Synonyms.”
      ↩︎ Start from the failure pattern, not the prompt
      “Hardcode specific values. This logic belongs in the data layer or in a specific Example Query.”
      ↩︎ Start from the failure pattern, not the prompt
    6. 6.
      “Overall latency and token consumption are examples of chain performance metrics.”
      ↩︎ Weighing token cost against maintenance burden
      “A RAG application can respond poorly despite retrieving the correct context; it can also provide good responses based on faulty retrievals.”
      ↩︎ Exam trap 2
      “A RAG application can respond poorly despite retrieving the correct context; it can also provide good responses based on faulty retrievals.”
      ↩︎ Checkpoint
    7. 7.
      “Although this approach may add some latency to the overall process, it can allow for more fine-grained control”
      ↩︎ Weighing token cost against maintenance burden
      “Although this approach may add some latency to the overall process, it can allow for more fine-grained control”
      ↩︎ Exam trap 3
    8. 10.
      “Simplify instructions: Verify that your instructions are clear and concise. Avoid unnecessary words.”
      ↩︎ Weighing token cost against maintenance burden
    9. 11.
      “Version and track prompts with Git-like versioning, commit messages, and rollback capabilities”
      ↩︎ Verify the revision and keep it reversible
    10. 12.
      “Document changes: Use meaningful commit messages to track why changes were made.”
      ↩︎ Verify the revision and keep it reversible
      “Use consistent datasets: Evaluate all versions against the same data for fair comparison.”
      ↩︎ Checkpoint

    Ready to test yourself?

    Practise Databricks Certified Context Engineer Associate in quiz mode.

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