Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
fix: Copilot Premium Requests
All calls including those initiated by a tool or the assistant are currently
being counted against the copilot premium request limit.

This header should prevent calls initiated by either the "tool" or "assistant"
from counting against those request limits.

For example codecompanion.nvim recently implemented a similar (fix)[olimorris/codecompanion.nvim@ed96fe3]

fix #430
  • Loading branch information
mhuggins7278 committed Jul 2, 2025
commit 0e99a0738534842b2e0d694aaa7016c5ed5ff69c
19 changes: 19 additions & 0 deletions packages/opencode/src/provider/provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,11 +99,30 @@ export namespace Provider {
})
info.access = tokens.access
}
let isAgentCall = false
try {
const body =
typeof init.body === "string"
? JSON.parse(init.body)
: init.body
let m
for (m of body.messages) {
Log.Default.warn("role", { role: m.role })
}
if (body?.messages) {
isAgentCall = body.messages.some(
(msg: any) =>
msg.role && ["tool", "assistant"].includes(msg.role),
)
}
} catch {}
Log.Default.warn("isAgentCall", { isAgentCall })
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, {
Expand Down