Skip to main content
Weave for Agents is in public preview. Features, APIs, and the Agents view UI may change before general availability.
A sub-agent is a delegated agent invocation that runs inside a turn. Use sub-agents when one agent hands off to another, such as when a supervisor agent dispatches a specialist agent. When instrumented using Weave, sub-agents emit a nested invoke_agent OTel span in the same trace as the parent turn. In the Agents view, this nesting renders as a sub-agent invocation under the turn that triggered it, with its own LLM calls and tool calls grouped beneath.

Sub-agent data model

The weave.start_subagent span maps to the OTel invoke_agent span and emits the same operation name as the parent turn. Weave distinguishes the two by their parent-child relationship in the trace:
Sub-agents inherit the active session’s conversation_id, so they’re grouped with the rest of the conversation in the Agents view.
weave.start_subagent creates an invoke_agent span that automatically becomes a child of whatever span is currently active in OTel context, typically the parent turn or the LLM call that triggered the delegation. OTel context propagation handles the parent-child relationship, so no explicit delegation is needed.

Trace a single sub-agent

The following example runs a supervisor agent that receives a request and delegates it a research-specialist sub-agent that uses a Wikipedia search tool to find the answer. Weave captures the full hierarchy by wrapping the conversation in weave.start_session and then a session.start_turn. Weave then captures the sub-agent trace using the weave.start_subagent block for the specialist, and recording each LLM call and tool execution as child spans. We have intentionally omitted the routing logic in these examples to focus on the tracing between agents.
In the Agents view, the sub-agent appears as a nested invoke_agent block inside the turn, with its own LLM calls and tool calls grouped beneath. The supervisor’s direct LLM calls remain siblings of the sub-agent.

Trace multiple sub-agents

The following example runs a content-pipeline agent that handles a single request by delegating to three sibling sub-agents in sequence: a researcher that gathers facts, a writer that drafts the post, and a reviewer that polishes the final output. Weave captures all three sub-agents as siblings under the same turn by opening a separate weave.start_subagent block for each. Because each sub-agent inherits the active turn’s OTel context, they appear as peer invoke_agent spans nested under the turn rather than under each other.
In the Agents view, the turn contains three sibling sub-agent invocations, each with its own LLM call nested beneath, and the researcher includes its tool call. None of the sub-agents are children of each other.

Trace nested sub-agents

A sub-agent can itself delegate to another sub-agent. Each start_subagent call nests under whatever span is currently active in OTel context.
The example produces three levels of nesting under the turn:
In the Agents view, research-coordinator appears as a sub-agent of the turn, anthropic-researcher and openai-researcher appear as siblings under the coordinator, and anthropic-summarizer appears as a sub-agent of anthropic-researcher.