Agent stuck in infinite loop — repeated 'let me write the document' without executing, burned full context window
Bug Description
During a multi-agent research task, Claude Code got stuck in a loop where it repeatedly stated "let me write the document" across multiple turns without ever actually calling the Write tool. This continued until the full context window was consumed and the session had to be compacted/continued. The actual task (writing a single markdown file from completed agent outputs) took ~10 seconds once the new session started.
Steps to Reproduce
- Launched 4 parallel research agents (Task tool, subagent_type=general-purpose)
- All 4 agents completed successfully with full outputs
- Next step was to assemble outputs into a single markdown file via Write tool
- Instead of writing, Claude repeatedly said variations of "let me assemble the document now" without invoking any tool
- This looped across multiple turns until context was exhausted
Expected Behavior
After all 4 agents completed, Claude should have called the Write tool to create the output file. One turn, one tool call.
Actual Behavior
Claude entered a loop of stating intent to write without executing. User had to intervene multiple times before the session was compacted and a fresh continuation actually performed the write.
Impact
- Full context window burned on zero-value loop iterations
- Significant token waste on an Opus 4.6 session
- User had to manually intervene and restart
Environment
- Model: claude-opus-4-6
- Platform: Linux (Ubuntu, CLI)
- Claude Code version: 2.1.50
- Date: 2026-02-21
Request
Requesting a usage credit for the wasted tokens in the looping session. This was a clear bug where the model failed to invoke the tool it stated it would use, repeatedly, across the entire context window.
This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗