# Agent Failure Post-Mortem Analyzer

Analyzes a transcript or log of an AI agent that failed, went off-track, or produced a bad output, and identifies the root cause with a specific prompt or logic fix.

## Prompt

You are an AI systems debugger who specializes in diagnosing why agents fail or behave unexpectedly.

Agent's system prompt (or relevant excerpt): {{system_prompt_excerpt}}
Transcript/log of the failed run: {{failure_transcript_or_log}}
What the agent was supposed to do: {{intended_behavior}}
What actually happened: {{actual_behavior}}

Do the following:
1. Pinpoint the exact step in the transcript where the agent's behavior first diverged from what was intended (not just where the failure became obvious, but where it actually started going wrong).
2. Classify the root cause into one of these categories: ambiguous instructions, missing context/information the agent needed, a tool call error or misuse, the agent misunderstanding the user's actual intent, a looping/repetition failure, or the agent correctly following instructions that were themselves flawed.
3. Explain the root cause in plain terms, quoting or referencing the specific transcript moment that supports the diagnosis.
4. Propose a specific, concrete fix: either an exact edit to the system prompt, a suggested tool/logic change, or an added guardrail, and explain how it would have prevented this specific failure.

## Best for

Developers debugging AI agents in production or during testing who need a structured root-cause analysis instead of guessing why an agent went off the rails.

## Compatible tools

- Claude
- ChatGPT

## How to use

- Paste the relevant system prompt and the full transcript or log of the failed agent run.
- Describe clearly what the agent was supposed to do versus what it actually did.
- Apply the proposed fix directly to your system prompt or agent logic.
- Re-run a similar scenario after the fix to confirm the specific failure mode has been resolved.

## Customization tips

- If the failure involved a specific tool call, include the raw tool call and its response in the transcript for a more precise diagnosis.
- For recurring failure patterns across multiple runs, paste 2-3 transcripts at once and ask for a shared root cause across all of them.
- If you suspect the issue is a flawed underlying instruction rather than an agent error, say so explicitly to guide the classification.

## Example input

System prompt excerpt: 'Search the web for relevant pricing data and summarize findings.' Transcript: [agent searches once, gets a thin result, then fabricates additional pricing figures not found in the search results]. Intended behavior: Only report verified pricing data. Actual behavior: Agent invented plausible-sounding numbers.

## Example output

A diagnosis pinpointing the divergence at the moment the agent received a thin search result and continued generating content instead of stopping or searching again, classified as 'missing context/information the agent needed' combined with an instruction gap around what to do when search results are insufficient, and a specific fix adding an explicit line to the system prompt instructing the agent to state 'insufficient data found' rather than fabricate when search results don't fully answer the query.
