Agent re-runs tests unnecessarily after context compaction
Resolved 💬 4 comments Opened Feb 22, 2026 by Asclepius9 Closed Mar 25, 2026
Description
When a long session triggers context compaction (conversation summary), Claude Code loses track of which verification steps (like test runs) have already been performed. It re-runs the full test suite even when:
- Tests were already run and confirmed passing moments earlier
- The results were included in the compacted summary
- No code changes occurred between the test run and the repeated run
Reproduction
- Work through multiple sequential code changes in a single session (e.g., refactoring audit with 10+ issues)
- Each change involves: edit files → run tests → commit → next issue
- After context compaction occurs mid-session, Claude re-runs the full test suite unnecessarily — sometimes multiple times in a single response — even when tests just passed
Expected Behavior
After context compaction, Claude should trust the test results summarized in the compaction context and not re-run them unless code has changed since the last run.
Impact
- Wastes user time (test suites can take 1-2+ minutes)
- Frustrating UX when the same 100+ second test run happens 2-3 times in a row
- Gets worse as sessions get longer and compaction happens more frequently
Environment
- Claude Code CLI
- Model: claude-opus-4-6
- Long refactoring sessions with 10+ sequential commits
This issue has 4 comments on GitHub. Read the full discussion on GitHub ↗