invoke_agent span and acts as the root of the
trace for that turn: it is always started under ROOT_CONTEXT so it
never accidentally inherits a parent from another OTel-instrumented
library.
Created by weave.startTurn() (or conversation.startTurn()) and
terminated with end(). Only one Turn may be active in an async chain.
Children (LLM, Tool, SubAgent) attach via the startLLM, startTool,
startSubagent methods.
Example
Hierarchy
-
SpanBase↳Turn
Table of contents
Properties
Methods
Properties
agentName
•Readonly agentName: string
Defined in
src/genai/turn.ts:57model
•Readonly model: string
Defined in
src/genai/turn.ts:58Methods
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 Turn 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/turn.ts:144setAttribute
▸ setAttribute(key, value): this
Parameters
| Name | Type |
|---|---|
key | string |
value | AttributeValue |
Returns
this
Defined in
src/genai/turn.ts:136setAttributes
▸ 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:63startLLM
▸ startLLM(opts): LLM
Start a child LLM span under this Turn.
Parameters
| Name | Type |
|---|---|
opts | LLMInit |
Returns
LLM
Defined in
src/genai/turn.ts:104startSubagent
▸ startSubagent(opts): SubAgent
Start a child SubAgent span under this Turn.
Parameters
| Name | Type |
|---|---|
opts | SubAgentInit |
Returns
SubAgent
Defined in
src/genai/turn.ts:122startTool
▸ startTool(opts): Tool
Start a child Tool span under this Turn.
Parameters
| Name | Type |
|---|---|
opts | ToolInit |
Returns
Tool
Defined in
src/genai/turn.ts:113create
▸ create(opts?): Turn
Parameters
| Name | Type |
|---|---|
opts | TurnInit & { conversationId?: string } |
Returns
Turn