
Agent Introspection Debugging
FreeSystematic self-debugging for AI agent failures.
Free · Opens the source repo
What Agent Introspection Debugging does
Agent Introspection Debugging is a structured workflow skill designed to help AI agents diagnose and recover from failures systematically. It is particularly useful when an agent encounters repeated failures, consumes excessive tokens without making progress, or loops on the same tools. By implementing this skill, agents can learn to capture their failure states, diagnose issues, and apply contained recovery actions before escalating the problem to a human operator. This approach not only enhances the agent's self-sufficiency but also improves the overall efficiency of the debugging process.
The skill operates through a four-phase loop: Failure Capture, Root-Cause Diagnosis, Contained Recovery, and Introspection Report. In the first phase, agents capture essential information about the failure, including error messages, the last successful steps, and environmental assumptions. This data is crucial for understanding the context of the failure. The second phase involves diagnosing the root cause by matching the failure to known patterns, helping to identify whether the issue is related to logic, state, environment, or policy.
Once the diagnosis is established, the skill guides the agent through contained recovery actions, which are the smallest interventions that can address the identified issues without causing further complications. Finally, the introspection report summarizes the failure, root cause, recovery action, and the outcome, providing a clear record for future reference. This structured approach not only aids in resolving current failures but also helps in preventing similar issues in the future.
This skill is ideal for developers and designers working with AI agents who need a reliable method for debugging and improving agent performance. It offers a systematic framework that enhances the agent's ability to self-correct and learn from past mistakes, ultimately leading to more robust and efficient AI systems.
When to use it
Use this skill when an agent is failing repeatedly or consuming resources without making progress.
When not to use it
This skill is not suitable for feature verification after code changes or when a more specific debugging tool is available.
What you can build with it
Repeated Tool Failures
An agent encounters maximum tool call failures and needs to diagnose the looping behavior before retrying.
Context Drift Issues
When the agent's output quality degrades due to context overflow, this skill helps identify and rectify the problem.
Environment State Mismatch
If the agent's expected environment state does not match reality, this skill assists in capturing and diagnosing the discrepancies.
How to install Agent Introspection Debugging
View source1. Install with the skills CLI
npx skills add affaan-m/ecc/agent-introspection-debugging --agent claude-code2. Or install it manually
Download the skill folder and drop it into ~/.claude/skills/ for all projects, or .claude/skills/ to scope it to one repo. Restart Claude Code so it picks up the new skill.
Anthropic's agentic coding CLI, and the reference implementation of Agent Skills. Drop a skill folder into ~/.claude/skills and Claude Code loads it automatically whenever a task matches the skill's description. Claude Code docs
Inside SKILL.md
Written by affaan-mAgent Introspection Debugging
Use this skill when an agent run is failing repeatedly, consuming tokens without progress, looping on the same tools, or drifting away from the intended task.
This is a workflow skill, not a hidden runtime. It teaches the agent to debug itself systematically before escalating to a human.
When to Activate
- Maximum tool call / loop-limit failures
- Repeated retries with no forward progress
- Context growth or prompt drift that starts degrading output quality
- File-system or environment state mismatch between expectation and reality
- Tool failures that are likely recoverable with diagnosis and a smaller corrective action
Scope Boundaries
Activate this skill for:
- capturing failure state before retrying blindly
- diagnosing common agent-specific failure patterns
- applying contained recovery actions
- producing a structured human-readable debug report
Do not use this skill as the primary source for:
- feature verification after code changes; use
verification-loop - framework-specific debugging when a narrower ECC skill already exists
- runtime promises the current harness cannot enforce automatically
Four-Phase Loop
Phase 1: Failure Capture
Before trying to recover, record the failure precisely.
Capture:
- error type, message, and stack trace when available
- last meaningful tool call sequence
- what the agent was trying to do
- current context pressure: repeated prompts, oversized pasted logs, duplicated plans, or runaway notes
- current environment assumptions: cwd, branch, relevant service state, expected files
Minimum capture template:
## Failure Capture
- Session / task:
- Goal in progress:
- Error:
- Last successful step:
- Last failed tool / command:
- Repeated pattern seen:
- Environment assumptions to verify:
Phase 2: Root-Cause Diagnosis
Match the failure to a known pattern before changing anything.
| Pattern | Likely Cause | Check |
|---|---|---|
| Maximum tool calls / repeated same command | loop or no-exit observer path | inspect the last N tool calls for repetition |
| Context overflow / degraded reasoning | unbounded notes, repeated plans, oversized logs | inspect recent context for duplication and low-signal bulk |
ECONNREFUSED / timeout | service unavailable or wrong port | verify service health, URL, and port assumptions |
429 / quota exhaustion | retry storm or missing backoff | count repeated calls and inspect retry spacing |
| file missing after write / stale diff | race, wrong cwd, or branch drift | re-check path, cwd, git status, and actual file existence |
| tests still failing after “fix” | wrong hypothesis | isolate the exact failing test and re-derive the bug |
Diagnosis questions:
- is this a logic failure, state failure, environment failure, or policy failure?
- did the agent lose the real objective and start optimizing the wrong subtask?
- is the failure deterministic or transient?
- what is the smallest reversible action that would validate the diagnosis?
Phase 3: Contained Recovery
Recover with the smallest action that changes the diagnosis surface.
Safe recovery actions:
- stop repeated retries and restate the hypothesis
- trim low-signal context and keep only the active goal, blockers, and evidence
- re-check the actual filesystem / branch / process state
- narrow the task to one failing command, one file, or one test
- switch from speculative reasoning to direct observation
- escalate to a human when the failure is high-risk or externally blocked
Do not claim unsupported auto-healing actions like “reset agent state” or “update harness config” unless you are actually doing them through real tools in the current environment.
Contained recovery checklist:
## Recovery Action
- Diagnosis chosen:
- Smallest action taken:
- Why this is safe:
- What evidence would prove the fix worked:
Phase 4: Introspection Report
End with a report that makes the recovery legible to the next agent or human.
## Agent Self-Debug Report
- Session / task:
- Failure:
- Root cause:
- Recovery action:
- Result: success | partial | blocked
- Token / time burn risk:
- Follow-up needed:
- Preventive change to encode later:
Recovery Heuristics
Prefer these interventions in order:
- Restate the real objective in one sentence.
- Verify the world state instead of trusting memory.
- Shrink the failing scope.
- Run one discriminating check.
- Only then retry.
Bad pattern:
- retrying the same action three times with slightly different wording
Good pattern:
- capture failure
- classify the pattern
- run one direct check
- change the plan only if the check supports it
Integration with ECC
- Use
verification-loopafter recovery if code was changed. - Use
continuous-learning-v2when the failure pattern is worth turning into an instinct or later skill. - Use
councilwhen the issue is not technical failure but decision ambiguity. - Use
workspace-surface-auditif the failure came from conflicting local state or repo drift.
Output Standard
When this skill is active, do not end with “I fixed it” alone.
Always provide:
- the failure pattern
- the root-cause hypothesis
- the recovery action
- the evidence that the situation is now better or still blocked
Frequently asked questions about Agent Introspection Debugging
Similar skills
Skill Creator
Efficiently create and manage skills for Gemini CLI.
Agent Development
Create and manage autonomous agents for Claude Code.
Math Olympiad Solver
Solve and verify competition math problems effectively.
Microsoft Skill Creator
Create specialized skills for Microsoft technologies.
Doublecheck
A verification pipeline for AI-generated claims.
Skill Development for Claude Code
Create and enhance skills for Claude Code plugins.
