Skip to content

Commit 5c675ca

Browse files
Merge pull request #1555 from corbitsdev/cl-11323-wire-reasoningeffort-through-opencode-go-and-zen-openai
fix(provider): wire reasoningEffort through OpenCode Go and Zen responses
2 parents 5a62b38 + 7fd2bbe commit 5c675ca

4 files changed

Lines changed: 83 additions & 1 deletion

File tree

‎src/config/index.ts‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -575,6 +575,9 @@ export function buildGoSource(fields: {
575575
providerOptions: {
576576
[OPENAI_SESSION_ID_OPTION]: fields.sessionId,
577577
[OPENCODE_SESSION_ID_OPTION]: fields.sessionId,
578+
...(fields.reasoningEffort !== undefined
579+
? { reasoning_effort: fields.reasoningEffort }
580+
: {}),
578581
},
579582
},
580583
};
@@ -642,6 +645,9 @@ export function buildZenSource(fields: {
642645
providerOptions: {
643646
[OPENAI_SESSION_ID_OPTION]: fields.sessionId,
644647
[OPENCODE_SESSION_ID_OPTION]: fields.sessionId,
648+
...(fields.reasoningEffort !== undefined
649+
? { reasoning_effort: fields.reasoningEffort }
650+
: {}),
645651
},
646652
},
647653
};

‎src/config/inference-sources.test.ts‎

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -820,6 +820,66 @@ describe("reasoning effort on the wire", () => {
820820
);
821821
});
822822

823+
test("forwards reasoning effort on OpenCode Go and Zen openai-responses sources", () => {
824+
const catalogEntries: ProviderCatalogEntry[] = [
825+
{
826+
name: "opencode-go",
827+
baseURL: "https://opencode.ai/zen/go/v1",
828+
apiKey: "sk-go",
829+
models: ["muse-spark-1.3-contributor", "grok-4.6", "gpt-5.6-luna"],
830+
opencodeGo: true,
831+
},
832+
{
833+
name: ZEN_PROVIDER_ID,
834+
baseURL: ZEN_DEFAULT_BASE_URL,
835+
apiKey: "zen-key",
836+
models: [
837+
"muse-spark-1.3-contributor-free",
838+
"muse-spark-1.3",
839+
"grok-4.6",
840+
"gpt-5.6-luna",
841+
],
842+
},
843+
];
844+
for (const [provider, models] of [
845+
[
846+
"opencode-go",
847+
["muse-spark-1.3-contributor", "grok-4.6", "gpt-5.6-luna"],
848+
],
849+
[
850+
ZEN_PROVIDER_ID,
851+
[
852+
"muse-spark-1.3-contributor-free",
853+
"muse-spark-1.3",
854+
"grok-4.6",
855+
"gpt-5.6-luna",
856+
],
857+
],
858+
] as const) {
859+
for (const model of models) {
860+
const withEffort = buildInferenceSourceForRef(
861+
{ provider, model, reasoningEffort: "low" },
862+
{ sessionId: "s1", catalog: catalogEntries },
863+
undefined,
864+
);
865+
expect(withEffort?.provider).toBe(OPENAI_RESPONSES_PROVIDER);
866+
expect(withEffort?.defaults?.providerOptions).toMatchObject({
867+
reasoning_effort: "low",
868+
});
869+
870+
const unset = buildInferenceSourceForRef(
871+
{ provider, model },
872+
{ sessionId: "s1", catalog: catalogEntries },
873+
undefined,
874+
);
875+
expect(unset?.provider).toBe(OPENAI_RESPONSES_PROVIDER);
876+
expect(unset?.defaults?.providerOptions).not.toHaveProperty(
877+
"reasoning_effort",
878+
);
879+
}
880+
}
881+
});
882+
823883
test("a hand-edited first-class row does not leak the operator ladder", () => {
824884
// The ladder override is a custom-OpenAI-compatible-provider concept. A
825885
// first-class row (OpenCode Go here) that somehow carries reasoningEfforts

‎src/provider/openai-responses.test.ts‎

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,22 @@ describe("openai-responses buildRequest", () => {
7070
) as Record<string, unknown>;
7171
expect(body).not.toHaveProperty("prompt_cache_key");
7272
});
73+
74+
test("serializes reasoning.effort from providerOptions.reasoning_effort", () => {
75+
const body = JSON.parse(
76+
adapter().buildRequest([userTurn("hi")], "gpt-5.6-luna", {
77+
providerOptions: { reasoning_effort: "low" },
78+
}).body,
79+
) as Record<string, unknown>;
80+
expect(body["reasoning"]).toEqual({ summary: "auto", effort: "low" });
81+
});
82+
83+
test("omits reasoning.effort when providerOptions.reasoning_effort is absent", () => {
84+
const body = JSON.parse(
85+
adapter().buildRequest([userTurn("hi")], "gpt-5.6-luna", {}).body,
86+
) as Record<string, unknown>;
87+
expect(body["reasoning"]).toEqual({ summary: "auto" });
88+
});
7389
});
7490

7591
describe("openai-responses promotion cache safety", () => {

‎src/provider/openai-responses.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ export const hostQuirks: ResponsesQuirks = {
2222
},
2323
systemPrompt: { role: "system", shape: "string" },
2424
contentShape: "flat",
25-
reasoning: { summary: "auto" },
25+
reasoning: { summary: "auto", effortOption: "reasoning_effort" },
2626
};
2727

2828
const baseFactory = responsesAdapterFactory(hostQuirks);

0 commit comments

Comments
 (0)