invoke_agent OpenTelemetry (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
Before instrumenting your code, it helps to understand how Weave represents sub-agents in a trace. Theweave.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:
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 you don’t need explicit delegation.
Trace a single sub-agent
The following example runs a supervisor agent that receives a request and delegates it to a research-specialist sub-agent that uses a Wikipedia search tool to find the answer. Weave captures the full hierarchy by wrapping the conversation inweave.start_conversation and then a conversation.start_turn. Weave then captures the sub-agent trace using the weave.start_subagent block for the specialist, and records each LLM call and tool execution as child spans.
The routing logic is intentionally omitted from these examples to focus on the tracing between agents.
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: aresearcher 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, the sub-agents appear as peer invoke_agent spans nested under the turn rather than under each other.
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. Eachstart_subagent call nests under whatever span is currently active in OTel context.
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.