Skip to content

Commit 1494c22

Browse files
Bulat Yapparovclaude
andcommitted
test: cover each reasoning effort spelling alone; document precedence
Co-Authored-By: Claude Fable 5 <[email protected]>
1 parent 136a280 commit 1494c22

2 files changed

Lines changed: 63 additions & 1 deletion

File tree

‎packages/cli/src/provider/sdk/copilot/chat/openai-compatible-chat-options.ts‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,13 @@ export const openaiCompatibleProviderOptions = z.object({
1111

1212
/**
1313
* Reasoning effort for reasoning models. Defaults to `medium`.
14+
* Alias of `reasoning_effort`; ignored when both are set.
1415
*/
1516
reasoningEffort: z.string().optional(),
1617

1718
/**
18-
* OpenAI-compatible reasoning effort request field.
19+
* OpenAI-compatible reasoning effort request field (wire name).
20+
* Takes precedence over `reasoningEffort` when both are set.
1921
*/
2022
reasoning_effort: z.string().optional(),
2123

‎packages/cli/test/provider/copilot/copilot-chat-model.test.ts‎

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -620,4 +620,64 @@ describe("request body", () => {
620620

621621
expect((capturedBody as { reasoning_effort?: string }).reasoning_effort).toBe("none")
622622
})
623+
624+
test("should pass reasoning_effort when set alone", async () => {
625+
let capturedBody: unknown
626+
const mockFetch = mock(async (_url: string, init?: RequestInit) => {
627+
capturedBody = JSON.parse(init?.body as string)
628+
return new Response(
629+
new ReadableStream({
630+
start(controller) {
631+
controller.enqueue(new TextEncoder().encode(`data: [DONE]\n\n`))
632+
controller.close()
633+
},
634+
}),
635+
{ status: 200, headers: { "Content-Type": "text/event-stream" } },
636+
)
637+
})
638+
639+
const model = createModel(mockFetch)
640+
641+
await model.doStream({
642+
prompt: TEST_PROMPT,
643+
providerOptions: {
644+
copilot: {
645+
reasoning_effort: "none",
646+
},
647+
},
648+
includeRawChunks: false,
649+
})
650+
651+
expect((capturedBody as { reasoning_effort?: string }).reasoning_effort).toBe("none")
652+
})
653+
654+
test("should fall back to camelCase reasoningEffort when snake_case is absent", async () => {
655+
let capturedBody: unknown
656+
const mockFetch = mock(async (_url: string, init?: RequestInit) => {
657+
capturedBody = JSON.parse(init?.body as string)
658+
return new Response(
659+
new ReadableStream({
660+
start(controller) {
661+
controller.enqueue(new TextEncoder().encode(`data: [DONE]\n\n`))
662+
controller.close()
663+
},
664+
}),
665+
{ status: 200, headers: { "Content-Type": "text/event-stream" } },
666+
)
667+
})
668+
669+
const model = createModel(mockFetch)
670+
671+
await model.doStream({
672+
prompt: TEST_PROMPT,
673+
providerOptions: {
674+
copilot: {
675+
reasoningEffort: "high",
676+
},
677+
},
678+
includeRawChunks: false,
679+
})
680+
681+
expect((capturedBody as { reasoning_effort?: string }).reasoning_effort).toBe("high")
682+
})
623683
})

0 commit comments

Comments
 (0)