fix(compaction): adjust instructions and structure to be more clear to smaller models like dsv4 flash - #42045
Merged
Conversation
…o smaller models like dsv4 flash Co-authored-by: akenra <37288280+akenra@users.noreply.github.com>
rekram1-node
force-pushed
the
compaction-fixes
branch
from
August 12, 2026 14:55
1eaba4f to
aac66da
Compare
6 tasks
6 tasks
sepo-eng
added a commit
to Draugur-AI/opencode
that referenced
this pull request
Aug 13, 2026
…#58) Hand-merged from anomalyco/opencode@dab2637217 ("fix(compaction): adjust instructions and structure to be more clear to smaller models like dsv4 flash", anomalyco#42045). Their patch didn't cherry-pick cleanly -- it conflicts with TKT-379 (the compaction summary must NOT hide that context was compacted; hiding it measurably drops history_search's call rate from 100% to 20%) and with our own splitPrefix/splitSuffix/ retainedCount extension to select(). Reapplied by hand, taking the genuinely good parts and explicitly not the rest: TAKEN: - New SUMMARY_UPDATE_INSTRUCTIONS block: explicit guidance for combining a <prior-summary> with new <conversation> content (carry forward objectives/constraints/decisions, conversation wins on conflict, move Active->Completed, update Objective/Next Move). - buildPrompt() restructured to wrap the actual conversation content in explicit <conversation> tags up front, before the instructions, instead of spreading context items loose at the end of the prompt array. This is the actual "clearer to smaller models" improvement. - Tag renamed <previous-summary> -> <prior-summary> to match. Fixed every place that tag name is asserted or referenced, including in the SECOND compaction pipeline (packages/opencode/src/session/ compaction.ts) that turns out to share this same buildPrompt() -- and its own agent system prompt (packages/core/src/plugin/agent.ts PROMPT_COMPACTION / packages/opencode/src/agent/prompt/ compaction.txt), which told the model to look for the old tag name. NOT TAKEN, deliberately (Sean: "don't take their side"): - Upstream's version of this same instruction says "Do not mention the summary process or that context was compacted" -- the exact opposite of TKT-379's fix. Kept our version unchanged. Added a test pinning this so a future upstream sync can't silently reintroduce it via a cleaner-looking cherry-pick. - Upstream's select() also drops splitPrefix/splitSuffix (character- level splitting of a message straddling the retention boundary) in favor of whole-message-only slicing. Our fork extended that same logic with retainedCount (feeds SessionEvent.Compaction.Ended.retainedTailMessages) -- left entirely untouched. NOT TOUCHED, flagged to feedback instead (anomalyco#227): PROMPT_COMPACTION's own "do not mention... compacting" sentence (a second, separate instance of the same class of bug TKT-379 fixed) and the packages/core/src/v1/config/config.ts tail_turns docstring clarity change -- both belong to the second compaction pipeline, whose liveness relative to the first is TKT-377's still-open question, not something to resolve as a side effect of this hand-merge. Co-authored-by: opencode <bot@opencode.ai> Co-authored-by: Claude <noreply@anthropic.com>
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 #41801
Closes #41268