fix(chat-headers): skip x-initiator override for @ai-sdk/github-copilot models
OpenCode's copilot fetch wrapper already sets x-initiator based on the actual HTTP request body content. When oh-my-opencode's chat.headers hook overrides it with 'agent', the Copilot API detects a mismatch between the header and the request body and rejects the request with 'invalid initiator'. This matches the approach OpenCode's own chat.headers handler uses (copilot.ts:314) — it explicitly skips @ai-sdk/github-copilot models because the fetch wrapper handles x-initiator correctly on its own.
This commit is contained in:
@@ -106,4 +106,41 @@ describe("createChatHeadersHandler", () => {
|
||||
|
||||
expect(output.headers["x-initiator"]).toBeUndefined()
|
||||
})
|
||||
|
||||
test("skips x-initiator override when model uses @ai-sdk/github-copilot", async () => {
|
||||
const handler = createChatHeadersHandler({
|
||||
ctx: {
|
||||
client: {
|
||||
session: {
|
||||
message: async () => ({
|
||||
data: {
|
||||
parts: [
|
||||
{
|
||||
type: "text",
|
||||
text: `notification\n${OMO_INTERNAL_INITIATOR_MARKER}`,
|
||||
},
|
||||
],
|
||||
},
|
||||
}),
|
||||
},
|
||||
},
|
||||
} as never,
|
||||
})
|
||||
const output: { headers: Record<string, string> } = { headers: {} }
|
||||
|
||||
await handler(
|
||||
{
|
||||
sessionID: "ses_4",
|
||||
provider: { id: "github-copilot" },
|
||||
model: { api: { npm: "@ai-sdk/github-copilot" } },
|
||||
message: {
|
||||
id: "msg_4",
|
||||
role: "user",
|
||||
},
|
||||
},
|
||||
output,
|
||||
)
|
||||
|
||||
expect(output.headers["x-initiator"]).toBeUndefined()
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user