Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions src/config/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -575,6 +575,9 @@ export function buildGoSource(fields: {
providerOptions: {
[OPENAI_SESSION_ID_OPTION]: fields.sessionId,
[OPENCODE_SESSION_ID_OPTION]: fields.sessionId,
...(fields.reasoningEffort !== undefined
? { reasoning_effort: fields.reasoningEffort }
: {}),
},
},
};
Expand Down Expand Up @@ -642,6 +645,9 @@ export function buildZenSource(fields: {
providerOptions: {
[OPENAI_SESSION_ID_OPTION]: fields.sessionId,
[OPENCODE_SESSION_ID_OPTION]: fields.sessionId,
...(fields.reasoningEffort !== undefined
? { reasoning_effort: fields.reasoningEffort }
: {}),
},
},
};
Expand Down
60 changes: 60 additions & 0 deletions src/config/inference-sources.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -820,6 +820,66 @@ describe("reasoning effort on the wire", () => {
);
});

test("forwards reasoning effort on OpenCode Go and Zen openai-responses sources", () => {
const catalogEntries: ProviderCatalogEntry[] = [
{
name: "opencode-go",
baseURL: "https://opencode.ai/zen/go/v1",
apiKey: "sk-go",
models: ["muse-spark-1.3-contributor", "grok-4.6", "gpt-5.6-luna"],
opencodeGo: true,
},
{
name: ZEN_PROVIDER_ID,
baseURL: ZEN_DEFAULT_BASE_URL,
apiKey: "zen-key",
models: [
"muse-spark-1.3-contributor-free",
"muse-spark-1.3",
"grok-4.6",
"gpt-5.6-luna",
],
},
];
for (const [provider, models] of [
[
"opencode-go",
["muse-spark-1.3-contributor", "grok-4.6", "gpt-5.6-luna"],
],
[
ZEN_PROVIDER_ID,
[
"muse-spark-1.3-contributor-free",
"muse-spark-1.3",
"grok-4.6",
"gpt-5.6-luna",
],
],
] as const) {
for (const model of models) {
const withEffort = buildInferenceSourceForRef(
{ provider, model, reasoningEffort: "low" },
{ sessionId: "s1", catalog: catalogEntries },
undefined,
);
expect(withEffort?.provider).toBe(OPENAI_RESPONSES_PROVIDER);
expect(withEffort?.defaults?.providerOptions).toMatchObject({
reasoning_effort: "low",
});

const unset = buildInferenceSourceForRef(
{ provider, model },
{ sessionId: "s1", catalog: catalogEntries },
undefined,
);
expect(unset?.provider).toBe(OPENAI_RESPONSES_PROVIDER);
expect(unset?.defaults?.providerOptions).not.toHaveProperty(
"reasoning_effort",
);
}
}
});

test("a hand-edited first-class row does not leak the operator ladder", () => {
// The ladder override is a custom-OpenAI-compatible-provider concept. A
// first-class row (OpenCode Go here) that somehow carries reasoningEfforts
Expand Down
16 changes: 16 additions & 0 deletions src/provider/openai-responses.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,22 @@ describe("openai-responses buildRequest", () => {
) as Record<string, unknown>;
expect(body).not.toHaveProperty("prompt_cache_key");
});

test("serializes reasoning.effort from providerOptions.reasoning_effort", () => {
const body = JSON.parse(
adapter().buildRequest([userTurn("hi")], "gpt-5.6-luna", {
providerOptions: { reasoning_effort: "low" },
}).body,
) as Record<string, unknown>;
expect(body["reasoning"]).toEqual({ summary: "auto", effort: "low" });
});

test("omits reasoning.effort when providerOptions.reasoning_effort is absent", () => {
const body = JSON.parse(
adapter().buildRequest([userTurn("hi")], "gpt-5.6-luna", {}).body,
) as Record<string, unknown>;
expect(body["reasoning"]).toEqual({ summary: "auto" });
});
});

describe("openai-responses promotion cache safety", () => {
Expand Down
2 changes: 1 addition & 1 deletion src/provider/openai-responses.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export const hostQuirks: ResponsesQuirks = {
},
systemPrompt: { role: "system", shape: "string" },
contentShape: "flat",
reasoning: { summary: "auto" },
reasoning: { summary: "auto", effortOption: "reasoning_effort" },
};

export const createOpenAIResponsesAdapter: AdapterFactory =
Expand Down
Loading