[Codex effort format] - Step 3: Drop opencode's hardcoded effort list - #2768
[Codex effort format] - Step 3: Drop opencode's hardcoded effort list#2768zeroliu wants to merge 1 commit into
Conversation
`KNOWN_OPENCODE_EFFORTS` and the trailing-segment branch it gated are unreachable on every opencode version Copilot will talk to. opencode reports effort as a sibling `category:"thought_level"` config option and its model ids carry none, which `applySelection` and `prefetchEffortCatalog` already rely on; installs below `OPENCODE_MIN_ACP_VERSION` (1.16.0) resolve to `incompatible`, and both `AgentModelPreloader` and `isBackendInstalled` require `ready`, so an older binary never spawns or reports a catalog. The suffix branch is also never reached from persisted state: `opencodeEnabledModelEntries` builds its base id from the provider mapping, not `wire.decode`, whose only callers are `translateBackendState` over live agent-reported ids. Deleting it also removes the reason the vocabulary existed — with no trailing segment peeled off, an umbrella id like `openrouter/anthropic/claude-3.5-haiku` can no longer be mis-split, so nothing needs to gate against it. `encode` drops effort to match, as Claude's codec already does. Net -68 lines. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
d1f0946 to
f142ce1
Compare
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: f142ce1019
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| const opencodeWire: ModelWireCodec = { | ||
| encode: (selection: ModelSelection) => | ||
| selection.effort ? `${selection.baseModelId}/${selection.effort}` : selection.baseModelId, | ||
| encode: (selection: ModelSelection) => selection.baseModelId, |
There was a problem hiding this comment.
Align the shared wire contract with out-of-band OpenCode effort
Once encode drops effort here, the shared contract still explicitly classifies OpenCode as suffix-style (src/agentMode/session/types.ts:225-229), seedSelectionIntoState still says a later setModel carries OpenCode effort in the encoded ID (src/agentMode/session/AgentSession.ts:110-116), and designdocs/todo/subscription_models_via_agent_backends.md:128-130 still documents <provider>/<model>[/<effort>]. A maintainer extending generic model dispatch from these contract comments would use the wrong channel and silently lose effort on supported OpenCode, so these stale references should be updated with the codec change.
Useful? React with 👍 / 👎.
Fixes logancyang/obsidian-copilot-preview#271
Why
Codex's hardcoded effort list is gone from this stack's first step. opencode carries the same construct — a
KNOWN_OPENCODE_EFFORTSset ofnone · minimal · low · medium · high · xhigh · max— and it is missingultrain exactly the way Codex's was. The issue asked whether to fix it too.It needs no fixing, because it does nothing. opencode stopped putting effort in model ids: it reports plain ids like
opencode/big-pickleandopenrouter/anthropic/claude-3.5-haiku, and offers effort as a separatethought_levelselector scoped to whichever model is active. Copilot already reads it from there — that is what the effort dropdown in an opencode chat is driven by.The suffix-splitting branch that the vocabulary guards can no longer run for any opencode Copilot will talk to. Installs below 1.16.0 resolve to
incompatible, and both the model preloader and the session manager requirereadybefore spawning, so an older binary never starts and never reports a catalog. Persisted state cannot reach the branch either: enabled opencode models derive their id from the provider mapping, not from the decoder, whose only callers translate ids the running agent just reported.So the vocabulary is a list of magic strings that reads as load-bearing, sitting on a decode path where the effort branch cannot fire. The next person to hit an effort bug will find it and widen it, exactly as the issue proposed.
What
No user-visible change. Removing the branch also removes the reason the vocabulary existed: it was there to stop a model whose id legitimately ends in a third segment —
openrouter/anthropic/claude-3.5-haiku— from being mis-split into a base model plus an effort calledclaude-3.5-haiku. With no trailing segment ever peeled off, that hazard is gone rather than guarded.opencode/big-pickleopencode/big-picklethought_levelselectoropenrouter/anthropic/claude-3.5-haikuopenrouter/anthropic/claude-3.5-haikuthought_levelselectorbyok-id/lmstudio-community/Qwen2.5-7B-GGUFEncoding drops effort to match, as the Claude backend's codec already does — for opencode the model id and the effort travel as two separate calls, and only the model id was ever sent.
This is the last step in the stack, so with it the reported behavior is fully addressed: Codex effort levels come from the CLI, the settings list shows one row per base model, and neither backend keeps a list of effort names.
Non goal
thought_leveloption, still gets prefetched per enabled model, and still applies after the model switch.effortConfigForpath is untouched — it synthesizes its option from the bundled SDK catalog and has no id-suffix branch to remove.Screenshot
Not applicable — this PR deletes unreachable code and changes nothing a user sees.
Risk
Medium
opencode/descriptor.test.tscovers decoding umbrella ids whole, keeping a trailing segment that reads like an effort, provider attribution, and encode/decode round-trips; itsapplySelectionandprefetchEffortCatalogsuites still assert the two-call model-then-effort pathReview: confirm the reachability claim before the code. In
src/agentMode/backends/opencode/OpencodeBinaryManager.ts, checkisOpencodeVersionOutdatedandtoOpencodeInstallStatereturnincompatiblebelowOPENCODE_MIN_ACP_VERSION, then thatAgentModelPreloader.preloadandAgentSessionManager.isBackendInstalledboth gate onready. ConfirmopencodeEnabledModelEntriesandopencodeWireBaseIdinsrc/agentMode/backends/opencode/opencodeModelResolve.tsnever callwire.decode. Then readopencodeWireinsrc/agentMode/backends/opencode/descriptor.tsalongside itsapplySelection. Run Verification steps 2–4, including step 4's downgrade attempt.Verification
Requires opencode installed and at least one provider configured, plus a reasoning-capable model such as an Anthropic or OpenRouter one.
openrouter/anthropic/claude-3.5-haikuis one row, not several, and is not renamed.