Autocompact silently disabled for Bedrock/Vertex users since v2.1.154
Summary
Autocompact stopped firing automatically for Bedrock users starting around v2.1.154. Sessions fill to 100% context without compacting; manual /compact still works fine.
Environment
- Claude Code version: 2.1.160
- API provider: AWS Bedrock (
CLAUDE_CODE_USE_BEDROCK=1,ANTHROPIC_API_PROVIDER=bedrock) - Model:
us.anthropic.claude-sonnet-4-6 - OS: Windows 11
CLAUDE_CODE_AUTO_COMPACT_WINDOW: not set (before fix)CLAUDE_CODE_MAX_OUTPUT_TOKENS: 12288
Root Cause (traced through binary)
The daf() function — which decides whether to compact on each turn — contains this guard:
if (fWH() && !rc() && !q68(q, $)) return false;
Where:
fWH()=!CLAUDE_CODE_REMOTE→ alwaystruein local sessionsrc()= reads GrowthBook feature flagtengu_amber_redwood3→ alwaysfalsefor Bedrock users becausepx()(GrowthBook availability) requiresCz()(firstParty provider), which is false for Bedrockq68(q, $)=trueonly ifCLAUDE_CODE_AUTO_COMPACT_WINDOWis set via env or settings → false by default
With all three conditions true, daf() returns false unconditionally — autocompact never fires, regardless of context usage.
The chain:
px()=!DISABLE_GROWTHBOOK && mx()=!DISABLE_GROWTHBOOK && !UI()UI()=wD9() || l3() !== null || Z58()wD9()=!PROVIDER_MANAGED_BY_HOST && !Cz()→truefor all non-firstParty providers (Bedrock, Vertex)- Therefore
px()=falsefor Bedrock users → GrowthBook feature flags always return defaults L8("tengu_amber_redwood3", "")returns""(falsy default) →rc()=false
This appears to have been introduced when the "reactive" compaction path was added. The guard is intended to route Bedrock users through the non-reactive path — but a logic error causes it to skip compaction entirely instead.
Evidence
Session transcripts show:
- v2.1.126–v2.1.150: 15+ successful
trigger: "auto"compact events,preTokens~175K - v2.1.154+: zero
trigger: "auto"events; onlytrigger: "manual"after user runs/compact - Non-compacting sessions peaked at 176K tokens (above the 174K threshold of
effectiveWindow - 13000)
Workaround
Setting CLAUDE_CODE_AUTO_COMPACT_WINDOW=200000 in settings.json makes q68() return true, which bypasses the broken guard and restores autocompact behavior via the standard (non-reactive) path.
Expected Behavior
Bedrock/Vertex users should have autocompact work identically to firstParty API users. Being excluded from a server-side A/B experiment (tengu_amber_redwood3) should not disable autocompact — it should simply use the non-reactive code path.
Suggested Fix
The guard condition should use || instead of && for the experiment check, or the non-reactive path should be taken (rather than skipping compaction entirely) when rc() is false and no explicit window is configured:
// Current (broken for Bedrock):
if (fWH() && !rc() && !q68(q, $)) return false;
// Fix option 1: fall through to non-reactive path when rc() is false
if (fWH() && !rc() && !q68(q, $)) {
// continue to non-reactive compact path below, don't return false
}
// Fix option 2: only skip if user explicitly disabled compact window
if (fWH() && !rc() && !q68(q, $) && autoCompactWindowExplicitlyDisabled) return false;This issue has 1 comment on GitHub. Read the full discussion on GitHub ↗