fix(session): honor compaction.reserved without limit.input [AI-generated, unverified] - #48813
Moonbius-lab wants to merge 1 commit into
Conversation
|
Hey! Your PR title Please update it to start with one of:
Where See CONTRIBUTING.md for details. |
|
This PR doesn't fully meet our contributing guidelines and PR template. What needs to be fixed:
Please edit this PR description to address the above within 2 hours, or it will be automatically closed. If you believe this was flagged incorrectly, please let a maintainer know. |
|
The following comment was made by an LLM, it may be inaccurate: Potential duplicate/related PRs found:
These PRs appear to be addressing related compaction and auto-trigger issues in the session management system. PR #45933 seems most closely related to the logic this PR modifies. |
|
Thanks for your contribution! This PR doesn't have a linked issue. All PRs must reference an existing issue. Please:
See CONTRIBUTING.md for details. |
|
Closing as superseded by #45933, which rewrites usable() in the same file and already honors a configured compaction.reserved (and adds unit tests, including a deepseek 1M/384k case). No need for a duplicate. (This PR was AI-generated and unverified.) |
Warning
AI-generated, not human-reviewed. This PR was produced by an AI coding agent and has not been reviewed or tested by a human. It is provided for reference only — please do not merge without independent review and verification.
Summary
usable()inpackages/opencode/src/session/overflow.tssilently ignores a user-configuredcompaction.reservedwhenever the model does not definelimit.input.In that branch the limit is computed as
context - maxOutputTokens(...), while the already-computedreservedvalue is discarded. As a resultcompaction.reservedhas no effect for such models and auto-compaction fires much later than configured. For example, a model withlimit.context: 1000000only compacts around ~968k tokens (context - min(limit.output, OUTPUT_TOKEN_MAX=32000)), even if the user setcompaction.reservedto a much larger value.Change
compaction.reservedin both branches.compaction.reservedis unset:limit.inputpresent:limit.input - min(COMPACTION_BUFFER, maxOutputTokens)context - maxOutputTokensVerification status
bun typecheckor the test suite (no Bun toolchain available in the environment this was authored in).Related reports
Not addressed here
Old media (images / PDFs) is persisted as base64 and replayed from history; the
stripMediaoption inpackages/opencode/src/session/message-v2.tscurrently has no callers. That is a separate concern and is not changed by this PR.