Conversation
The session.compacted handler passed agent but not model/variant when injecting restored memories. OpenCode resolves the model as input.model ?? agent.model ?? session.model, so an agent with its own model took over the session after each compaction. Read the session's current model from session.get() and pass model and variant with the injection. A "default" variant is omitted, matching OpenCode's own normalization.
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.
Fixes #325
Summary
The
session.compactedhandler passesagent(#236) but notmodel/variantwhen it injects restored memories. OpenCode resolvesinput.model ?? agent.model ?? session.model, so an agent that declares its own model takes over the session after every compaction.This adds
resolveSessionModel(), which reads the session's current model fromsession.get()(compaction does not change it), and passesmodelandvariantalongsideagent. A"default"variant is omitted, matching OpenCode's own normalization. When the model cannot be resolved, the injection behaves as before.The OpenCode v2 compatibility client turns
noReplyprompts intoctx.session.synthetic(...), which does not go through model resolution, so that path is unaffected.Testing
resolveSessionModeland two compaction scenarios (model passed through / left unset) intests/compaction-agent-preservation.test.ts.bun run typecheck,bun run lintandbun run format:checkpass.bun test: 465 pass, 11 fail. The same 11 fail onmain(460 pass); they inspect the builtdist/bundle and needbun run buildfirst.max, real auto-capture, thenPOST /session/:id/summarize. The injected message carried the session's model and variant, andsession.modelwas unchanged. The same request withoutmodel(current behaviour) was recorded with the agent's model.