perf(copilot): trigger compaction at 100K tokens instead of 140K

Set CLAUDE_AUTOCOMPACT_PCT_OVERRIDE=50 to compact at 50% of 200K
context window (100K) instead of the default 70% (140K). Context
>200K accounts for 54% of cost despite being only 3% of calls.
Earlier compaction keeps context smaller and reduces cache creation.
This commit is contained in:
majdyz
2026-04-13 12:15:39 +00:00
parent 1d3cce0ebf
commit ac054c31f6

View File

@@ -100,6 +100,11 @@ def build_sdk_env(
# that OpenRouter rejects. Safe for all modes — direct Anthropic ignores it.
env["CLAUDE_CODE_DISABLE_EXPERIMENTAL_BETAS"] = "1"
# Trigger context compaction earlier — default is 70% of 200K = 140K.
# Set to 50% = 100K to keep context smaller and reduce cache creation costs.
# Context >200K accounts for 54% of total cost despite being only 3% of calls.
env["CLAUDE_AUTOCOMPACT_PCT_OVERRIDE"] = "50"
# Disable gzip on API responses to prevent ZlibError decompression
# failures (see oven-sh/bun#23149, anthropics/claude-code#18302).
# Appended to any existing ANTHROPIC_CUSTOM_HEADERS (OpenRouter mode