Agent tool: include agent name in subagent transcript metadata
Problem
When spawning agents with the Agent tool, the name parameter is not recorded in the subagent's own transcript JSONL. The name only exists in the parent session's tool_use/tool_result blocks.
This makes telemetry, debugging, and observability harder — you have to parse the parent transcript to figure out what a subagent was named, cross-referencing tool_use IDs with agent session IDs.
Current Behavior
Parent transcript contains:
{"type": "assistant", "message": {"content": [{"type": "tool_use", "name": "Agent", "input": {"name": "hardener", "prompt": "..."}}]}}
{"type": "user", "message": {"content": [{"type": "tool_result", "agentId": "abc123"}]}}
Subagent transcript (abc123.jsonl) has no record of its own name. The session ID is abc123 but there's no field indicating it was named "hardener."
Expected Behavior
The subagent transcript should include its assigned name in the session metadata, e.g. as a system event at the start:
{"type": "system", "subtype": "session_start", "agent_name": "hardener", "parent_session": "parent123"}
Or as a field in every event: "agent_name": "hardener"
Use Case
I built a DuckDB telemetry system that indexes all session transcripts into a queryable dashboard. To resolve agent names, I have to:
- Parse every parent session JSONL
- Find Agent tool_use blocks with name params
- Find corresponding tool_result blocks with agentId
- Map agentId → name
- Apply that mapping when indexing the subagent transcript
This is fragile and breaks when the parent transcript is large or has complex nesting. If the subagent knew its own name, the indexer would be trivial.
Impact
Anyone doing agent observability, telemetry, or debugging across multi-agent sessions.
This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗