You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Description Bug in the compaction overflow detection: isOverflow threshold too low when limit.input is set. overflow.ts:14-19 鈥?when model.limit.input is set, usable() uses limit.input - reserved. reserved is min(COMPACTION_BUFFER, maxOutputTokens) where COMPACTION_BUFFER is 20,000. Since max output tokens are typically 32K-128K, reserved stays at 20K even when the model needs more headroom. Compaction triggers with only 20K of reserve, but the next API call may need 32K+ 鈥?causing an actual overflow despite compaction having fired. Note: the compaction retry loop (compaction LLM overflow 鈫?infinite retry) is already tracked in #27924, #15533, #30443. This issue focuses on the distinct threshold calculation bug that causes compaction to fire too late. Focused follow-on to #30376. Suggested fix: use maxOutputTokens as reserve when limit.input is set, instead of min(20K, maxOutputTokens). ### OpenCode version
main
Steps to reproduce 1. Start a session with a model that has limit.input set (e.g., 128K input limit) 2. Fill context to near the limit 3. Compaction fires with only 20K reserve 4. Next API call overflows because output needs more than 20K headroom
Description Bug in the compaction overflow detection: isOverflow threshold too low when limit.input is set. overflow.ts:14-19 鈥?when
model.limit.inputis set,usable()useslimit.input - reserved.reservedismin(COMPACTION_BUFFER, maxOutputTokens)whereCOMPACTION_BUFFERis 20,000. Since max output tokens are typically 32K-128K,reservedstays at 20K even when the model needs more headroom. Compaction triggers with only 20K of reserve, but the next API call may need 32K+ 鈥?causing an actual overflow despite compaction having fired. Note: the compaction retry loop (compaction LLM overflow 鈫?infinite retry) is already tracked in #27924, #15533, #30443. This issue focuses on the distinct threshold calculation bug that causes compaction to fire too late. Focused follow-on to #30376. Suggested fix: use maxOutputTokens as reserve when limit.input is set, instead of min(20K, maxOutputTokens). ### OpenCode versionmain
Steps to reproduce 1. Start a session with a model that has limit.input set (e.g., 128K input limit) 2. Fill context to near the limit 3. Compaction fires with only 20K reserve 4. Next API call overflows because output needs more than 20K headroom