Skip to content

Commit 6fe6ced

Browse files
committed
fix(opencode): show Reasoning selector for OpenCode models
OpenCode previously exposed its reasoning effort as a 'Variant' option and only when a model advertised variants. Models without variants (including custom models and several first-party providers) showed only the Agent chip, leaving the composer with no reasoning control while Codex/Grok/Cursor all offer one. Add a Reasoning descriptor for all OpenCode models: keep the stored 'id' as 'variant' for compatibility but label it 'Reasoning', and synthesize standard levels (low/medium/high/xhigh) when a model advertises no variants so the TraitsPicker always has a primary select to render. Provide the same fallback capabilities for custom models and update the saved-option label for unavailable models. This restores parity with other providers and makes the selected effort visible in the composer footer (e.g. 'Medium · Build').
1 parent c742edd commit 6fe6ced

2 files changed

Lines changed: 36 additions & 4 deletions

File tree

‎apps/server/src/provider/Layers/OpenCodeProvider.ts‎

Lines changed: 35 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -171,15 +171,47 @@ function inferDefaultAgent(agents: ReadonlyArray<Agent>): string | undefined {
171171
}
172172

173173
const DEFAULT_OPENCODE_MODEL_CAPABILITIES: ModelCapabilities = createModelCapabilities({
174-
optionDescriptors: [],
174+
optionDescriptors: [
175+
{
176+
id: "variant",
177+
label: "Reasoning",
178+
type: "select",
179+
options: [
180+
{ id: "low", label: "Low" },
181+
{ id: "medium", label: "Medium", isDefault: true },
182+
{ id: "high", label: "High" },
183+
{ id: "xhigh", label: "Extra High" },
184+
],
185+
currentValue: "medium",
186+
},
187+
{
188+
id: "agent",
189+
label: "Agent",
190+
type: "select",
191+
options: [
192+
{ id: "build", label: "Build", isDefault: true },
193+
{ id: "plan", label: "Plan" },
194+
],
195+
currentValue: "build",
196+
},
197+
],
175198
});
176199

177200
function openCodeCapabilitiesForModel(input: {
178201
readonly providerID: string;
179202
readonly model: ProviderListResponse["all"][number]["models"][string];
180203
readonly agents: ReadonlyArray<Agent>;
181204
}): ModelCapabilities {
182-
const variantValues = Object.keys(input.model.variants ?? {});
205+
const rawVariantValues = Object.keys(input.model.variants ?? {});
206+
// When a model advertises no variants, synthesize the standard reasoning
207+
// levels so the composer still offers a Reasoning selector (mirrors the
208+
// Codex/Grok experience where reasoning is always configurable). The set
209+
// covers the common OpenCode variant spectrum; `inferDefaultVariant`
210+
// picks the provider-appropriate default (e.g. medium for openai/opencode).
211+
const variantValues =
212+
rawVariantValues.length > 0
213+
? rawVariantValues
214+
: ["low", "medium", "high", "xhigh"];
183215
const defaultVariant = inferDefaultVariant(input.providerID, variantValues);
184216
const variantOptions = variantValues.map((value) =>
185217
defaultVariant === value
@@ -201,7 +233,7 @@ function openCodeCapabilitiesForModel(input: {
201233
? [
202234
{
203235
id: "variant",
204-
label: "Variant",
236+
label: "Reasoning",
205237
type: "select" as const,
206238
options: variantOptions,
207239
...(defaultVariant ? { currentValue: defaultVariant } : {}),

‎apps/web/src/components/chat/TraitsPicker.tsx‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ const SAVED_OPTION_LABELS: Readonly<Record<string, string>> = {
4040
agent: "Agent",
4141
effort: "Effort",
4242
reasoningEffort: "Reasoning effort",
43-
variant: "Variant",
43+
variant: "Reasoning",
4444
};
4545

4646
function savedOptionLabel(id: string): string {

0 commit comments

Comments
 (0)