From 9889848932d5b27b6f53c3e6d3b717c41d8aabea Mon Sep 17 00:00:00 2001 From: robbyczgw-cla Date: Wed, 29 Apr 2026 15:07:26 +0000 Subject: [PATCH] fix(claude-provider): respect operator-set CLAUDE_CODE_AUTO_COMPACT_WINDOW Closes #1820. The container agent-runner sets CLAUDE_CODE_AUTO_COMPACT_WINDOW unconditionally on the container process env, with no way to override it per-deployment without editing source. Read process.env first and fall back to the existing 165000 literal when unset. Default behavior is unchanged for installs that do not set the env var. Operators running 1M-context models or emergency-tuning a live deployment can now raise or lower the threshold from the host env. --- container/agent-runner/src/providers/claude.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/container/agent-runner/src/providers/claude.ts b/container/agent-runner/src/providers/claude.ts index fbb077c..c9478b8 100644 --- a/container/agent-runner/src/providers/claude.ts +++ b/container/agent-runner/src/providers/claude.ts @@ -226,8 +226,12 @@ function createPreCompactHook(assistantName?: string): HookCallback { /** * Claude Code auto-compacts context at this window (tokens). Kept here so * the generic bootstrap doesn't need to know about Claude-specific env vars. + * + * Operator override: set CLAUDE_CODE_AUTO_COMPACT_WINDOW in the host env to + * raise or lower the threshold without editing source — useful when running + * with a 1M-context model variant or when emergency-tuning a deployment. */ -const CLAUDE_CODE_AUTO_COMPACT_WINDOW = '165000'; +const CLAUDE_CODE_AUTO_COMPACT_WINDOW = process.env.CLAUDE_CODE_AUTO_COMPACT_WINDOW || '165000'; /** * Stale-session detection. Matches Claude Code's error text when a