When to use it

Use this prompt when an agent run produced a wrong answer, took too long, cost more than expected or got stuck in a loop, and you have a trace of the run from your observability tool. It turns a long list of spans into a short, evidence-based diagnosis you can act on. Our guide to reading OpenTelemetry GenAI traces explains what the spans mean.

How to customize it

  • [GOAL] should be the original user request in one sentence, so the model can judge whether each step moved toward it.
  • [WHAT WENT WRONG] works best as one concrete symptom, such as “answered with last year’s price” rather than “bad output.”
  • [TRACE] can be a span export or plain log lines. Include durations and tool names; include prompts and tool arguments only if they are safe to share, and mask personal data first.
  • Add a line about your stack, such as “tools are Python functions; retries are handled by the framework,” if you want code-level suggestions.

Why it works

Asking for the timeline first forces the model to read the trace before theorizing. Requiring quoted evidence and a confidence level makes weak guesses visible, and the “INFERRED” label separates what the trace shows from what the model assumes. The cheapest-check step keeps the output practical: you learn what to open next rather than receiving a generic list of possible causes. The final step ties debugging to evaluation, so each incident adds a test.

Tips and variations

  • Run it on two traces, one good and one bad, and ask for the first point where they diverge.
  • For cost problems, ask the model to total the time or tokens per span type and rank the largest contributors.
  • Treat the answer as a hypothesis list. Confirm it with the checks the prompt proposes before changing production code.
  • Never paste secrets, customer text or full prompts into a third-party tool unless your policy allows it.