fix(provider): pin per-model default params on subagent turns#71
Merged
Conversation
Subagents inherit the primary agent's model but reach the provider with the model's opencode options.params dropped, so Cursor's server-side `fast: true` default silently applied (e.g. composer-2.5 ran "fast" in subagent calls). Thread each discovered model's defaultModelParams through provider options (a per-provider channel that survives opencode's subagent param-drop) and re-apply them as a lowest-precedence floor in resolveControls, so `fast: "false"` holds even when per-request params are absent. Explicit variant/static params still win. Add an OPENCODE_CURSOR_DEBUG log of the resolved modelSelection to confirm per-turn behavior.
Collapse the repeated subagent/fast rationale to a single home (the plugin config hook where the map originates); reduce the type-field docstrings to one-liners and drop the self-evident debug-log comment.
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.
Problem
Subagents that don't set their own
modelinherit the invoking primary agent's model (per opencode's documented resolution). When that model is a Cursor model likecomposer-2.5, the subagent turn reaches the provider with the model's opencodeoptions.paramsdropped, soresolveControlsproduced a bare{ id: "composer-2.5" }with nofastparam — and Cursor's server-sidefast: truedefault silently applied. Result: subagents ran "composer-2.5 fast" even though the plugin pinsfastoff on the normal chat path.The model choice itself (inheritance) is correct/expected. The bug was only the
fastleak on the inherited path.Fix
resolveControlsfloor (controls.ts):StaticControls.defaultsapplied under static params and per-request options (defaults < params < per-request). On the subagent path (params dropped) the floor re-appliesfast: "false"; an explicitfastvariant or static param still wins.plugin/index.ts→provider/index.ts→language-model.ts): theconfighook builds amodelId → defaultModelParamsmap from the discovered catalog (reusing existingdefaultModelParams) and injects it into provider options — a per-provider channel that survives opencode's subagent param-drop. The provider passes it as thedefaultsfloor for the current model.OPENCODE_CURSOR_DEBUG=1now logs the resolvedmodelSelectionper turn, so the leak (and its fix) is observable.Verification
npm test→ 306 passed (27 files), including:resolveControlscases: floor applies when no params; per-request and static params override the floor;language-modeltest: a params-less turn sendsAgent.create{ id: "composer-2.5", params: [{ id: "fast", value: "false" }] }.npm run build(tsup) → clean.tsc --noEmit: no errors in changed files. (Pre-existing@types/semvererrors inversion-check.*are unrelated and reproduce onmain.)Notes
options.paramsthere, so re-applying the floor is a no-op).