Repository navigation
feat(opencode): trim old tool output and media in one batch at a token mark - #186
Merged
Merged
Conversation
…n mark compaction.prune_at runs the prune inside the loop once the context reaches the mark and clears everything older than the latest keep_media results with media, in one batch so the prompt cache is rewritten rarely. Without prune_at nothing changes: prune still runs only when a turn ends, with its token-window rules.
… prune accounting
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Long V4 runs resend their whole history and only compact near the model window, and prune runs only when a turn ends, so a single long run never prunes.
compaction.prune_atruns the existing prune inside the loop once the context reaches that many tokens, andcompaction.keep_mediakeeps the latest N tool results with screenshots whole and clears everything older in one batch, so the prompt cache is rewritten rarely instead of every step. Withoutprune_atnothing changes: prune still runs only when a turn ends with its token-window rules. Tests cover the mark, the batch and the default (the existing config-dependent prune test also fails on main in this environment); typecheck passes and the prompt suite fails identically on main and this branch.Summary by cubic
Adds
compaction.prune_atandcompaction.keep_mediaoptions so long runs can trim old tool output and media in one batch inside the loop instead of only pruning when a turn ends. Withoutprune_at, behavior is unchanged and prune still runs only at turn end with its existing token-window rules.prune_attokens and clears everything older than the latestkeep_media(default: 2) completed tool results with media, rewriting the prompt cache rarely.Written for commit e6347c6. Summary will update on new commits.