Copilot auth now sets far too many requests as "user" consuming premium requests rapidly
Description
This, morning a request or two using Github Copilot's Opus 4.5 consumed half my monthly quota -- there were around 60 agent-initiated requests that should not have been counted as premium requests. In other words, they should have had the X-Initiator header set to "agent" as this is the way Copilot counts requests. Agent/tool initiated messages are flagged as "agent" and truly user-initated ("user" messages) are the ones that should consume premium requests.
This appears to be directly related to the opencode-copilot-auth version bump of recent commits, so I did create anomalyco/opencode-copilot-auth#11 there as well. The opencode-copilot-auth is recently, and rightly, trying to comply with Copilot's request consumption patterns so as not to provide an avenue for abuse. We are now seeking to ensure that all "user" requests consume premium tokens (with premium models, that is). That is good, but introduces an incompatibility with opencode's role classifying.
As far as I can tell, opencode creates synthetic "user" messages for tool attachments in the MessageV2.toModelMessage function in packages/opencode/src/session/message-v2.ts. So now that opencode-copilot-auth is more conservative in its use of the X-Initiator: agent header, we are in effect charging for every tool attachment message, which gets quite expensive, as I discovered this morning, sadly.
Workaround
For now, I would highly recommend to Copilot users that they keep OpenCode at version 1.1.12, and do your best to be honorable (and safe from being blocked or throttled by Github), starting new sessions often rather than "riding" the same session to avoid premium request consumption.
Plugins
OpenCode version
1.1.14
Steps to reproduce
Ask a copilot premium model such as Claude to investigate or solve a complex problem that involves reading, writing, and editing files.
Screenshot and/or share link
No response
Operating System
Linux, Windows
Terminal
Foot, and Windows Terminal
This issue might be a duplicate of existing issues. Please check:
- #6816: Github Copilot burns premium quota for non-premium models (similar issue about premium quota consumption, recently closed)
- #768: Github Copilot: Tracking Premium Requests (related to premium request tracking)
- #7076: Heightened number of requests being made (reports similar premium quota consumption increase with GitHub Copilot)
- #924: Dramatic increase in token consumption (related issue about dramatic token/request consumption increase)
Feel free to ignore if your specific case differs from these.
ahh
will fix
in claude code , skill invocations, edit hooks or to do reminders , request like this: {"role":"user","content":[{"type":"tool_result","content":"Launching skill: xxx"},{"type":"text","text":"xxx"}]}, when translate to copilot-api will add user block in last message. i also change in https://github.com/ericc-ch/copilot-api/pull/170/commits/f2b84769bbda984d83c78aeb7dbb52c58595e71d , maybe opencode also the same case.
As discussed in #8067 my initial analysis is probably wrong, and the excessive token usage may have been related to https://github.com/Opencode-DCP/opencode-dynamic-context-pruning -- I just had the bad luck to use it before it had fully updated to use assistant messages instead of user messages.
I'm not sure if this is related to your thing... but interestingly enough, yday I noticed the same increased usage with Copilot: https://x.com/adrians5j/status/2011007640344678444?s=20
Was shocked, and now I'm using webstorm's plugin, just to see if it's any dfferent. So far, it DOES feel that the increased consumption is no longer happening.
Keeping my eye on this one. Don't know how to properly debug these things yet.
UPDATE: Just saw the duplicate issue. Woah so it's not just me. Good to know.