Skip to content

Commit 9ec54ae

Browse files
committed
refactor: improve X-Initiator agent detection logic
Extends agent detection to use pattern matching for better coverage of AI assistant models
1 parent c30a590 commit 9ec54ae

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/services/copilot/create-chat-completions.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,13 @@ export const createChatCompletions = async (
2222
["assistant", "tool"].includes(msg.role),
2323
)
2424

25-
// Check if model is claude-sonnet-4.5 (should also be treated as agent)
26-
const isClaudeSonnet45 = payload.model === "claude-sonnet-4.5"
25+
// Check if model starts with "claude-" (should also be treated as agent)
26+
const isClaudeModel = payload.model.startsWith("claude-")
2727

2828
// Build headers and add X-Initiator
2929
const headers: Record<string, string> = {
3030
...copilotHeaders(state, enableVision),
31-
"X-Initiator": isAgentCall || isClaudeSonnet45 ? "agent" : "user",
31+
"X-Initiator": isAgentCall || isClaudeModel ? "agent" : "user",
3232
}
3333

3434
const response = await fetch(`${copilotBaseUrl(state)}/chat/completions`, {

0 commit comments

Comments
 (0)