[BUG] Claude Code sends repeated requests hundreds of times without stopping
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?
Claude Code entered an infinite loop, repeatedly sending the same requests for several hours (~1 minute interval between each). This resulted in $500+ of unexpected token usage.
What Should Happen?
Claude Code should detect repeated/looping request patterns and automatically stop after a reasonable number of retries, rather than continuing indefinitely for hours and consuming hundreds of dollars in tokens.
Error Messages/Logs
Steps to Reproduce
Configure 100+ MCP tools, which occupy a large portion of the context window (~33.4%). Combined with other configs, 42% of the context window is already occupied before any conversation begins:
claude-opus-4-6 · 84k/200k tokens (42%)
Start a task — e.g., ask Claude to develop a Python file based on a wiki document (not a particularly complex task).
Claude Code reports the context window is exhausted and suggests compacting or clearing the context.
Run /compact.
Follow up with: "Please finish the last task" — then leave (unattended).
Next day: the task is still running. Check the bill → $500+ spent on repeated requests.
Claude Model
Opus
Is this a regression?
I don't know
Last Working Version
_No response_
Claude Code Version
v2.1.71
Platform
Anthropic API
Operating System
Other Linux
Terminal/Shell
Other
Additional Information
Root Cause Hypothesis
With 42% of the context consumed by MCP tool definitions alone, the remaining usable context is very limited. After /compact, Claude likely enters a cycle where it:
Attempts to continue the task
Immediately runs out of context again
Retries — repeating this loop indefinitely
Suggested Fix
Implement a loop detection mechanism: if the same (or near-identical) request is sent N times consecutively, abort and notify the user.
Add a maximum retry limit or cumulative cost guardrail for unattended sessions.
Consider warning the user when the available context after MCP tool definitions is too small to meaningfully complete a task.
This issue has 9 comments on GitHub. Read the full discussion on GitHub ↗