[Bug] Auto-compact threshold ignores CLAUDE_CODE_DISABLE_1M_CONTEXT in background agents
Bug Description
Title: Auto-compact never triggers in background agents when CLAUDE_CODE_DISABLE_1M_CONTEXT=1
Environment
- Claude Code CLI on Linux (WSL2). Current install is v2.1.201; the bug was observed on or around 2026-07-03 (auto-updated since, so the exact build then may have been slightly earlier).
- Env vars set via the env block of ~/.claude/settings.json.
Description
With "CLAUDE_CODE_DISABLE_1M_CONTEXT": "1", auto-compaction stopped working entirely — but only in background agents launched from the agents view. Interactive sessions with the same setting auto-compacted normally. Background agents just kept growing their context; compaction never fired.
Steps to reproduce
- Set "CLAUDE_CODE_DISABLE_1M_CONTEXT": "1" in the env block of ~/.claude/settings.json.
- Launch a background agent from the agents view.
- Give it a long task that fills the conversation well past the point where auto-compact should trigger on a 200k window.
Expected: the background agent auto-compacts near the effective (200k) context limit, same as interactive sessions.
Actual: auto-compaction never triggers in the background agent.
Workaround / strong hint at the cause: explicitly setting "CLAUDE_CODE_AUTO_COMPACT_WINDOW": "250000" restores auto-compaction for background agents. This suggests the background-agent path derives its auto-compact threshold from the 1M window even when the 1M beta is disabled — so the trigger point sits far above the real context limit and is never reached. Pinning the window manually fixes it; interactive sessions compute the reduced window correctly.
Environment Info
- Platform: linux
- Terminal: wsl-Ubuntu
- Version: 2.1.201
- Feedback ID: 959ef51f-a947-4ae5-b733-f6a5201621f4
Errors
[]