Skip to content

feat(context): lower default compaction threshold to 150K#37

Merged
arniesaha merged 1 commit intomainfrom
feat/lower-compact-threshold
Apr 23, 2026
Merged

feat(context): lower default compaction threshold to 150K#37
arniesaha merged 1 commit intomainfrom
feat/lower-compact-threshold

Conversation

@arniesaha
Copy link
Copy Markdown
Owner

Summary

  • CONTEXT_WINDOW: 1M → 200K default
  • COMPACT_THRESHOLD: 0.8 → 0.75 (effective budget: 150K tokens)
  • Env overrides: MAX_CONTEXT_WINDOW, MAX_COMPACT_THRESHOLD, MAX_KEEP_RECENT
  • Effective values logged once on first transform
  • README gains a Context sizing section

Why

Yesterday's quota exhaustion: at the old 800K budget, a multi-step session resends history on every tool iteration. The Claude subscription 5-hour rate-limit window fills long before compaction kicks in. 150K is a safe default for that path; Gemini direct or long-context Anthropic keys can set the window back up via env.

Test plan

  • npm test — all green
  • npm run build — clean
  • Deploy, check logs for Context sizing: window=200000 threshold=150000 ...
  • Run a medium session; compaction triggers earlier than before

🤖 Generated with Claude Code

Default CONTEXT_WINDOW drops from 1M to 200K, threshold from 0.8 to 0.75
(effective budget 150K tokens). At the old 800K budget a multi-PR session
could exhaust a Claude 5-hour rate-limit window before compaction ever
triggered.

- Added env overrides: MAX_CONTEXT_WINDOW, MAX_COMPACT_THRESHOLD,
  MAX_KEEP_RECENT
- Log effective values once per process (first transformContext call)
- Documented in README under "Context sizing"
- .env.example updated

Providers with cheap long context (Gemini direct, 1M-context models) can
raise MAX_CONTEXT_WINDOW back up.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@arniesaha arniesaha merged commit 2c0a8f0 into main Apr 23, 2026
1 check passed
@arniesaha arniesaha deleted the feat/lower-compact-threshold branch April 23, 2026 07:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant