The best way to control Claude Code, Codex and more from any computer or phone
fix(opencode): OpenCode Go threads no longer fail on a reasoning level the model lacks (#35432)
Julius Marminge committed
Nov 12, 2026 at 10:01 UTC
662a1ce6e27c0384ac8a12b7b0c435285ace56e7
4 files changed
+55
-10
apps/server/src/orchestration-v2/Adapters/OpenCode2AdapterV2.test.ts
+15
@@ -496,6 +496,21 @@ it.layer(McpProviderSessions.layer)("OpenCode2 adapter", (it) => {
496
}).pipe(Effect.scoped),
497
);
498
499
+ it.effect("never sends a saved variant the catalog model does not list", () =>
500
+ Effect.gen(function* () {
501
+ const { runtime, thread } = yield* resumed([
502
+ out("session.prompt", { sessionID: SESSION, text: "<any>" }),
503
+ promptAccepted,
504
+ event("session.execution.succeeded", { sessionID: SESSION }),
505
+ ]);
506
+ const terminal = yield* terminalOf(runtime).pipe(Effect.forkScoped);
507
+ yield* runtime.startTurn(
508
+ turnInput(thread, { ...bigPickle, options: [{ id: "variant", value: "medium" }] }),
509
+ );
510
+ assert.equal((yield* Fiber.join(terminal))?.status, "completed");
511
+ }).pipe(Effect.scoped),
512
+ );
513
+
514
it.effect("renames the session before the first turn after the thread was renamed", () =>
515
Effect.gen(function* () {
516
const { runtime, thread } = yield* resumed([
packages/provider-opencode/src/server/status.test.ts
+19
-1
@@ -850,6 +850,12 @@ it.layer(layerTest)("checkOpenCodeProviderStatus", (it) => {
850
name: "Space Bunny Free",
851
variants: [{ id: "low" }, { id: "medium" }, { id: "high" }],
852
},
853
+ {
854
+ providerID: "opencode-go",
855
+ id: "deepseek-v4.1-flash",
856
+ name: "DeepSeek V4.1 Flash",
857
+ variants: [{ id: "low" }, { id: "high" }, { id: "max" }],
858
+ },
859
]),
860
);
861
@@ -869,7 +875,7 @@ it.layer(layerTest)("checkOpenCodeProviderStatus", (it) => {
875
);
876
NodeAssert.deepEqual(
877
snapshot.models.map((model) => model.slug),
872
- ["opencode/big-pickle", "opencode/space-bunny-free"],
878
+ ["opencode/big-pickle", "opencode-go/deepseek-v4.1-flash", "opencode/space-bunny-free"],
879
);
880
const variant = snapshot.models.find((model) => model.slug === "opencode/space-bunny-free")
881
?.capabilities?.optionDescriptors?.[0];
@@ -877,6 +883,18 @@ it.layer(layerTest)("checkOpenCodeProviderStatus", (it) => {
883
variant?.type === "select" ? variant.options.map((option) => option.id) : [],
884
["low", "medium", "high"],
885
);
886
+ const goVariant = snapshot.models.find(
887
+ (model) => model.slug === "opencode-go/deepseek-v4.1-flash",
888
+ )?.capabilities?.optionDescriptors?.[0];
889
+ const goVariantIds =
890
+ goVariant?.type === "select" ? goVariant.options.map((option) => option.id) : [];
891
+ NodeAssert.deepEqual(goVariantIds, ["low", "high", "max"]);
892
+ NodeAssert.ok(
893
+ goVariant?.type === "select" &&
894
+ goVariant.currentValue !== undefined &&
895
+ goVariantIds.includes(goVariant.currentValue),
896
+ "an OpenCode Go model gets a default reasoning variant it lists",
897
+ );
898
NodeAssert.equal(runtimeMock.state.sdkClientInputs.length, 0);
899
}),
900
);
packages/provider-opencode/src/server/status.ts
+1
-1
@@ -193,7 +193,7 @@ function inferDefaultVariant(
193
if (providerID === "anthropic" || providerID.startsWith("google")) {
194
return variants.includes("high") ? "high" : undefined;
195
}
196
- if (providerID === "openai" || providerID === "opencode") {
196
+ if (providerID === "openai" || providerID === "opencode" || providerID === "opencode-go") {
197
return variants.includes("medium") ? "medium" : variants.includes("high") ? "high" : undefined;
198
}
199
return undefined;
packages/provider-opencode/src/server/v2/adapter.ts
+20
-8
@@ -660,10 +660,18 @@ const boundaryAfter = (
660
661
const isProviderAdapterError = Schema.is(ProviderAdapter.ProviderAdapterV2Error);
662
663
-const modelRef = (selection: ProviderAdapter.ProviderAdapterV2TurnInput["modelSelection"]) => {
663
+// A saved or inherited variant the catalog model does not list makes OpenCode reject the turn.
664
+const modelRef = (
665
+ selection: ProviderAdapter.ProviderAdapterV2TurnInput["modelSelection"],
666
+ listedVariants: ReadonlySet<string> | undefined,
667
+) => {
668
const parsed = OpenCodeRuntime.parseOpenCodeModelSlug(selection.model);
669
if (parsed === null) return undefined;
666
- const variant = getModelSelectionStringOptionValue(selection, "variant");
670
+ const selected = getModelSelectionStringOptionValue(selection, "variant");
671
+ const variant =
672
+ selected === undefined || listedVariants === undefined || listedVariants.has(selected)
673
+ ? selected
674
+ : undefined;
675
return Model.Ref.make({
676
providerID: Provider.ID.make(parsed.providerID),
677
id: Model.ID.make(parsed.modelID),
@@ -765,9 +773,12 @@ export const make = Effect.fn("OpenCode2Adapter.make")(function* (instanceId: Pr
773
const sessionScope = yield* Effect.scope;
774
// Project config changes model limits; key by directory because this runtime serves all instance threads.
775
const contextWindows = new Map<string, Map<string, number>>();
776
+ const modelVariants = new Map<string, Map<string, ReadonlySet<string>>>();
777
const directoryOf = (cwd: string | null | undefined) => cwd ?? host.paths.cwd;
778
const windowOf = (cwd: string | null | undefined, model: string) =>
779
contextWindows.get(directoryOf(cwd))?.get(model);
780
+ const listedModelRef = (selection: ModelSelection, cwd: string | null | undefined) =>
781
+ modelRef(selection, modelVariants.get(directoryOf(cwd))?.get(selection.model));
782
const now = yield* DateTime.now;
783
let session: OrchestrationV2ProviderSession = {
784
id: input.providerSessionId,
@@ -3699,15 +3710,16 @@ export const make = Effect.fn("OpenCode2Adapter.make")(function* (instanceId: Pr
3710
Effect.suspend(() => {
3711
const windows = contextWindows.get(directory) ?? new Map<string, number>();
3712
contextWindows.set(directory, windows);
3713
+ const variants = modelVariants.get(directory) ?? new Map<string, ReadonlySet<string>>();
3714
+ modelVariants.set(directory, variants);
3715
return client.model.list({ location: { directory } }).pipe(
3716
Effect.timeout("5 seconds"),
3717
Effect.tap((models) =>
3718
Effect.sync(() => {
3719
for (const model of models.data) {
3707
- windows.set(
3708
- `${model.providerID}/${model.id}`,
3709
- model.limit.input ?? model.limit.context,
3710
- );
3720
+ const slug = `${model.providerID}/${model.id}`;
3721
+ windows.set(slug, model.limit.input ?? model.limit.context);
3722
+ variants.set(slug, new Set(model.variants.map((variant) => variant.id)));
3723
}
3724
}),
3725
),
@@ -4434,7 +4446,7 @@ export const make = Effect.fn("OpenCode2Adapter.make")(function* (instanceId: Pr
4446
});
4447
}
4448
yield* readModelsOnce(threadInput.runtimePolicy.cwd);
4437
- const model = modelRef(threadInput.modelSelection);
4449
+ const model = listedModelRef(threadInput.modelSelection, threadInput.runtimePolicy.cwd);
4450
if (model === undefined) {
4451
return yield* new ProviderAdapter.ProviderAdapterProtocolError({
4452
driver: OPENCODE_PROVIDER,
@@ -4611,7 +4623,7 @@ export const make = Effect.fn("OpenCode2Adapter.make")(function* (instanceId: Pr
4623
}),
4624
});
4625
}
4614
- const model = modelRef(turnInput.modelSelection);
4626
+ const model = listedModelRef(turnInput.modelSelection, turnInput.runtimePolicy.cwd);
4627
if (model === undefined) {
4628
yield* begin;
4629
return yield* finishTurn(state, {