Skip to content

Bug: compaction.reserved config is ignored for models without explicit 'input' limit #13980

Closed

Description

@andrea-tomassi

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)

Activity

  1. added
    coreAnything pertaining to core functionality of the application (opencode server stuff)
    on Feb 17, 2026
  2. added 5 commits that reference this issue on Feb 18, 2026
    33b2bf7
    567e162
    e41f8bc
    4a5ad18
    0fc0f82
  3. github-actions commented on Apr 19, 2026

    @github-actions
    Contributor

    To stay organized issues are automatically closed after 60 days of no activity. If the issue is still relevant please open a new one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

coreAnything pertaining to core functionality of the application (opencode server stuff)

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions