agent-debug
Skill1 starsChanged 4 months agoMITView on GitHub
Diagnose why an agent is failing, looping, choosing the wrong tools, hallucinating, overrunning its budget, or dying silently. Use this whenever the user reports an agent misbehaving, pastes an agent trace or error, or says things like "my agent keeps looping", "it calls the wrong tool", "costs are spiking", or "it returns nothing and no error".
1 other project uses a version of this.
Adopted by
Most recently taken up by
- angelgabrieljacintohuayllasco/clipboard-skillstheir own version, first seen Sep 20, 2026
Other versions1 project uses a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 1
- angelgabrieljacintohuayllasco/clipboard-skills★ 0same name
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository6 other files it gives its agents.
- AGENTS.mdAGENTS.md
- CLAUDE.mdCLAUDE.md
- agentic-design-reviewSkill
- agent-scaffoldSkill
- guardrail-setupSkill
- tool-schema-designSkill
The file
We split this skill into the rules it gives an agent
1 rule. About 0 are common, 1 is distinctive, and 0 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈1
Distinctive · estimate
This author's own choices. Worth a look.
0
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 100
Symptoms: No error, but agent returns generic or empty response.
≈ “Common” is an estimate: at least 1 in 5 of the 213,897 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Agent Debug
Systematically diagnose why an agent is failing, looping, producing wrong answers, or exceeding budgets. Follows the production incident playbook.
When to Use
- Agent produces wrong or incomplete answers.
- Agent loops without converging on an answer.
- Agent exceeds cost, token, or time budgets.
- Agent fails silently or returns generic errors.
- Tool calls fail or return unexpected results.
Inputs
Provide as many as available:
- Error description: What's going wrong.
- Agent trace/logs: Step-by-step execution log.
- Agent config: AgentConfig with limits.
- Tool definitions: Schemas of registered tools.
- System prompt: The agent's system prompt.
- Example input: A failing query.
Diagnostic Flowchart
Agent is failing
├── Is it looping? → Check: iteration limits, tool output quality, stop condition
├── Is it exceeding budget? → Check: cost tracking, token counting, timeout
├── Is it calling wrong tools? → Check: tool descriptions, tool count, prompt clarity
├── Is it getting wrong tool results? → Check: tool implementation, input validation
├── Is it hallucinating? → Check: output guardrails, grounding, context window
├── Is it timing out? → Check: tool latency, LLM latency, network issues
├── Is it returning errors? → Check: error handling, circuit breaker, fallback chain
└── Is it silently wrong? → Check: eval dataset, golden trajectories, output validationIncident Playbook
1. Infinite Loop / Excessive Iterations
Symptoms: Agent hits max_iterations, repeats same tool calls, cost spikes.
Root causes and fixes:
| Cause | Signal | Fix |
| Tool returns unhelpful output | Same tool called repeatedly with same args | Improve tool output format and description |
| No stop condition | Agent never produces final_answer | Add explicit "answer the question" instruction after N steps |
| Ambiguous tool descriptions | Agent oscillates between tools | Clarify WHEN to use each tool, add exclusions |
| Context window overflow | Late steps lose early context | Summarize intermediate results, reduce tool output size |
| Missing tool | Agent can't find what it needs | Add the missing tool or clarify which tool handles the case |
2. Wrong Tool Selection
Symptoms: Agent uses run_sql when it should use search_docs, or vice versa.
Root causes and fixes:
| Cause | Signal | Fix |
| Vague tool descriptions | Tool chosen by name alone | Add WHEN/DON'T USE sections to docstring |
| Too many tools | Random selection from 10+ tools | Reduce to 3-7 tools, split into specialized agents |
| Overlapping tools | Two tools seem to do the same thing | Merge or clearly differentiate in descriptions |
| Prompt doesn't guide | System prompt doesn't mention tools | Add tool selection guidance to system prompt |
3. Budget Exceeded
Symptoms: Cost or token limit reached before answer.
Root causes and fixes:
| Cause | Signal | Fix |
| Large tool outputs | Token count spikes after tool calls | Truncate outputs (10K char limit), summarize |
| Too many iterations | Steady cost increase per step | Lower max_iterations, improve per-step quality |
| Expensive model | High cost per call | Use cheaper model for simple steps, reserve expensive for final |
| No caching | Same queries repeated | Add exact/semantic cache |
4. Hallucination / Wrong Answers
Symptoms: Agent returns plausible but incorrect information.
Root causes and fixes:
| Cause | Signal | Fix |
| No grounding check | Answer contradicts tool results | Add output guardrail comparing answer to tool outputs |
| Stale context | Answer uses outdated information | Refresh retrieval, check cache TTL |
| Prompt injection | External content influences behavior | Wrap external content in untrusted markers |
| Missing tool result | Agent answers from parametric knowledge | Force tool use before answering on factual queries |
5. Silent Failures
Symptoms: No error, but agent returns generic or empty response.
Root causes and fixes:
| Cause | Signal | Fix |
| Swallowed exceptions | No error in logs | Add structured error logging, never bare except |
| Missing tracing | Can't see what happened | Add trace events for every LLM and tool call |
| Fallback to empty | Degradation returns nothing useful | Ensure degradation level 5 returns helpful message |
| Circuit breaker stuck | All providers marked failed | Add health check / reset mechanism |
6. Provider Failures
Symptoms: LLM API errors, timeouts, rate limits.
Root causes and fixes:
| Cause | Signal | Fix |
| Rate limiting | 429 errors | Add retry with backoff, request quota increase |
| Provider outage | 5xx errors | Verify circuit breaker + fallback chain active |
| Network issues | Connection timeout | Check DNS, proxy settings, firewall rules |
| Auth expired | 401/403 errors | Rotate API keys, check token expiration |
Debug Checklist
Quick triage — check these first:
- Are iteration/cost/timeout limits set? What are current values?
- Is tracing enabled? Can you see the execution trace?
- What's the last successful step before failure?
- Are tool outputs reasonable? (Check size, format, content.)
- Is the circuit breaker open for any provider?
- Does the eval dataset cover this failure case?
- Has this agent been reviewed with
/agentic-design-review?
Output Format
## Agent Debug Report
**Symptom**: {description}
**Category**: {loop | wrong_tool | budget | hallucination | silent | provider}
**Root Cause**: {identified cause}
**Evidence**: {trace excerpt or log line}
### Fix
{Step-by-step fix with code changes}
### Prevention
{What to add to prevent recurrence: test, alert, guardrail}Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

