[Bug] Plugin-scoped subagent definitions silently ignored in agent teams
Bug Description
Agent teams: plugin-scoped subagent definitions are silently ignored for teammates
The docs (Agent teams → "Use subagent definitions for teammates") say a teammate can spawn from a subagent definition in any scope — "project, user, plugin, or CLI-defined" — with the definition's body appended to its system prompt and its tools/model honored.
On v2.1.211, plugin-scoped definitions are silently dropped. The in-process teammate spawn resolves the type (activeAgents.find(H => H.agentType === s)) but then discards the result via a source filter (source !== "built-in" && source !== "plugin"). No error is surfaced — the teammate spawns as a vanilla session: tools ["*"], no appended body, no definition model. Project- and user-scoped definitions apply correctly.
Repro: spawn a teammate with subagent_type set to any plugin agent (myplugin:my-agent) → the teammate's subagents/agent-a<name>-*.meta.json has no customAgentType field, and with --debug the log shows [handleSpawnInProcess] agent_type=<type>, found=false. Repeat with a .claude/agents/ agent → customAgentType present, body/tools/model applied.
Expected: plugin scope works as documented — or the spawn fails loudly and the docs drop "plugin" from the supported scopes. The silent degradation is the damaging part: orchestration setups that keep worker procedures in plugin agent definitions break invisibly, and the workers improvise instead.
Environment Info
- Platform: darwin
- Terminal: tmux
- Version: 2.1.211
- Feedback ID: 96d7f07a-3b83-4f7c-97f0-d8a235b616d9
Errors
[{"error":"Error: 500 {\"type\":\"error\",\"error\":{\"type\":\"api_error\",\"message\":\"Internal server error\"},\"request_id\":\"req_011Cd6DfKiHpLWhhdVugEMzZ\"}\n at generate (/$bunfs/root/src/entrypoints/cli.js:40:48330)\n at makeRequest (/$bunfs/root/src/entrypoints/cli.js:80:7690)\n at processTicksAndRejections (native:7:39)","timestamp":"2026-07-16T18:36:01.089Z"},{"error":"Error: 500 {\"type\":\"error\",\"error\":{\"type\":\"api_error\",\"message\":\"Internal server error\"},\"request_id\":\"req_011Cd6DfKHFLyTXUQaUBWSLv\"}\n at generate (/$bunfs/root/src/entrypoints/cli.js:40:48330)\n at makeRequest (/$bunfs/root/src/entrypoints/cli.js:80:7690)\n at processTicksAndRejections (native:7:39)","timestamp":"2026-07-16T18:36:01.151Z"}]Showing cached comments. Read the full discussion on GitHub ↗
3 Comments
Reproducing the same underlying bug on v2.1.211 but on a different spawn path — worth folding in so whoever fixes the source filter covers both entry points.
Environment
2.1.211CLAUDE_CODE_WORKFLOWS=1,DISABLE_GROWTHBOOK=1~/.claude/plugins/cache/<marketplace>/<plugin>/<version>/agents/<agent>.md— SHA1 matches source frontmatter, so it's not a cache-staleness problem.Repro (Agent-tool spawn, not TeamCreate)
Plugin subagent frontmatter:
From the main loop:
The subagent spawns, but when it introspects its own system prompt it reports only 4 tools available:
Read, Bash, Agent, SendMessage. The other 7 declared in frontmatter (Glob, Grep, TaskCreate, TaskUpdate, TaskList, TeamCreate, Workflow) are missing. Confirmed across two consecutive CLI sessions (fresh restart, cache cleared).Delta vs the teammate-spawn path in the OP
The failure mode is the same root cause (plugin frontmatter dropped) but the fallback differs between the two paths, which is useful signal for the fix:
| Path | OP (
handleSpawnInProcess— teammate) | Agent tool (subagent_typefrom main loop) ||---|---|---|
| Body appended? | No | Yes (the subagent's role prompt loads) |
| Frontmatter
tools:honored? | No | No || Effective toolset |
["*"](vanilla — inherits everything) | Truncated to a small default (Read, Bash, Agent, SendMessage) || Frontmatter
model:honored? | No | (not tested) |So the teammate path collapses to "no definition applied at all" and the Agent-tool path collapses to "body applied, tool allowlist silently replaced by a hard-coded default." Both silently degrade — no error surfaced either way.
Impact
Any plugin that ships a
main-loop → lead subagent → workerstopology is partially inoperative on 2.1.211: workers that needWrite/Editto modify code,Glob/Grepto search, orWorkflowto invoke deterministic orchestration cannot perform their role. Fallback in practice is having the main loop take over the lead-subagent's job, which defeats the plugin architecture.Prior history
#47898 reported the same class of bug against the Agent-tool spawn path back in April 2026 and was auto-closed as stale in May without a fix. Given #78234 covers the teammate path on the same runtime version, a shared fix is likely.
We've hit the same silent drop at larger scale and measured the blast radius. Three data points beyond what's in the issue body:
tools:allowlists (Read, Bash, Grep, Glob, TaskStop). Spawned with anamein an interactive session, the samesubagent_typecame up as a vanilla teammate holdingAgent,Artifact,Bash,Edit,Read,Skill,ToolSearch,Write— i.e. write, delegation, and publishing capabilities the allowlist was built to withhold. Across 53 named dispatches of our plugin lenses, 0 resolved the definition (plain spawns of the same types resolve fine). Downstream we logged 9 real working-tree writes from "read-only" reviewers, and one leaf agent successfully spawning sub-agents — the teammate's ownspawnDepthis 0, so leaf restrictions don't apply structurally.deferred_tools_delta(plus 15,445 bytes of skill listing; 42,914 bytes ≈ 12k tokens per spawn). The skill listing appears to be documented teammate behavior; the deferred-tools delta contradicting the definition'stools:allowlist is the defect half.claude -p, passingnamedoes not take the in-process-teammate path — the bug only manifests in interactive sessions, so scripted probes/CI stay green. Repro'd as of 2.1.23x, macOS (2026-08-18).The silent form is the damaging part for us too: it turns an authorization boundary into a false assurance — state records say "allowlist in place" while reviewers effectively run with the full toolset. Failing loudly (or honoring plugin scope as documented) would both be fine outcomes.
Still present in Version: 2.1.280 Windows
This bug completely prevents any plugin that has agent definitions from being used in agent teams
CLAUDE_CODE_EXPERIMENTAL_AGENT_TEAMS=1whenever the agents are named.In my case, it makes the plugin I'm developing completely unusable.