A failed agent run leaves a log of prompts, tool calls and results. Reading it from the start finds the first step that went wrong, which is usually the cause of everything after it. Replay the run in your head from the log, then fix that one step.
Checked on 2026-11-29. We did not run any tool for this guide. Every result below is an expected result, marked UNTESTED, for you to confirm on your own files.
Prerequisites
- The run log with prompts, tool calls and results
- The task the run was meant to do
- The tool schemas for the tools it called
Steps
1. Open the log from the start
Read the log from the first step, not from the error at the end.
Expected result: The log is open from the first step.
2. Mark each step right or wrong
For each step, mark whether the tool and its arguments were right for the task.
Expected result: Each step is marked right or wrong, in order.
3. Find the first wrong step
The first wrong step is the likely cause. Later errors often follow from it.
Expected result: The first wrong step is named, with what it should have been.
4. Fix that step and rerun
Fix the prompt, schema or tool for that step, then rerun the task and check the log again.
Expected result: A fix is made and the rerun is checked against the same log steps.
Worked example
A practice run failed at step 4 of 6. The log showed step 2 called the wrong tool.
| Step | Tool called | Right? |
|---|---|---|
| Step 1 | search_orders | Yes |
| Step 2 | delete_note | No |
| Step 3 | create_ticket | No |
| Step 4 | send_email | No |
Expected result: Step 1 is right and step 2 is the first wrong step, so the fix targets the tool choice at step 2 (UNTESTED – confirm it yourself.)
Verdict table
| Check | Expected result | Pass? |
|---|---|---|
| Open the log from the start | The log is open from the first step. | – |
| Mark each step right or wrong | Each step is marked right or wrong, in order. | – |
| Find the first wrong step | The first wrong step is named, with what it should have been. | – |
| Fix that step and rerun | A fix is made and the rerun is checked against the same log steps. | – |
Limits
- A log may not show what the model was thinking, only what it did; the cause can still be a vague prompt.
- Some logs truncate long tool results, so the missing piece may be in the full result.
Sources
- Model Context Protocol (Stanford CS329T slides) – checked 2026-11-29
- The Model Context Protocol (MCP) for compliance data – checked 2026-11-29
- What is the Model Context Protocol (MCP)? – checked 2026-11-29
- Ollama v0.9.1 release notes – checked 2026-11-29
