fix(copilot): mark internal background notifications as agent-initiated

This commit is contained in:
Maxim Harizanov
2026-02-18 19:55:36 +02:00
parent 11d41d3bdd
commit dcfe72e989
7 changed files with 179 additions and 4 deletions
+72
View File
@@ -0,0 +1,72 @@
import { describe, expect, test } from "bun:test"
import { OMO_INTERNAL_INITIATOR_MARKER } from "../shared"
import { createChatHeadersHandler } from "./chat-headers"
describe("createChatHeadersHandler", () => {
test("sets x-initiator=agent for Copilot internal synthetic marker messages", async () => {
const handler = createChatHeadersHandler()
const output: { headers: Record<string, string> } = { headers: {} }
await handler(
{
provider: { id: "github-copilot" },
message: {
info: { role: "user" },
parts: [
{
type: "text",
text: `notification\n${OMO_INTERNAL_INITIATOR_MARKER}`,
synthetic: true,
},
],
},
},
output,
)
expect(output.headers["x-initiator"]).toBe("agent")
})
test("does not override non-copilot providers", async () => {
const handler = createChatHeadersHandler()
const output: { headers: Record<string, string> } = { headers: {} }
await handler(
{
provider: { id: "openai" },
message: {
info: { role: "user" },
parts: [
{
type: "text",
text: `notification\n${OMO_INTERNAL_INITIATOR_MARKER}`,
synthetic: true,
},
],
},
},
output,
)
expect(output.headers["x-initiator"]).toBeUndefined()
})
test("does not override regular user messages", async () => {
const handler = createChatHeadersHandler()
const output: { headers: Record<string, string> } = { headers: {} }
await handler(
{
provider: { id: "github-copilot" },
message: {
info: { role: "user" },
parts: [{ type: "text", text: "normal user message" }],
},
},
output,
)
expect(output.headers["x-initiator"]).toBeUndefined()
})
})