fix(compaction): make compaction limits configurable and improve prompt detail retention#29324
Open
shrijit37 wants to merge 2 commits into
Open
fix(compaction): make compaction limits configurable and improve prompt detail retention#29324shrijit37 wants to merge 2 commits into
shrijit37 wants to merge 2 commits into
Conversation
…pt detail retention - Add tool_output_max_chars config: controls how much tool output text the compaction model sees. Default 2000, can be raised to e.g. 16000. - Add summary_template config: custom Markdown template replacing the hardcoded template. Lets users tailor sections to their workflow. - Add model config: route compaction to a specific model (e.g. 'anthropic/claude-opus-4') separate from the session model. - Add preserve_recent_tokens_max config: upper bound for tokens kept verbatim from recent turns. Default raised from 8000 to 32000. - Revise compaction system prompt to emphasize preserving exact error messages, file paths, command outputs, identifiers, and user preferences over terse bullets. Closes anomalyco#25746 Refs anomalyco#21478, anomalyco#20246, anomalyco#16333, anomalyco#13946
Contributor
|
The following comment was made by an LLM, it may be inaccurate: Based on my search, I found no duplicate PRs for PR #29324. The searches returned PR #29324 itself and various other compaction-related PRs, but none are addressing the same specific changes (making compaction limits configurable and improving prompt detail retention through the mechanisms described in this PR). The other compaction-related PRs address different aspects like auto-compact loops, compaction thresholds, cache-aligned compaction, etc., but not the same feature scope as this PR. |
Contributor
|
Thanks for updating your PR! It now meets our contributing guidelines. 👍 |
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.
Issue for this PR
Closes #25746
Related: #21478, #20246, #16333, #13946
Type of change
What does this PR do?
Compaction quality regressed after #23870 — models forget context after compaction, especially in tool-heavy sessions. The root causes were hardcoded limits (2k char tool output truncation, 8k token preserve budget) and a generic system prompt that told the model to prefer "terse bullets" over detail.
Changes:
4 new config options in
opencode.jsonso users can tune compaction to their needs:compaction.tool_output_max_chars— controls how many chars of tool output the compaction model sees (was hardcoded 2000)compaction.summary_template— custom Markdown template replacing the hardcodedSUMMARY_TEMPLATEin source codecompaction.model— model override for compaction, lets you route to e.g. Opus while keeping a cheaper model for daily usecompaction.preserve_recent_tokens_max— upper bound for verbatim recent turns (default raised from 8000→32000)Compaction engine reads these config values instead of hardcoded constants. Constants renamed to
DEFAULT_*signaling they're fallbacks.Compaction system prompt rewritten to emphasize preserving exact details (error messages, file paths, identifiers, command outputs, user preferences) over terse bullets.
How did you verify your code works?
Screenshots / recordings
N/A — config + engine change, no UI.
Checklist