invoke_agent span tagged with the sub-agent’s name and (optionally)
its model.
Created by weave.startSubagent() (or turn.startAgent(), or
llm.startAgent()) and terminated with end().
Example
Hierarchy
-
SpanBase↳SubAgent
Table of contents
Properties
Methods
Properties
model
•Readonly model: string
Defined in
src/genai/subagent.ts:41name
•Readonly name: string
Defined in
src/genai/subagent.ts:40Methods
addEvent
▸ addEvent(name, attributes?, startTime?): this
Add a named event to the span. Useful for marking non-span moments such as
context compaction, tool-loop detection, or guardrail trips. Warns and
no-ops after end(). Mirrors OTel Span.addEvent.
Parameters
| Name | Type |
|---|---|
name | string |
attributes? | Attributes |
startTime? | TimeInput |
Returns
this
Example
Inherited from
SpanBase.addEventDefined in
src/genai/spanBase.ts:77end
▸ end(opts?): void
Close the SubAgent span. Idempotent. Pass error to mark it as failed;
pass endTime to backdate the close.
Parameters
| Name | Type |
|---|---|
opts? | SpanEndOptions |
Returns
void
Defined in
src/genai/subagent.ts:72setAttributes
▸ setAttributes(attributes): this
Set multiple attributes on the span at once. Warns and no-ops after
end(). Mirrors OTel Span.setAttributes (and the Python SDK’s
set_attributes).
Parameters
| Name | Type |
|---|---|
attributes | Attributes |
Returns
this
Example
Inherited from
SpanBase.setAttributesDefined in
src/genai/spanBase.ts:63create
▸ create(opts): SubAgent
Parameters
| Name | Type |
|---|---|
opts | SubAgentInit & ChildSpanContext |
Returns
SubAgent