Skip to content

fix(compaction): adjust instructions and structure to be more clear to smaller models like dsv4 flash - #42045

Merged
rekram1-node merged 10 commits into
devfrom
compaction-fixes
Aug 12, 2026
Merged

fix(compaction): adjust instructions and structure to be more clear to smaller models like dsv4 flash#42045
rekram1-node merged 10 commits into
devfrom
compaction-fixes

Conversation

@rekram1-node

@rekram1-noderekram1-node commented Aug 12, 2026

Copy link
Copy Markdown
Collaborator

Issue for this PR

Closes#41801
Closes#41268

…o smaller models like dsv4 flash
Co-authored-by: akenra <37288280+akenra@users.noreply.github.com>
@rekram1-node
rekram1-node merged commit dab2637 into devAug 12, 2026
8 of 9 checks passed
@rekram1-node
rekram1-node deleted the compaction-fixes branch August 12, 2026 19:36
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>
Qiiks added a commit to Qiiks/opencode that referenced this pull request Aug 15, 2026
…hydration-fix
Sync 86 upstream commits (Aug 6-14) including:
- ID-wrap/chronological message ordering fixes (anomalyco#40987-anomalyco#41006) — upstream
independently fixed the same bug class as our 07889a1/21964da41;
adopted upstream versions (parentID === user.id for prompt exit, same
findIndex boundaries for revert/session, isAfter helper in latest())
- v1.18.18 release (4 releases: v1.18.15-18)
- v1 database compatibility preservation (anomalyco#42444)
- ignore unknown config fields (anomalyco#41312)
- session retry cap with jitter (anomalyco#41939)
- compaction instructions for smaller models (anomalyco#42045)
- DeepSeek V4 Flash sampling defaults (anomalyco#41620)
- Copilot PDF input support detection (anomalyco#41522)
- web search for opencode-go (anomalyco#42630)
- compaction plugin hooks (experimental.session.compacting, messages.transform)
- New models: GLM 5.3, Gemini 3.7 Flash, Grok 4.6, Zen updates
Fork-only changes preserved:
- Synthetic web search backend (synthetic flag in webSearchEnabled)
- Config npm propagation to inherited models
- Tool-result media extraction for models without attachment capability
- packageManager pin to bun 1.4.-canary.1 (Rust runtime)
Conflicts resolved: message-v2, prompt, revert, session, server-session
(adopted upstream), compaction (adopted upstream), registry + websearch
test (merged both synthetic + opencode-go).
iceteaSA added a commit to iceteaSA/opencode that referenced this pull request Aug 15, 2026
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Manual /compact with DeepSeek V4 Flash degenerates into thousands of repeated lines /compact 命令上下文丢失问题

1 participant

@rekram1-node