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

[BUG]

Open virgil-king opened this issue 2 months ago • 1 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?

Bug Report: Task Resume Functionality Not Working

Summary

The resume parameter in the Task tool does not preserve agent context. Resumed agents have no memory of their previous conversation/work.

Environment

  • Claude Code CLI (latest as of 2025-12-24)
  • Model: claude-opus-4-5-20251101, tested with sonnet subagent

Impact

This bug makes iterative agent workflows impossible:

  • Cannot resume agents to continue incomplete work
  • Cannot have agents fix issues they discovered in previous runs
  • Agents restart from scratch on every resume, wasting context and repeating work

Additional Context

In a real-world task (fixing e2e tests), I attempted to resume an agent 3 times. Each time:

  1. The agent started by reading files from scratch
  2. The agent tried to recreate a worktree that already existed
  3. The agent redid all code edits from the beginning
  4. The agent never referenced its previous implementation work

This wasted significant time and tokens, and the agent never completed the verification step because it kept restarting the implementation.

Root Cause Analysis

Examined agent transcript files in ~/.claude/projects/*/agent-*.jsonl

The transcript file correctly records the full conversation history with proper parentUuid linking. However, the API request doesn't include prior messages.

Evidence from agent-ae68799.jsonl (the resume test):

API Call cache_read_input_tokens cache_creation_input_tokens Analysis
1st (generate) 0 12,349 System prompt cached
2nd (resume) 12,349 129 Only system prompt + 129 new tokens!

If the prior conversation had been sent, cache_creation_input_tokens would be much larger. The 129 tokens only covers the new resume prompt.

Conclusion: Claude Code writes conversation history to the transcript file, but does not read it back when constructing API requests for resumed agents.

Transcript File Location

Agent transcripts are stored at:

~/.claude/projects/{project-path}/agent-{agentId}.jsonl

Documentation Reference

The Task tool documentation states:

"Agents can be resumed using the resume parameter by passing the agent ID from a previous invocation. When resumed, the agent continues with its full previous context preserved."

This behavior does not match the documentation.

What Should Happen?

Subagents should have access to previous context when resumed with resume argument

Expected Result: Agent recalls TEST_ID: 7f3a9c2e-8b1d-4f6a-9e5c-2d7b4a8f1c3e

Error Messages/Logs


Steps to Reproduce

Repro Steps

Step 1: Launch an agent and have it generate a unique identifier

Task(
  subagent_type="general-purpose",
  model="sonnet",
  description="Test resume context - phase 1",
  prompt="""
    Generate a random UUID and report it in this format:
    TEST_ID: [your random string here]
  """,
  run_in_background=false
)

Result: Agent generates and reports: TEST_ID: 7f3a9c2e-8b1d-4f6a-9e5c-2d7b4a8f1c3e Agent ID returned: ae68799

Step 2: Resume the agent and ask it to recall the identifier

Task(
  subagent_type="general-purpose",
  model="sonnet",
  description="Test resume context - phase 2",
  resume="ae68799",  # <-- Resume parameter specified
  prompt="""
    In your previous task, you generated a TEST_ID.
    Please tell me what that TEST_ID was.
    Do NOT generate a new one.
  """,
  run_in_background=false
)

Claude Model

Opus

Is this a regression?

I don't know

Last Working Version

No response

Claude Code Version

2.0.76 (Claude Code)

Platform

Other

Operating System

Other Linux

Terminal/Shell

Other

Additional Information

No response

virgil-king avatar Dec 24 '25 23:12 virgil-king