Skip to main content
When Claude Code or OpenCode spawn subagents, the proxy needs to distinguish subagent requests from top-level user requests and keep them associated with the correct root session. Without a marker, the proxy treats every request as a fresh top-level interaction, which can consume unnecessary premium quota and breaks session affinity. The plugins fix this by injecting a session marker and propagating a session ID header. The proxy reads these values to preserve the parent session identity and correctly classify the traffic as subagent-originated.

Claude Code plugin

The Claude Code plugin is distributed through a marketplace hosted in the Copilot API repository.
1

Add the marketplace

Inside Claude Code, run:
This registers the Copilot API marketplace catalog with Claude Code.
2

Install the plugin

What the plugin does

  • Injects a subagent marker at the SubagentStart lifecycle event so the proxy can identify subagent traffic.
  • Registers a UserPromptSubmit hook that returns {"continue": true}.

Plugin environment variables

You can control the plugin’s behavior with these environment variables, set in your .claude/settings.json env block or in your shell:

OpenCode plugin

The OpenCode plugin is a JavaScript file included in the Copilot API repository at .opencode/plugins/subagent-marker.js.
1

Copy the plugin file

Clone or download the Copilot API repository, then copy the plugin to your OpenCode plugins directory:
If you prefer not to clone the repository, create the file manually at ~/.config/opencode/plugins/subagent-marker.js with the plugin content from the repository.

What the plugin does

  • Tracks sub-sessions created by subagents.
  • Prepends a subagent marker as a system reminder to subagent chat messages.
  • Sets a session ID header for session tracking.
The plugin hooks into the following OpenCode events: session.created, session.deleted, chat.message, and chat.headers. Adding question-tool reminders to your project’s CLAUDE.md (for Claude Code) or AGENTS.md (for OpenCode and Codex) helps the agent check in with you before closing a task instead of finishing silently.
CLAUDE.md or AGENTS.md
If you set CLAUDE_PLUGIN_ENABLE_QUESTION_RULES=1 in your Claude Code environment, the plugin injects these reminders automatically at session start. You do not need to add them to CLAUDE.md in that case — but it does not hurt to have both.