Skip to content
Back to skills

Subagent Report Recovery

ASecurity

Recover a background subagent's full report when its completion notification or final message is empty or a one-liner ("Done.", "Complete.", "Standing by."). Use when a Claude Code Agent-tool task finishes with a high token count and many tool uses but the result text is missing the actual report, when the task's output file is 0 bytes, or when re-asking the agent with SendMessage also returns one-liners.

  • 9 stars
  • 0 votes
  • 0 copies
  • 0 views
  • Added November 14, 2026
ai-agentspython

Works with

  • claude code

Security analysis

A100/100

Scanned November 14, 2026

npx -y skills add ychampion/ystack --skill subagent-report-recovery --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Subagent Report Recovery?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Subagent Report Recovery
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/ychampion-subagent-report-recovery/badge)](https://www.skillsdirectory.com/skills/ychampion-subagent-report-recovery)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: subagent-report-recovery
description: >-
  Recover a background subagent's full report when its completion notification or final message is
  empty or a one-liner ("Done.", "Complete.", "Standing by."). Use when a Claude Code Agent-tool task
  finishes with a high token count and many tool uses but the result text is missing the actual report,
  when the task's output file is 0 bytes, or when re-asking the agent with SendMessage also returns
  one-liners.
---

# Recovering reports from subagent transcripts

Claude Code specific: it reads the transcripts Claude Code writes for subagents. Other harnesses keep
their own session logs; the same idea (find the longest assistant text block) applies if you can
locate them.

## When this applies

- A background agent (Agent tool, `run_in_background: true`) completes with a useless result like
  "Done." or "No action pending.", but it clearly did the work (high token count, many tool uses).
- Re-prompting it with SendMessage returns another one-liner: the resumed agent has lost the thread or
  believes it already delivered.
- The `output_file` named in the task notification is **0 bytes**. This has been seen on Windows,
  where the tasks directory sits under `%TEMP%\claude\...\tasks\`.

## When it does not apply

- The result text contains the report. Use it.
- The agent failed early (few tool uses, small token count). There is nothing to recover; dispatch it
  again.

## Recovery procedure

The real transcript lives in the session directory, not in the task's output file:

```
~/.claude/projects/<project-slug>/<session-id>/subagents/agent-<agentId>.jsonl
```

`<project-slug>` is the working directory with path separators replaced by dashes; the agent id is in
the task notification. If you can't find it, list the session's `subagents/` folder by modification
time.

Don't read the whole JSONL into context: it can be enormous. Extract only long assistant text blocks:

```python
import json, io, sys

def blocks(path, min_len=400):
    out = []
    for line in io.open(path, encoding="utf-8", errors="replace"):
        try:
            obj = json.loads(line)
        except Exception:
            continue
        if obj.get("type") != "assistant":
            continue
        for blk in (obj.get("message") or {}).get("content") or []:
            if isinstance(blk, dict) and blk.get("type") == "text" and len(blk.get("text", "")) > min_len:
                out.append(blk["text"])
    return out

found = blocks(sys.argv[1])
if not found:
    sys.exit("no assistant text block over 400 chars: lower min_len or check the path")
best = max(found, key=len)   # the report is almost always the longest block
print(best[:13000])          # print the tail separately if it is longer
```

Run it as `python recover.py <path-to-agent.jsonl>`.

## Why this works

Subagents write their report as an ordinary assistant text block in their transcript before the final
hand-back, which is the part that sometimes gets lost. The `type == "assistant"` filter skips tool
calls and results; the length filter skips status chatter. The longest block of 400+ characters is
reliably the report.

## Prevention

In background-agent prompts, say explicitly: "Your final message is the only thing returned to me. Put
the complete report in it, never 'done' or a pointer to earlier messages." Better still, ask the agent
to write its long report to a file and return the path. Both reduce the failure; neither removes it, so
keep this recovery handy.

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

View all in ai-agents →

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.