Team agents lack self-identity: no team name or agent name injected at spawn
Summary
Team agents spawned via the Task tool have no self-awareness of their own identity (name, team name, agent ID) or their team's config path. The team_name and name parameters passed to the Task tool are used for message routing infrastructure but are not injected into the agent's context (no env var, no system prompt field, no config path).
Agents must blindly search ~/.claude/teams/ to discover their team, which is unreliable when multiple team directories exist.
Environment
- Claude Code v2.1.34
- macOS, tmux backend
- Opus 4.6 agents (also tested with Haiku 4.5)
Reproduction
- Create a team:
TeamCreate(team_name="my-team")→ system generates slug likequiet-purring-cerf - Spawn two agents with explicit names:
Task(name="alice", team_name="quiet-purring-cerf", ...) - Ask each agent: "What is your name? What team are you on? Run
env | grep -i claudeto check env vars. Find and read your team config."
Observed behavior
No identity injection. Only env vars set are:
CLAUDECODE=1
CLAUDE_CODE_EXPERIMENTAL_AGENT_TEAMS=1
CLAUDE_CODE_ENTRYPOINT=cli
No CLAUDE_TEAM_NAME, CLAUDE_AGENT_NAME, CLAUDE_AGENT_ID, or CLAUDE_TEAM_CONFIG equivalent.
Config discovery is unreliable. Agents know from system prompt that configs live at ~/.claude/teams/{team-name}/config.json but don't know {team-name}. They resort to heuristics:
- Agent "alice" searched for a config containing member "alice" → found correct team (got lucky because message summary leaked her name)
- Agent "bob" searched by most recent modification time → found a completely different team's config from a previous session, with different members, different models, different prompts
Identity discoverable only via side effect. Bob discovered his name was "bob" only after sending a message — the SendMessage tool response includes "sender": "bob" in routing metadata. There is no way for an agent to know its own name without performing a side-effecting action.
Message routing works correctly regardless. The infrastructure routes messages between agents correctly — it knows the identity mapping internally, it just doesn't share it with the agents.
Expected behavior
When team_name and name are passed to the Task tool, the spawned agent should have this information available from the start. Options:
- Env vars:
CLAUDE_TEAM_NAME=quiet-purring-cerf,CLAUDE_AGENT_NAME=alice,CLAUDE_AGENT_ID=alice@quiet-purring-cerf - System prompt injection with team context
- A dedicated self-identity tool
The data already exists at spawn time and is used for routing — it just needs to be surfaced to the agent's own context.
Impact
- Agents on the same team can read different (wrong) configs
- Haiku-class models cannot reliably self-discover at all — they hallucinate teammate names
- Even Opus gets it right only with lucky heuristics
- Stale team directories from previous sessions act as traps for config discovery
- Peer-to-peer messaging requires the team lead to manually bridge names ("send a message to bob, his name is bob") because agents can't discover teammates reliably
This issue has 2 comments on GitHub. Read the full discussion on GitHub ↗