agentleFS
iushviushv/agentic-ai-skills/skills/agent-debug/SKILL.md

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

  • Other versions1 project uses a version of this.

    Word for word · 0

    None found.

    Edited · 0

    None found.

    Wrote their own version · 1

    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.

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
  1. Distinctive:

    Symptoms: No error, but agent returns generic or empty response.

    line 100

≈ “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.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

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 validation

Incident Playbook

1. Infinite Loop / Excessive Iterations

Symptoms: Agent hits max_iterations, repeats same tool calls, cost spikes.

Root causes and fixes:

CauseSignalFix
Tool returns unhelpful outputSame tool called repeatedly with same argsImprove tool output format and description
No stop conditionAgent never produces final_answerAdd explicit "answer the question" instruction after N steps
Ambiguous tool descriptionsAgent oscillates between toolsClarify WHEN to use each tool, add exclusions
Context window overflowLate steps lose early contextSummarize intermediate results, reduce tool output size
Missing toolAgent can't find what it needsAdd 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:

CauseSignalFix
Vague tool descriptionsTool chosen by name aloneAdd WHEN/DON'T USE sections to docstring
Too many toolsRandom selection from 10+ toolsReduce to 3-7 tools, split into specialized agents
Overlapping toolsTwo tools seem to do the same thingMerge or clearly differentiate in descriptions
Prompt doesn't guideSystem prompt doesn't mention toolsAdd tool selection guidance to system prompt

3. Budget Exceeded

Symptoms: Cost or token limit reached before answer.

Root causes and fixes:

CauseSignalFix
Large tool outputsToken count spikes after tool callsTruncate outputs (10K char limit), summarize
Too many iterationsSteady cost increase per stepLower max_iterations, improve per-step quality
Expensive modelHigh cost per callUse cheaper model for simple steps, reserve expensive for final
No cachingSame queries repeatedAdd exact/semantic cache

4. Hallucination / Wrong Answers

Symptoms: Agent returns plausible but incorrect information.

Root causes and fixes:

CauseSignalFix
No grounding checkAnswer contradicts tool resultsAdd output guardrail comparing answer to tool outputs
Stale contextAnswer uses outdated informationRefresh retrieval, check cache TTL
Prompt injectionExternal content influences behaviorWrap external content in untrusted markers
Missing tool resultAgent answers from parametric knowledgeForce tool use before answering on factual queries

5. Silent Failures

Symptoms: No error, but agent returns generic or empty response.

Root causes and fixes:

CauseSignalFix
Swallowed exceptionsNo error in logsAdd structured error logging, never bare except
Missing tracingCan't see what happenedAdd trace events for every LLM and tool call
Fallback to emptyDegradation returns nothing usefulEnsure degradation level 5 returns helpful message
Circuit breaker stuckAll providers marked failedAdd health check / reset mechanism

6. Provider Failures

Symptoms: LLM API errors, timeouts, rate limits.

Root causes and fixes:

CauseSignalFix
Rate limiting429 errorsAdd retry with backoff, request quota increase
Provider outage5xx errorsVerify circuit breaker + fallback chain active
Network issuesConnection timeoutCheck DNS, proxy settings, firewall rules
Auth expired401/403 errorsRotate API keys, check token expiration

Debug Checklist

Quick triage — check these first:

  1. Are iteration/cost/timeout limits set? What are current values?
  2. Is tracing enabled? Can you see the execution trace?
  3. What's the last successful step before failure?
  4. Are tool outputs reasonable? (Check size, format, content.)
  5. Is the circuit breaker open for any provider?
  6. Does the eval dataset cover this failure case?
  7. 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}

Download now (ZIP)

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
What did you use it for? e.g. Reviewing pull requests in a Rails app

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.