[PR #12924] fix(core): ensure compaction is more reliable, add reserve token buffer to ensure that input window has enough room to compact #14436

Closed
opened 2026-02-16 18:19:13 -05:00 by yindo · 0 comments
Owner

Original Pull Request: https://github.com/anomalyco/opencode/pull/12924

State: closed
Merged: Yes


  • Remove max token calculation logic that is handled by ai sdk now
  • add total tokens field (isOverflow now uses the native totalTokens count coming from providers and falls back to the addition method)
  • add compaction.reserved (configurable token buffer for compaction, users can set to 0 to have no buffer)
  • adjust isOverflow to try to get a bit closer to the context window by default (within 20k instead of within 32k)

This should fix most issues people were having w/ openai models not compacting on time


Next up:

I will make it so context overflows aren't "session ending" and are actually recoverable states

**Original Pull Request:** https://github.com/anomalyco/opencode/pull/12924 **State:** closed **Merged:** Yes --- - Remove max token calculation logic that is handled by ai sdk now - add total tokens field (isOverflow now uses the native totalTokens count coming from providers and falls back to the addition method) - add compaction.reserved (configurable token buffer for compaction, users can set to 0 to have no buffer) - adjust isOverflow to try to get a bit closer to the context window by default (within 20k instead of within 32k) --- This should fix most issues people were having w/ openai models not compacting on time --- Next up: I will make it so context overflows aren't "session ending" and are actually recoverable states
yindo added the pull-request label 2026-02-16 18:19:13 -05:00
yindo closed this issue 2026-02-16 18:19:13 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#14436