agentleFS
joelbarmettlerUZHjoelbarmettlerUZH/ultrainit.sh/.claude/skills/debug-agent-failure/SKILL.md

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…

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
  1. Very specific:

    If the file contains null, the agent exited 0 but claude -p returned an empty structured_output.

    line 58
  2. Very specific:

    If loggedIn: false, re-authenticate.

    line 98

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

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

Before You Start

  • lib/agent.sh lines 85-130 — error handling, budget enforcement, stderr capture
  • .ultrainit/state.json — which phases completed (readable with jq . .ultrainit/state.json)
  • .ultrainit/logs/ — one .stderr file per agent
  • .ultrainit/costs/ — one .cost file 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>.stderr

2. Read the stderr log

cat .ultrainit/logs/<name>.stderr

Common error subtypes and what they mean:

ErrorCauseFix
error_max_budget_usdPer-agent budget exhaustedIncrease --budget or delete .ultrainit/costs/*.cost files to reset
error_max_structured_output_retriesSchema validation loop — agent couldn't produce conforming JSONCheck schema for overly strict enums or missing additionalProperties: false
rate_limit_exceededAPI rate limit hitWait and rerun (findings exist for completed agents — only failed ones retry)
authentication_errorClaude auth expiredRun claude auth status and re-authenticate
context_length_exceededPrompt too long for modelCheck 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>.json

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.

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/*.cost

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 budget accounting: rm .ultrainit/costs/<name>.cost.

5. Check phase state

jq . .ultrainit/state.json

Phases 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 status

If loggedIn: false, re-authenticate. lib/config.sh calls this at startup and aborts if not authenticated.

Common Mistakes

  1. Using --force when you only want to retry failures — --force reruns every agent, which costs money. Without --force, only agents with missing findings files are retried.
  2. Budget retries are cumulative — if synthesis retried 3 times and failed, all 3 attempts' costs are in .cost files. Raise --budget or delete specific .cost files before rerunning.
  3. structure-scout failure degrades deep-dive quality silently — if structure-scout fails, run_fallback_module_analyzers() uses a crude directory scan. Check logs/structure-scout.stderr before trusting module findings.
  4. Findings with null content pass silently — run_agent in lib/agent.sh validates with jq empty, but null is valid JSON. Use jq -e . file (exits 1 on null) to catch empty structured output.

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.