fix(ai): omit copilot responses reasoning default closes #2567

This commit is contained in:
Mario Zechner
2026-03-24 20:39:11 +01:00
parent 7f04694c4d
commit bab58f821d
3 changed files with 49 additions and 1 deletions

View File

@@ -2,6 +2,10 @@
## [Unreleased]
### Fixed
- Fixed GitHub Copilot OpenAI Responses requests to omit the `reasoning` field entirely when no reasoning effort is requested, avoiding `400` errors from Copilot `gpt-5-mini` rejecting `reasoning: { effort: "none" }` during internal summary calls ([#2567](https://github.com/badlogic/pi-mono/issues/2567))
## [0.62.0] - 2026-03-23
### Added

View File

@@ -220,7 +220,7 @@ function buildParams(model: Model<"openai-responses">, context: Context, options
summary: options?.reasoningSummary || "auto",
};
params.include = ["reasoning.encrypted_content"];
} else {
} else if (model.provider !== "github-copilot") {
params.reasoning = { effort: "none" };
}
}

View File

@@ -0,0 +1,44 @@
import { afterEach, describe, expect, it, vi } from "vitest";
import { getModel } from "../src/models.js";
import { streamOpenAIResponses } from "../src/providers/openai-responses.js";
describe("openai-responses github-copilot defaults", () => {
afterEach(() => {
vi.restoreAllMocks();
});
it("omits reasoning when no reasoning is requested", async () => {
const model = getModel("github-copilot", "gpt-5-mini");
let capturedPayload: unknown;
vi.spyOn(globalThis, "fetch").mockResolvedValue(
new Response("data: [DONE]\n\n", {
status: 200,
headers: { "content-type": "text/event-stream" },
}),
);
const stream = streamOpenAIResponses(
model,
{
systemPrompt: "sys",
messages: [{ role: "user", content: "hi", timestamp: Date.now() }],
},
{
apiKey: "test-key",
onPayload: (payload) => {
capturedPayload = payload;
},
},
);
for await (const event of stream) {
if (event.type === "done" || event.type === "error") break;
}
expect(capturedPayload).not.toBeNull();
expect(capturedPayload).not.toMatchObject({
reasoning: expect.anything(),
});
});
});