feat(ai): route copilot claude via anthropic messages api

This commit is contained in:
Nate Smyth 2026-02-06 05:09:52 -05:00 committed by Mario Zechner
parent cf1353b8e7
commit 0a132a30a1
9 changed files with 196 additions and 76 deletions

View file

@ -40,7 +40,7 @@ describe("Anthropic Copilot auth config", () => {
});
expect(options.apiKey).toBeNull();
expect(options.defaultHeaders?.["Authorization"]).toBe(`Bearer ${token}`);
expect(options.defaultHeaders?.Authorization).toBe(`Bearer ${token}`);
});
it("includes Copilot static headers from model.headers", () => {

View file

@ -28,7 +28,7 @@ describe("Copilot Claude model routing", () => {
it("does not have compat block on Claude models (completions-API-specific)", () => {
const sonnet = getModel("github-copilot", "claude-sonnet-4");
expect((sonnet as any).compat).toBeUndefined();
expect("compat" in sonnet).toBe(false);
});
it("preserves static Copilot headers on Claude models", () => {

View file

@ -75,6 +75,17 @@ describe("inferCopilotInitiator", () => {
];
expect(inferCopilotInitiator(messages)).toBe("agent");
});
it("returns 'agent' for any non-user role (e.g. 'tool' in OpenAI format)", () => {
const messages: unknown[] = [
{
role: "tool",
tool_call_id: "call_abc123",
content: "tool output",
},
];
expect(inferCopilotInitiator(messages)).toBe("agent");
});
});
describe("hasCopilotVisionInput", () => {