[BUG] Plugin agent body is discarded when loaded via --agent — content never reaches system prompt

Resolved 💬 3 comments Opened May 6, 2026 by abouzou Closed May 10, 2026

Preflight Checklist

  • [x] I have searched existing issues and this hasn't been reported yet
  • [x] This is a single bug report (please file separate reports for different bugs)
  • [x] I am using the latest version of Claude Code

What's Wrong?

When using --agent PluginName:agent-name with a plugin-provided agent (registered via extraKnownMarketplaces in settings.json), the agent markdown body is completely discarded. Only frontmatter fields (name, description) are extracted. The body content — whether it contains @path imports or raw inlined markdown — never reaches the system prompt.

The /context command shows system prompt remains at ~6k tokens (default Claude Code prompt) regardless of agent body size. Tested with 109KB of inlined content — still 6k.

Non-plugin agents (in ~/.claude/agents/ or .claude/agents/) work correctly — the body becomes the system prompt as documented.

What Should Happen?

Per the sub-agents documentation: "The subagent's system prompt replaces the default Claude Code system prompt entirely, the same way --system-prompt does."

Plugin-provided agents loaded via --agent should behave identically to user-level agents — the markdown body should become the session's system prompt.

Error Messages/Logs

Steps to Reproduce

1. Create a minimal plugin:

mkdir -p /tmp/test-plugin/.claude-plugin /tmp/test-plugin/agents

Plugin manifest (/tmp/test-plugin/.claude-plugin/plugin.json):

{"name": "test-plugin", "version": "1.0.0"}

Agent file (/tmp/test-plugin/agents/test-agent.md):

---
name: test-agent
description: "Test agent with body content"
---

The secret word is PINEAPPLE. Always mention this when asked about your context.

2. Register in ~/.claude/settings.json:

{
  "enabledPlugins": {"test-plugin@local": true},
  "extraKnownMarketplaces": {
    "local": {"source": {"source": "directory", "path": "/tmp/test-plugin"}}
  }
}

3. Test:

claude --agent test-plugin:test-agent -p "What is the secret word in your context?"

Expected: "PINEAPPLE"

Actual: Agent says there is no secret word in its context.

4. Confirm with /context:

Launch interactively with --agent test-plugin:test-agent, run /context, observe system prompt is 6k tokens (unchanged default).

5. Control test (proves user-level agents work):

Copy the same file to ~/.claude/agents/test-agent.md, then run:

claude --agent test-agent -p "What is the secret word?"

This works correctly — responds with "PINEAPPLE."

Claude Model

Opus

Is this a regression?

I don't know

Last Working Version

_No response_

Claude Code Version

2.1.131

Platform

Anthropic API

Operating System

Other Linux

Terminal/Shell

Terminal.app (macOS)

Additional Information

Binary analysis of v2.1.131 shows two separate code paths:

User/project agents → parseAgentFromMarkdown → body.trim() used as system prompt
Plugin agents → only frontmatter extracted, body never passed to system prompt logic
The agent loading module (parseAgentFromMarkdown / flK in minified source) does K.trim() and returns it as the system prompt. But this function is never called for plugin-provided agents — they go through a different loader that only reads frontmatter.

Related: #9354 (variable resolution in plugin markdown). That issue is a prerequisite but even with resolved paths or fully inlined content, the body is still discarded for plugin agents.

View original on GitHub ↗

This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗