claude-code - 💡(How to fix) Fix [BUG] Plugin agent body is discarded when loaded via --agent — content never reaches system prompt [1 comments, 2 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
anthropics/claude-code#56797Fetched 2026-05-07 03:45:08
View on GitHub
Comments
1
Participants
2
Timeline
5
Reactions
0
Author
Timeline (top)
labeled ×4commented ×1

Error Message

Error Messages/Logs

Code Example



---

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

---

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

---

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

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

---

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

---

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

---

claude --agent test-agent -p "What is the secret word?"
RAW_BUFFERClick to expand / collapse

Preflight Checklist

  • I have searched existing issues and this hasn't been reported yet
  • This is a single bug report (please file separate reports for different bugs)
  • 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.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

claude-code - 💡(How to fix) Fix [BUG] Plugin agent body is discarded when loaded via --agent — content never reaches system prompt [1 comments, 2 participants]