feat: opencodeModel: "inherit" — capture with the session's own model#151
Open
anagnorisis2peripeteia wants to merge 1 commit into
Open
Conversation
When opencodeModel is set to "inherit", auto-capture resolves the provider/model that opencode actually used for the captured prompt (recorded per message via the chat.params hook and stored on the user_prompts row), instead of a pinned model id. Pinned ids can go stale when providers rename models, silently breaking capture; inherit also means multi-model users capture each conversation with the model that produced it.
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.
Motivation
Pinned
opencodeModelids rot: when a provider renames a model (or a local endpoint changes its served model id), auto-capture silently fails atsession.createon every prompt until someone notices the log spam. That is how I found this — capture had been broken for days on a stale local-model id. Separately, users who switch models during the day may prefer each conversation to be captured by the model that actually produced it.What this does
"opencodeModel": "inherit"makes auto-capture use the exact provider/model opencode resolved for the captured prompt:chat.paramshook recordsinput.model.providerID/input.model.idonto the prompt's existinguser_promptsrow (two new nullable columns, added with the same duplicate-column-guardedALTER TABLEpattern ascapture_attempts), keyed bymessage.id— the same key capture already uses, so the mapping is exact rather than inferred from transcript position;"inherit"resolves provider/model from the stored row; the existingisProviderConnectedguard runs against the resolved provider;chat.params), capture throws and the existing retry/cap machinery handles it — it never guesses.Pinned configuration behaves exactly as before; the hook returns immediately unless
"inherit"is configured.Notes for review
opencodeProvidermust still be set (the existingopencodeProvider && opencodeModelgate is untouched for diff minimality); with"inherit"its value is only used as a gate. Happy to change the gate if you prefer.chat.paramsfiring reliably for models served through the standard providers, but not for every custom npm-provider path — the hard-error fallback covers those prompts. Worth knowing for docs/support.Testing
tsc --noEmitand Prettier clean; migration verified against an existing populateduser-prompts.db(old rows read back withnullmodel fields).provider_id/model_idcorrectly on their prompt rows, and capture consumed the recorded model (verified via capture-session behavior/logs).