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

Subagent duplicate tool calls with persisted-output

Open keenanwh opened this issue 11 months ago • 0 comments

Description

Subagents spawned via the Task tool are making duplicate consecutive tool calls, burning tokens unnecessarily.

Environment

  • Claude Code version: Latest (as of 2026-01-03)
  • OS: Windows 10 (MSYS2/Git Bash)
  • Model: Sonnet (subagent), Opus (orchestrator)

Reproduction

  1. Spawn a subagent via Task tool for a multi-step task
  2. Let it run for 10+ minutes with file reads, edits, and bash commands
  3. Observe the output file shows duplicate consecutive tool calls

Observed Behavior

Almost every tool call appears twice in succession with identical parameters:

[Tool: Read] {"file_path":"...Player.cs"}
[Tool: Read] {"file_path":"...Player.cs"}     <-- DUPLICATE
[Tool: Grep] {"pattern":"WithNobleAdded",...}
[Tool: Grep] {"pattern":"WithNobleAdded",...}  <-- DUPLICATE
[Tool: Edit] {"file_path":"...GameStateTests.cs",...} (200+ line edit)
[Tool: Edit] {"file_path":"...GameStateTests.cs",...} (200+ line edit)  <-- DUPLICATE

This affects Read, Grep, Edit, Bash - all tool types.

Suspected Cause

When tools return <persisted-output>Tool result saved to:...</persisted-output>, the subagent may be misinterpreting this as "no result received" and retrying immediately.

Impact

  • 2x token consumption for affected calls
  • Large Edit operations are especially expensive when duplicated
  • 21-minute task consumed excessive tokens

Additional Context

  • No custom hooks affecting Read/Grep (verified)
  • Duplicates are consecutive (not interleaved)
  • Pattern starts after first few calls, not from the beginning

keenanwh avatar Jan 03 '26 17:01 keenanwh