MAJOR BUG: Claude Code Stuck in Infinite Compaction Loop Making it Basically Useless!
✽ Compacting conversation… (esc to interrupt) and since it is wasting so much time and cycles on compacting, this happens a lot sooner that it should: Claude usage limit reached. Your limit will reset at 12pm (America/Los_Angeles).
Issue Summary
Claude Code v1.0.83 is stuck in an infinite loop attempting to "compact" the conversation, preventing task completion and wasting computational resources. consequently, i am getting, " Approaching Opus usage limit" and "Approaching usage limit. resets at x pm" a lot faster than what I am used to for the past 3 months that I have been using claude code.
Environment
- Claude Code Version: v1.0.83 (latest)
- OS: Windows 11 + WSL2 Ubuntu
- Session Duration: Multiple hours
- Task: Creating test files
Bug Description
Expected Behavior
Claude should:
- Read the required files to understand test patterns
- Identify missing test files
- Create the missing test files
- Complete the task
Actual Behavior
Claude is stuck in an infinite loop where it:
- Reads the same 5 test files repeatedly: - x_strategy_test.go (746 lines) - y_timeseries_strategy_test.go (746 lines) - z_markov_model_strategy_test.go (647 lines) - w_strategy_test.go (795 lines) - v_strategy_test.go (810 lines)
- After reading files, attempts to "compact" the conversation
- Returns to step 1, reading the same files again
- Never progresses to actually creating the missing test files
Pattern Observed
Read x_strategy_test.go → Read y_timeseries_strategy_test.go → Read z_markov_model_strategy_test.go → Read w_range_strategy_test.go → Read v_flow_imbalance_strategy_test.go → [Compaction attempt] → [Loop restarts]
Reproduction Steps
- Start a conversation about creating missing test files
- Claude identifies need to read existing test files for patterns
- Claude reads 5 test files successfully
- Claude enters compaction loop
- Loop continues indefinitely without task progress
- User Experience: User must manually interrupt and restart
Evidence of Loop
The conversation history shows:
- Same 5 files read multiple times
- No actual test file creation despite having all needed information
- Pattern recognition completed but no execution
- Todo list shows task as "in_progress" but no progress made
Suspected Cause
Appears to be a context management issue where:
- Claude tries to compact/summarize conversation to fit context window
- Compaction process loses critical task state
- Claude re-reads files to "recover" context
- Process repeats infinitely
Workaround Attempts
- User interrupted with: "Please continue the conversation from where we left it off"
- Claude acknowledged but resumed the same loop pattern
Requested Fix
- Immediate: Break loop detection - if same files read >2 times, force task execution
- Long-term: Fix compaction logic to preserve task state and progress
- Safety: Add loop detection to prevent infinite patterns
Additional Context
- The task is straightforward: create 3 test files following established patterns
- All required information was successfully gathered in first read
- No technical blockers exist - purely a control flow issue
- System has sufficient context from the 5 example files
Severity: CRITICAL
This bug prevents completion of any complex multi-step task that triggers compaction, making Claude Code unusable for production software development tasks.
Recommendation: The compaction/context management system needs urgent review. When compaction occurs, task state and progress markers must be preserved to prevent re-reading already processed files.