claude-code icon indicating copy to clipboard operation
claude-code copied to clipboard

[BUG] Subagent Resume Missing All User Prompts

Open 0x1355 opened this issue 1 month ago • 6 comments

Preflight Checklist

  • [x] I have searched existing issues and this hasn't been reported yet
  • [x] This is a single bug report (please file separate reports for different bugs)
  • [x] I am using the latest version of Claude Code

What's Wrong?

The subagent resume functionality is broken because agent transcript files do not store the user prompts that initiated or resumed the agent. This causes resumed agents to lack critical context, making the resume feature unusable for its intended purpose.

This manifests in three symptoms.

Symptom 1: Agent IDs Not Displayed

When an agent completes, the agent ID is not displayed to the user in either:

  • The CLI output/UI
  • The tool result returned to the main agent

Evidence:

  • Dispatched multiple test agents
  • Agents completed successfully
  • No agent ID was shown in UI or <function_results> blocks
  • Agent IDs only discoverable by manually inspecting transcript files in ~/.claude/projects/

Symptom 2: Transcripts Missing ALL User Prompts

Agent transcript files (agent-{agentId}.jsonl) contain:

  • ✅ Assistant responses (text and tool calls)
  • ✅ Tool results (as "user" role messages)
  • NO user prompts (both initial dispatch and all resume prompts)

Critical Finding: This affects EVERY user prompt, not just the first one. No user instructions are ever saved to the transcript.

Evidence:

Extended test case with multiple resumes:

1. Dispatch agent: "Remember BANANA-123, read bug_report.md, standby"
   Agent responds: "I'll remember BANANA-123" + reads file + "standing by"
   Agent ID: 32203431

2. Resume agent 32203431: "What was the code and first word of the file?"
   Agent responds: "BANANA-123" and "Bug" ✅ (inferred from its previous response + tool result)

3. Resume agent 32203431: "Also remember PEAR-666, standby"
   Agent responds: "I'll remember PEAR-666, standing by" ✅

4. Resume agent 32203431: "Tell me both codes"
   Agent responds: "APPLE-123 and PEAR-666" ❌ (BANANA hallucinated as APPLE)

Transcript inspection of agent-32203431.jsonl:

  • 6 assistant messages (responses, tool calls)
  • 1 user message (tool_result from Read)
  • 0 user messages containing ANY of the 4 prompts sent
  • input_tokens field shows only 3-6 tokens per message (impossible to include prompts)

Symptom 3: Context Reconstruction Causes Hallucination

Resume DOES partially work, but agents must reconstruct context by reading their own previous responses rather than seeing the actual prompts. This leads to:

Lossy context reconstruction:

  • ✅ Agent can infer some context from its own assertions ("I'll remember BANANA-123" → knows about BANANA-123)
  • ✅ Tool results are preserved (file contents from Read tool were remembered)
  • ❌ Agent lacks the original framing/instructions from user prompts
  • ❌ Multiple inference steps cause drift and hallucination (BANANA-123 → APPLE-123)

Why this happens: The agent sees: "I'll remember the code **BANANA-123**" and "I'll remember the second code: **PEAR-666**" but doesn't see WHY it said those things. When asked to recall both codes, it must infer what the user originally asked for, leading to hallucinated "corrections" like changing BANANA to APPLE.

What Should Happen?

According to the documentation at https://code.claude.com/docs/en/sub-agents:

  1. "Each subagent execution is assigned a unique agentId"
  2. "Claude Code displays the agent ID when a subagent completes its work"
  3. "You can resume a previous agent by providing its agentId via the resume parameter"
  4. Resumed agents should have full context from their previous conversation

Example from docs:

> Use the code-analyzer agent to start reviewing the authentication module
[Agent completes initial analysis and returns agentId: "abc123"]

> Resume agent abc123 and now analyze the authorization logic as well
[Agent continues with full context from previous conversation]

Error Messages/Logs


Steps to Reproduce

  1. Dispatch a test agent with multiple tasks:
claude
> Use the general-purpose agent to remember the code ORANGE-456, read /etc/hostname, then standby
  1. Find the agent ID:
ls -lt ~/.claude/projects/-xxx/agent-*.jsonl | head -1
grep -o '"agentId":"[^"]*"' [most recent file]
# Returns something like: "agentId":"abc12345"
  1. Resume once (will work):
> Resume agent abc12345 and tell me the code and hostname
# Agent responds correctly (infers from its previous response + tool result)
  1. Resume again with new info:
> Resume agent abc12345, also remember GRAPE-789, standby
  1. Resume third time:
> Resume agent abc12345 and tell me both codes
# Agent will hallucinate one or both codes, or claim confusion
  1. Inspect transcript:
cat ~/.claude/projects/-xxx/agent-abc12345.jsonl | jq -r '.message.role'
# Shows only "assistant" and occasional "user" (tool results), never user prompts

Claude Model

Sonnet (default)

Is this a regression?

I don't know

Last Working Version

No response

Claude Code Version

2.0.42

Platform

Anthropic API

Operating System

Other Linux

Terminal/Shell

Other

Additional Information

Priority: High - Core feature severely degraded Component: Agent/Subagent system, Transcript storage Reproducibility: 100% consistent across all agent invocations Affects: All workflows using agent resume (subagents practically broken after 2-3 resumes)

0x1355 avatar Nov 15 '25 22:11 0x1355