claude-code - 💡(How to fix) Fix [Feature Request] Add CLAUDE_AGENT_NAME environment variable for multi-agent workflows [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#46858Fetched 2026-04-12 13:31:13
View on GitHub
Comments
1
Participants
2
Timeline
11
Reactions
0
Author
Timeline (top)
labeled ×4cross-referenced ×2mentioned ×2subscribed ×2

Error Message

[{"error":"Error: 400 {"type":"error","error":{"type":"invalid_request_error","message":"Output blocked by content filtering policy"},"request_id":"req_011CZwHyHAGs3JxBGJEgkNGQ"}\n at generate (/$bunfs/root/src/entrypoints/cli.js:11:53430)\n at makeRequest (/$bunfs/root/src/entrypoints/cli.js:50:4943)\n at processTicksAndRejections (native:7:39)","timestamp":"2026-04-11T03:43:27.528Z"},{"error":"Error: 400 {"type":"error","error":{"type":"invalid_request_error","message":"Output blocked by content filtering policy"},"request_id":"req_011CZwJQ4AsrsX6YgSuRMn2i"}\n at generate (/$bunfs/root/src/entrypoints/cli.js:11:53430)\n at makeRequest (/$bunfs/root/src/entrypoints/cli.js:50:4943)\n at processTicksAndRejections (native:7:39)","timestamp":"2026-04-11T03:49:07.527Z"},{"error":"Error: 400 {"type":"error","error":{"type":"invalid_request_error","message":"Output blocked by content filtering policy"},"request_id":"req_011CZwJZoTsSiAuQDu2k85ey"}\n …

Root Cause

We maintain a project-local .agency-agent file that records the expected agent name per worktree, and our agent-identity tool reads this file to produce a fallback identity. This works for us because we control the worktree directory layout, but it's not a general solution.

Fix Action

Fix / Workaround

Workaround

Code Example

[{"error":"Error: 400 {\"type\":\"error\",\"error\":{\"type\":\"invalid_request_error\",\"message\":\"Output blocked by content filtering policy\"},\"request_id\":\"req_011CZwHyHAGs3JxBGJEgkNGQ\"}\n    at generate (/$bunfs/root/src/entrypoints/cli.js:11:53430)\n    at makeRequest (/$bunfs/root/src/entrypoints/cli.js:50:4943)\n    at processTicksAndRejections (native:7:39)","timestamp":"2026-04-11T03:43:27.528Z"},{"error":"Error: 400 {\"type\":\"error\",\"error\":{\"type\":\"invalid_request_error\",\"message\":\"Output blocked by content filtering policy\"},\"request_id\":\"req_011CZwJQ4AsrsX6YgSuRMn2i\"}\n    at generate (/$bunfs/root/src/entrypoints/cli.js:11:53430)\n    at makeRequest (/$bunfs/root/src/entrypoints/cli.js:50:4943)\n    at processTicksAndRejections (native:7:39)","timestamp":"2026-04-11T03:49:07.527Z"},{"error":"Error: 400 {\"type\":\"error\",\"error\":{\"type\":\"invalid_request_error\",\"message\":\"Output blocked by content filtering policy\"},\"request_id\":\"req_011CZwJZoTsSiAuQDu2k85ey\"}\n …
RAW_BUFFERClick to expand / collapse

Bug Description --agent/--name flag does not expose agent name as an environment variable

Problem

When launching Claude Code with claude --agent devex or claude --name devex, the spawned process does not expose the agent name to its shell environment. There is no CLAUDE_AGENT_NAME, CLAUDE_NAME, or equivalent variable that downstream tooling can read.

This is a hard blocker for any workflow that runs multiple agents concurrently and needs to tell them apart from outside the Claude Code process — terminal tab titles, shell prompts, status lines, tmux pane labels, telemetry tagging, per-agent log routing, and so on.

Steps to reproduce

  1. Launch multiple Claude Code sessions with different agent names: claude --agent captain claude --agent devex claude --agent iscp
  2. Inside each session, inspect the environment: env | grep -i agent env | grep -i claude
  3. Inspect the terminal tab/title bar.

Observed: No environment variable references the agent name. All terminal tabs display a generic "agent" label. $CLAUDE_AGENT_NAME is unset.

Expected: An environment variable — CLAUDE_AGENT_NAME, or similar — is set in the child process, containing the name passed to --agent / --name. Terminal integration features would use this to populate the tab title automatically.

Why this matters

  • Multi-agent development is the use case Claude Code is being used for. Many teams (including ours) run captain + multiple worktree agents simultaneously. Differentiating them outside the Claude Code process is currently impossible.
  • Terminal ergonomics matter. Humans looking at a row of terminal tabs need to see which one is doing what. Generic "agent" labels everywhere is a paper cut that becomes painful fast.
  • Tool integration matters. Shell prompts, tmux status lines, monitoring tools, and IDE integrations all want to know "which agent is this?" and there's no answer.
  • Programmatic agent-aware scripting is blocked. Shell scripts that want to behave differently per agent (e.g., "if this is captain, use the admin path; otherwise, use the worktree path") have no reliable way to detect the agent context.

Requested behavior

Minimal change: Set CLAUDE_AGENT_NAME (or a namespace-qualified variant like CLAUDE_CODE_AGENT_NAME) in the spawned process's environment when --agent / --name is passed. The variable should be readable from shell, from tools invoked via Bash, and from hooks.

Nice to have:

  • Also set CLAUDE_SESSION_ID so concurrent sessions can be distinguished programmatically
  • Document the full set of environment variables Claude Code exposes to child processes in the public docs
  • Consider a structured session metadata file (e.g., $XDG_RUNTIME_DIR/claude-code/{session-id}.json) for richer integration

Workaround

We maintain a project-local .agency-agent file that records the expected agent name per worktree, and our agent-identity tool reads this file to produce a fallback identity. This works for us because we control the worktree directory layout, but it's not a general solution.

Reporter

Related

  • Session identity broken for worktree workflows (#46853) — the session-level companion to this process-level request
  • Agent permission UX (#46855) — another aspect of the multi-agent workflow gap
  • Filed as part of the 2026-04-11/12 feedback batch

Environment Info

  • Platform: darwin
  • Terminal: ghostty
  • Version: 2.1.101
  • Feedback ID: 0894552a-1614-4553-9eef-0acf597598e5

Errors

[{"error":"Error: 400 {\"type\":\"error\",\"error\":{\"type\":\"invalid_request_error\",\"message\":\"Output blocked by content filtering policy\"},\"request_id\":\"req_011CZwHyHAGs3JxBGJEgkNGQ\"}\n    at generate (/$bunfs/root/src/entrypoints/cli.js:11:53430)\n    at makeRequest (/$bunfs/root/src/entrypoints/cli.js:50:4943)\n    at processTicksAndRejections (native:7:39)","timestamp":"2026-04-11T03:43:27.528Z"},{"error":"Error: 400 {\"type\":\"error\",\"error\":{\"type\":\"invalid_request_error\",\"message\":\"Output blocked by content filtering policy\"},\"request_id\":\"req_011CZwJQ4AsrsX6YgSuRMn2i\"}\n    at generate (/$bunfs/root/src/entrypoints/cli.js:11:53430)\n    at makeRequest (/$bunfs/root/src/entrypoints/cli.js:50:4943)\n    at processTicksAndRejections (native:7:39)","timestamp":"2026-04-11T03:49:07.527Z"},{"error":"Error: 400 {\"type\":\"error\",\"error\":{\"type\":\"invalid_request_error\",\"message\":\"Output blocked by content filtering policy\"},\"request_id\":\"req_011CZwJZoTsSiAuQDu2k85ey\"}\n …

Note: Content was truncated.

extent analysis

TL;DR

Set the CLAUDE_AGENT_NAME environment variable in the spawned process when the --agent or --name flag is passed to Claude Code.

Guidance

  • The issue is likely caused by the absence of an environment variable that exposes the agent name to the child process.
  • To verify the fix, run claude --agent devex and then env | grep -i agent to check if the CLAUDE_AGENT_NAME variable is set.
  • A potential workaround is to maintain a project-local file that records the expected agent name per worktree, similar to the reporter's .agency-agent file.
  • The fix should involve modifying the Claude Code codebase to set the CLAUDE_AGENT_NAME environment variable when the --agent or --name flag is passed.

Example

No code snippet is provided as the issue does not contain sufficient information about the Claude Code codebase.

Notes

The provided error messages do not seem to be directly related to the issue at hand, as they appear to be content filtering policy errors. The issue is focused on the absence of an environment variable, and the errors do not provide additional context.

Recommendation

Apply a workaround by maintaining a project-local file that records the expected agent name per worktree, similar to the reporter's .agency-agent file, until the CLAUDE_AGENT_NAME environment variable is officially supported by Claude Code.

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