Skill
Complex Failure Diagnosis
Finding where a failure started: model, harness, tools, or data
A production failure in a Claude system has four possible origins: the model output, the agent harness (your loop, message assembly, parsing, retries), the tools, and the data (retrieved documents, tool payloads, indexes). The symptom usually appears far from the origin. Your job is to find the first step that differs from a healthy run, then name the layer that owns that step.
Read the trace forwards, not backwards
Agents keep state across many tool calls, so one bad step sends the rest of the run down a different path. Anthropic's write-up of its research system notes that one step failing can cause agents to explore entirely different trajectories. Start at the top of the trace and stop at the first divergence. A wrong final answer at step 45 that follows from a timed-out lookup at step 6 is a step 6 problem.
Stop reasons are evidence, not errors
A stop reason comes back on a successful response. An error is a 4xx or 5xx status. Mixing them up sends you to the wrong layer.
| What you see | Likely origin | What to check |
|---|
Two or three output tokens, end_turn, right after tool results | Harness | Text blocks added after tool_result blocks, or a finished turn sent back unchanged |
max_tokens with a tool call that will not parse | Harness config | The output cap. Retry with a higher value |
HTTP 200, empty content, refusal | Safety classifier | stop_details category |
| Tool input checks fail only after a model change | Harness | Raw string matching on serialized JSON. Parse it instead |
| Agent declines to follow text inside a tool result | Harness or tool design | Your own instructions placed inside the tool result |
Refusals are their own failure class
A refusal is a normal HTTP 200 response. Retrying the same request on the same model treats it like a transient fault and will not help. The documented route is to read the category and retry on another Claude model, in the API or in your client. One category is the exception: when the refusal is about reproducing internal reasoning in the output, there is no recommended fallback model and you change the prompt. Look for a reasoning or scratchpad field in the output format, the system prompt, a skill, or a tool description. A refusal can also arrive mid-stream. Discard the partial output; do not store it as an answer.
Non-deterministic and multi-agent failures
The same input can pass on one run and fail on the next. One passing rerun proves nothing about a failure that happens one time in fifteen. Run the case many times, compare the failure rate before and after a change, and read the transcripts of the runs that still fail. For multi-agent systems, check the messages between agents. A small change to the lead agent can change how subagents behave even when their own prompts are untouched, and vague task descriptions cause duplicated work and gaps. If you cannot see why agents fail, add tracing of queries, sources, and tool errors before you change prompts.
Retrieval-grounding failures: find the stage
- Was the right passage in the index? If the current document was never ingested, the model can answer faithfully from a stale one. That is a data problem.
- Was it retrieved? Embeddings can miss exact matches such as part numbers and error codes. Lexical search (BM25) alongside embeddings addresses that.
- Was it used? If the passage was retrieved and the answer still contains claims found in no passage, the fault is in generation. Restrict the model to the provided documents, require a supporting quote for each claim, and allow it to say it does not know.
A citation with a valid pointer shows which passage the answer used. It does not show that the passage is current or correct. An answer can be perfectly grounded in the wrong document.
Do not start with the model. A pinned model ID keeps the same weights, so when one input class fails after a change on your side, look at the harness, tools, and data first. Serving infrastructure can change behaviour slightly without a new model ID, which is a reason to keep request IDs and dated evidence, not a reason to skip your own layers.
Sources
Stop reasons and fallback
Refusals and fallback
Troubleshooting tool use
Handle tool calls
Reduce hallucinations
Citations
Model IDs and versioning
How we built our multi-agent research system
Introducing Contextual Retrieval
Skill
Incident Response and Learning Loops
Running the incident and turning it into tests, monitors, and findings
An incident in an LLM system is often a quality regression, not an outage. Error rates stay flat while answers get worse. The response still follows the same order: limit the harm, coordinate, tell people, then learn.
Mitigate before you diagnose
The SRE book puts the priority in one line: stop the bleeding, restore service, and preserve the evidence for root-causing. In a major incident the instinct is to hunt for the root cause. Resist it. Make the system work as well as it can first.
- Pick the mitigation the evidence supports. Line the start of the regression up against the change log. Recent changes are a productive place to start, including changes labelled routine. If the regression is confined to one cohort (a region, a prompt version, a proxy pool), revert the change that defines that cohort.
- Check that rollback will help. If a holdback slice on the old version shows the same regression, your change is not the cause and rolling it back only adds churn.
- Use the smallest blast radius. If one write tool is causing harm, disable that tool or put it behind approval. Taking the whole assistant offline punishes the traffic that is healthy.
- Prefer deterministic controls for harmful actions. A new prompt line asking the agent not to repeat a refund is a request, not a control.
- Keep the traces. Save failing examples and request IDs before a rollback changes the picture. You need them for diagnosis and for support.
Coordinate
Declare early. It is better to declare an incident and close it after a simple fix than to assemble a response hours into a growing problem. A slow rise in thumbs-down rate with two teams investigating separately is already an incident.
Separate the roles: an incident commander who holds the overall state, an operations lead whose team is the only group changing production, and a communications lead. Uncoordinated changes are the classic failure. If three engineers each adjust the prompt, the retrieval settings, and a sampling parameter, nobody can tell which change moved the metric.
Communicate
Send periodic updates that state what is known: user impact and scope, the mitigation under way, and when the next update will come. Do not present a suspected cause as confirmed, do not name individuals, and do not paste customer conversations into a broad update.
Convert the incident into regression evaluations
- Use the real failures. Converting user-reported failures into test cases keeps the suite tied to actual usage. De-identify them where the domain requires it.
- Grade the outcome. Check the resulting state, such as the calendar record or the database row, and not only what the agent said it did.
- Run several trials. Outputs vary between runs. A regression suite should pass close to 100% of the time, so a drop means something broke.
- Test both directions. If the incident was a missed escalation, add cases where escalation is wrong as well. One-sided evals create one-sided optimization.
- Distrust a 0% pass rate. It is most often a broken task or grader. Read the transcripts before you touch the agent.
Close the monitoring gap
Ask how the incident was found. A customer email after six days is a monitoring failure, and that alone justifies a postmortem. If the fault existed only in production configuration, more offline cases will not catch it next time. Anthropic's own postmortem of three infrastructure bugs commits to running quality evaluations continuously on true production systems, and names the lack of a clear way to connect user reports to recent changes as a gap.
Write a blameless postmortem
The document records impact, mitigation, root causes, and follow-up actions. Focus on contributing causes without indicting a person or team. You cannot fix people, but you can fix the systems and processes around them. Good action items fall into three groups: prevent recurrence, detect sooner, and mitigate faster. Each needs an owner. A postmortem that is never reviewed might as well not exist.
Writing that the engineer skipped the evals stops the analysis one step too early. Ask why the deploy path allowed a prompt change to reach production without them.
Reaching for a forward fix because the cause seems obvious. An untested fix shipped during an incident is a second change stacked on the first. If a known-good version is minutes away, go back to it and test the fix offline.
Sources
Managing Incidents (Google SRE book)
Postmortem Culture: Learning from Failure (Google SRE book)
Effective Troubleshooting (Google SRE book)
A postmortem of three recent issues
Demystifying evals for AI agents
Claude API errors