Skip to content

GH Copilot | synthetic user messages burn premium requests #8700

Closed

Description

@essinghigh

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

  1. 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).

  2. 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).

  3. 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
  4. 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

  1. github-actions commented on Jan 15, 2026

    @github-actions
    Contributor

    This issue might be a duplicate of existing issues. Please check:

    Feel free to ignore if this doesn't address your specific case.

  2. changed the title [-]GH Copilot | Subagent tool calls burn premium requests[/-] [+]GH Copilot | Tools using synthetic user messages burn premium requests[/+] on Jan 15, 2026
  3. changed the title [-]GH Copilot | Tools using synthetic user messages burn premium requests[/-] [+]GH Copilot | synthetic user messages burn premium requests[/+] on Jan 15, 2026
  4. essinghigh commented on Jan 15, 2026

    @essinghigh
    Author

    This issue might be Copilot's own problem. I've been using Copilot in web chat sessions these past two days, and my 1,000 requests ran out in just two days. This has left me completely speechless. I haven't even managed to complete the most basic tasks.
    (DeepL Translated)

    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.

  5. ananas-viber commented on Jan 16, 2026

    @ananas-viber

    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.

  6. github-actions commented on Mar 26, 2026

    @github-actions
    Contributor

    To stay organized issues are automatically closed after 90 days of no activity. If the issue is still relevant please open a new one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingzenRelates to Zen

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions