Skip to content

Commit 54504a2

Browse files
committed
test(api): cover the streaming-path prompt_cache_key omission
What: add a createMessage-level test asserting that the Responses request body carries no prompt_cache_key when no metadata is supplied. Why: the omission was only pinned through the private buildRequestBody and through completePrompt, which builds its own body inline and never reaches buildRequestBody. A fallback task id introduced on the streaming path (createMessage -> handleResponsesApiMessage -> buildRequestBody) would have passed both. The new test fails on exactly that mutant. Impact: test-only, +13 lines, no production change. Stryker's changed-line budget excludes __tests__, so the 12/500 gate figure is unchanged.
1 parent 7011fec commit 54504a2

1 file changed

Lines changed: 13 additions & 0 deletions

File tree

‎src/api/providers/__tests__/openai-native.spec.ts‎

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1523,6 +1523,19 @@ describe("OpenAiNativeHandler", () => {
15231523
expect(mockResponsesCreate.mock.calls[0][1].headers).not.toHaveProperty("session_id")
15241524
})
15251525

1526+
it("omits the prompt_cache_key through createMessage when no metadata is supplied", async () => {
1527+
mockResponsesCreate.mockResolvedValue(asyncStreamFrom([]))
1528+
1529+
const cacheHandler = new OpenAiNativeHandler({ ...mockOptions, apiModelId: "gpt-5.1" })
1530+
1531+
// No metadata at all: the streaming entry point must not synthesize a fallback
1532+
// task id, or the field would replace OpenAI's default routing for no affinity.
1533+
await collectStream(cacheHandler.createMessage(systemPrompt, messages))
1534+
1535+
const [body] = mockResponsesCreate.mock.calls[0]
1536+
expect(body).not.toHaveProperty("prompt_cache_key")
1537+
})
1538+
15261539
it("should provide helpful error messages for different error codes", async () => {
15271540
const testCases = [
15281541
{ status: 400, expectedMessage: "Invalid request to Responses API" },

0 commit comments

Comments
 (0)