Description
In packages/opencode/src/session/compaction.ts, the isOverflow function calculates usable tokens:
const usable = input.model.limit.input
? input.model.limit.input - reserved
: context - ProviderTransform.maxOutputTokens(input.model)
The problem is that many models (like claude-opus-4.6) do not have an explicit input limit defined in their model definition (only context and output). In this case, the code takes the else branch:
: context - ProviderTransform.maxOutputTokens(input.model)
This calculation completely ignores the reserved variable (which respects config.compaction.reserved). As a result, users cannot tune the compaction threshold to avoid context overflow crashes.
Expected Behavior
The reserved buffer (e.g. 60000 tokens) should be subtracted from the total context in the else branch as well.
Proposed Fix
const usable = input.model.limit.input
? input.model.limit.input - reserved
: context - reserved // (assuming reserved includes maxOutput safety buffer)
Description
In
packages/opencode/src/session/compaction.ts, theisOverflowfunction calculatesusabletokens:The problem is that many models (like
claude-opus-4.6) do not have an explicitinputlimit defined in their model definition (onlycontextandoutput). In this case, the code takes theelsebranch:This calculation completely ignores the
reservedvariable (which respectsconfig.compaction.reserved). As a result, users cannot tune the compaction threshold to avoid context overflow crashes.Expected Behavior
The
reservedbuffer (e.g. 60000 tokens) should be subtracted from the total context in the else branch as well.Proposed Fix