[BUG] Subagent SendMessage-resume 400s: deferred tool (ReportFindings) referenced in transcript not rehydrated into tools[] on resume
Summary
Resuming a completed background subagent via SendMessage fails immediately with:
Agent terminated early due to an API error:
API Error: 400 Tool reference 'ReportFindings' not found in available tools
The resumed agent never runs any work — it 400s at request validation. A fresh Agent spawn of the same subagent type on the same task works fine; only the resume-from-transcript path fails. ReportFindings is a deferred, skill-injected tool the subagent never called — it merely appears by name in the reconstructed transcript.
Environment
- Claude Code v2.1.x (interactive CLI), model Opus 4.8 (
claude-opus-4-8[1m]) - Linux
- Session had code-review capability active, so the top-level tool catalog contained
ReportFindings("Report code-review findings as a typed list…"), plus MCP servers (lean-ctx, tokensave) contributing many deferred tools surfaced on demand viaToolSearch.
Reproduction
- In a session where
ReportFindingsis present as a (deferred) tool, spawn ageneral-purposesubagent with theAgenttool (run_in_background: false) and give it a run-and-report task. It completes normally and returns anagentId. - Continue that agent with
SendMessage({ to: <agentId>, message: "<follow-up>" }). The tool result confirms: "had no active task; resumed from transcript in the background." - Before doing any work, the continuation dies. Task-notification arrives with
status=failedand summary:
Agent "…" failed: Agent terminated early due to an API error: API Error: 400 Tool reference 'ReportFindings' not found in available tools
Observed reliably: first spawn = success (10–14 tool calls, full report); every SendMessage-resume of that same agent = instant 400 on ReportFindings.
Expected
Resume-from-transcript reassembles the continuation request's tools[] to include every tool referenced anywhere in the resumed transcript (or neutralizes stale references), so Messages-API validation passes and the agent continues.
Actual
The Anthropic Messages API rejects the continuation request at validation because a tool referenced in the reconstructed messages (ReportFindings) is absent from that request's tools[]. ReportFindings is a deferred tool that was ambiently present in the parent session's catalog (code-review skill) and surfaced into the subagent's first-run tool set; the resume path does not rehydrate deferred-tool state, so it is omitted from tools[] on the continuation — producing the 400.
Root cause (hypothesis, ~65% confidence — inferred, no harness source)
The subagent resume-from-transcript path rebuilds tools[] from scratch and does not restore deferred tools that were loaded/surfaced during the original run (via ToolSearch or ambient skill injection). Any transcript that references such a tool by name → 400 "Tool reference X not found in available tools" on resume. A fresh spawn is unaffected because its new transcript never references the tool.
Suggested fixes (any one closes it)
- On resume, scan the reconstructed transcript for all referenced tool names and guarantee each is present in
tools[](rehydrate deferred tools by name before sending). - Persist the deferred-tool registry alongside the agent transcript; restore it on resume.
- Before sending the continuation request, strip/neutralize
tool_useblocks and system-reminders that name tools not in the currenttools[]. - Stop leaking code-review-only tools (
ReportFindings) intogeneral-purposesubagents' catalogs — it has no business there and is the specific trigger.
Impact
- Subagent continuation via
SendMessageis unusable in any session with code-review (or other deferred / skill-injected) tools active — a hard failure, not graceful degradation. - Semi-silent: surfaces only as a task-notification
failedwith an API-error summary. Worse, any detached child process the subagent launched keeps running orphaned after the agent dies.
Related
- #38183 — SendMessage / agent continuation + tool availability on resume
- #69158 — subagent tool roster injected lazily (availability vs visibility)
Workaround
Spawn a fresh Agent each time instead of SendMessage-resuming a completed subagent. Fresh spawns reliably succeed.