debug-agent-failure
Skill8 starsChanged 7 months agoApache-2.0View on GitHub
From terminal output, note the agent name (e.g., patterns, git-forensics). The error message format is: Common error subtypes and what they mean: If the file contains null, the agent exited 0 but claude -p returned an empty structured_output. This usually means the schema had no matching fields. Budget check is optimistic under parallelism — all agents in a batch check before any write costs. Spend can exceed TOTAL_BUDGET by up to N × per-agent share. To reset an individual agent's…
In this repository22 other files it gives its agents.
- CLAUDE.mdCLAUDE.md
- .github/workflows/CLAUDE.mdCLAUDE.md
- lib/CLAUDE.mdCLAUDE.md
- prompts/CLAUDE.mdCLAUDE.md
- schemas/CLAUDE.mdCLAUDE.md
- scripts/CLAUDE.mdCLAUDE.md
- tests/CLAUDE.mdCLAUDE.md
- add-bats-testSkill
- add-edge-testSkill
- add-gather-agentSkill
- add-integration-testSkill
- add-synthesis-fixtureSkill
- audit-prompt-schema-syncSkill
- bundle-and-verifySkill
- check-ci-locallySkill
- fixture-syncSkill
- pre-pr-checklistSkill
- rebuild-test-imageSkill
- release-ultrainitSkill
- run-testsSkill
- tune-synthesis-contextSkill
- validate-generated-artifactSkill
The file
We split this skill into the rules it gives an agent
2 rules. About 0 are common, 0 are distinctive, and 2 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈0
Distinctive · estimate
This author's own choices. Worth a look.
2
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 58
If the file contains null, the agent exited 0 but claude -p returned an empty structured_output.
- Very specific: line 98
If loggedIn: false, re-authenticate.
≈ “Common” is an estimate: at least 1 in 5 of the 372,429 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
Before You Start
lib/agent.shlines 85-130 — error handling, budget enforcement, stderr capture.ultrainit/state.json— which phases completed (readable withjq . .ultrainit/state.json).ultrainit/logs/— one.stderrfile per agent.ultrainit/costs/— one.costfile per agent, format:phase|agent|cost_usd.ultrainit/findings/— structured JSON output from each agent
Diagnosis Steps
1. Identify the failed agent
From terminal output, note the agent name (e.g., patterns, git-forensics). The error message format is:
[ERROR] Agent <name> failed (exit <N>). See .ultrainit/logs/<name>.stderr2. Read the stderr log
cat .ultrainit/logs/<name>.stderrCommon error subtypes and what they mean:
| Error | Cause | Fix |
error_max_budget_usd | Per-agent budget exhausted | Increase --budget or delete .ultrainit/costs/*.cost files to reset |
error_max_structured_output_retries | Schema validation loop — agent couldn't produce conforming JSON | Check schema for overly strict enums or missing additionalProperties: false |
rate_limit_exceeded | API rate limit hit | Wait and rerun (findings exist for completed agents — only failed ones retry) |
authentication_error | Claude auth expired | Run claude auth status and re-authenticate |
context_length_exceeded | Prompt too long for model | Check prompt size; use --skip-research to reduce context |
3. Check the findings file
# Does it exist?
ls -la .ultrainit/findings/<name>.json
# Is it valid JSON?
jq empty .ultrainit/findings/<name>.json && echo "valid" || echo "INVALID"
# Check for null content (empty structured output)
jq -r 'if . == null then "NULL OUTPUT" else "ok" end' .ultrainit/findings/<name>.jsonIf the file contains null, the agent exited 0 but claude -p returned an empty structured_output. This usually means the schema had no matching fields.
4. Check budget spend
# Show individual agent costs
for f in .ultrainit/costs/*.cost; do
echo "$f:"; cat "$f"
done
# Sum total spend
awk -F'|' '{ sum += $3 } END { print sum }' .ultrainit/costs/*.costBudget check is optimistic under parallelism — all agents in a batch check before any write costs. Spend can exceed TOTAL_BUDGET by up to N × per-agent share. To reset an individual agent's budget accounting: rm .ultrainit/costs/<name>.cost.
5. Check phase state
jq . .ultrainit/state.jsonPhases marked complete are skipped on rerun. If you want to re-run just one agent without re-running the whole phase: rm .ultrainit/findings/<name>.json then rerun.
6. Re-run with verbose output
./ultrainit.sh --force --verbose /path/to/project--verbose pipes agent stderr to the terminal in real time. --force re-runs all agents even if findings exist.
To re-run only the failed agents (preserving completed ones), do NOT use --force. Just rerun without flags — run_agent skips existing findings automatically.
7. Check authentication
claude auth statusIf loggedIn: false, re-authenticate. lib/config.sh calls this at startup and aborts if not authenticated.
Common Mistakes
- Using
--forcewhen you only want to retry failures —--forcereruns every agent, which costs money. Without--force, only agents with missing findings files are retried. - Budget retries are cumulative — if synthesis retried 3 times and failed, all 3 attempts' costs are in
.costfiles. Raise--budgetor delete specific.costfiles before rerunning. structure-scoutfailure degrades deep-dive quality silently — ifstructure-scoutfails,run_fallback_module_analyzers()uses a crude directory scan. Checklogs/structure-scout.stderrbefore trusting module findings.- Findings with
nullcontent pass silently —run_agentinlib/agent.shvalidates withjq empty, butnullis valid JSON. Usejq -e . file(exits 1 on null) to catch empty structured output.
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.

