Repository navigation
Description
Description
When a subagent is created, the messages passed through to it look to be created with the user role, which burns a premium request.
Same seems to happen once a response from the subagent is received.
As this is now an "officially supported(?)" plugin, I'm assuming it should have the same functionality as vscode, which does not consume requests in the same way when calling their native runSubagent tool.
Quick summary from opencode as I am not familiar at all with the codebase so can only really provide input on what I've observed:
Summary
The problem is in packages/opencode/src/plugin/copilot.ts at lines 51-88.
Issue Details
-
X-Initiator Header Logic: The Copilot plugin sets "X-Initiator": isAgent ? "agent" : "user" to distinguish between user and agent requests. The isAgent flag is determined by checking if last?.role !== "user" (lines 63 and 75).
-
Subagent Spawning Creates User Messages: When the task tool spawns a subagent (packages/opencode/src/tool/task.ts:145-160), it calls SessionPrompt.prompt() which internally calls createUserMessage() (packages/opencode/src/session/prompt.ts:820-821). This function always creates messages with role: "user" (line 824).
-
Detection Logic Flaw: The isAgent detection in the Copilot plugin only looks at the last message's role. When a subagent is spawned: - A new user message is created to prompt the subagent
- The last message in the API request has role: "user"
- isAgent becomes false
- X-Initiator: user is sent instead of X-Initiator: agent
-
Post-Subagent Message Also Affected: After a subagent completes, another synthetic user message is added (packages/opencode/src/session/prompt.ts:458-476) to continue the parent agent's task. This also gets classified as a user message.
Plugins
None
OpenCode version
1.1.21
Steps to reproduce
Using a Github Copilot model, ask it to spawn a subagent to do work, you will see your usage increase both for your initial message, but also as well as when it enters and exits the call.
Screenshot and/or share link
No response
Operating System
N/A
Terminal
N/A
Activity
github-actions commentedon Jan 15, 2026
This issue might be a duplicate of existing issues. Please check:
Feel free to ignore if this doesn't address your specific case.
[-]GH Copilot | Subagent tool calls burn premium requests[/-][+]GH Copilot | Tools using synthetic user messages burn premium requests[/+][-]GH Copilot | Tools using synthetic user messages burn premium requests[/-][+]GH Copilot | synthetic user messages burn premium requests[/+]essinghigh commentedon Jan 15, 2026
I'm not sure how this is done in Copilot web, but at least as far as VSCode is concerned these sorts of calls never use premium requests. I think the problem here is that the detection logic is based purely on which role the last message has instead of what the actual origin of that message was. If the parent spawns a subagent, the message is being sent by the agent - so it should be classified as such.
ananas-viber commentedon Jan 16, 2026
This is addressed by PR #8721 (pattern-matching fix for immediate relief) and follow-up issue #8766 (metadata-based approach for long-term solution).
The root cause is the same as #8030 - synthetic user messages created by OpenCode (compaction, tool attachments, subagent prompts) are not detected as agent-initiated, so they consume premium requests.
fix(session): prevent concurrent prompt() from creating duplicate use…
github-actions commentedon Mar 26, 2026
To stay organized issues are automatically closed after 90 days of no activity. If the issue is still relevant please open a new one.