Unclear Whether Claude Code always fills in agent_id on subagent messages is not confirmed.
Messages that Claude Code sends through the SDK (the kit developers use to build on Claude Code) can now carry an optional agent_id field. It identifies the subagent (a helper agent Claude starts for part of a task) that produced the message. Its value is the task_id used in that subagent's task events, and it stays the same when the subagent is resumed. Messages from the main conversation do not have it. Before, only the subagent's type was given.
Programs built on Claude Code can now tell which particular subagent wrote a message, not just what kind of subagent it was.
The entry above is what we published on the day. These lines were added later, as Anthropic's own pages caught up, and they sit beside the original rather than replacing it.
Messages from within a subagent's context include a `parent_tool_use_id` field. In TypeScript, each assistant and user message a subagent produces also carries [`agent_id`](/docs/en/agent-sdk/typescript#sdkassistantmessage): the `task_id` …agent-sdk/subagents see the edit
| `agent_id` | On this event, the [common input field](#common-input-fields) identifies the subagent or [in-process teammate](/docs/en/agent-teams#choose-a-display-mode) creating the task. May be absent. Requires Claude Code v2.1.290 or la…hooks see the edit
Whether Claude Code always fills in `agent_id` on subagent messages is not confirmed.
A small documentation edit on Hooks reference touched a line naming agent_id after this was published.