Mark Huggins 7 месяцев назад
Родитель
Сommit
b89d4a16fd
1 измененных файлов с 14 добавлено и 0 удалено
  1. 14 0
      packages/opencode/src/provider/provider.ts

+ 14 - 0
packages/opencode/src/provider/provider.ts

@@ -99,11 +99,25 @@ export namespace Provider {
               })
               info.access = tokens.access
             }
+            let isAgentCall = false
+            try {
+              const body =
+                typeof init.body === "string"
+                  ? JSON.parse(init.body)
+                  : init.body
+              if (body?.messages) {
+                isAgentCall = body.messages.some(
+                  (msg: any) =>
+                    msg.role && ["tool", "assistant"].includes(msg.role),
+                )
+              }
+            } catch {}
             const headers = {
               ...init.headers,
               ...copilot.HEADERS,
               Authorization: `Bearer ${info.access}`,
               "Openai-Intent": "conversation-edits",
+              "X-Initiator": isAgentCall ? "agent" : "user",
             }
             delete headers["x-api-key"]
             return fetch(input, {