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
Example
Hierarchy
-
SpanBase↳Turn
Table of contents
Accessors
Methods
Accessors
agentName
•get agentName(): string
Returns
string
Defined in
src/genai/turn.ts:111model
•get model(): string
Returns
string
Defined in
src/genai/turn.ts:115Methods
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
Returns
this
Inherited from
SpanBase.addEventDefined in
src/genai/spanBase.ts:82end
▸ end(opts?): void
Read current field values (to reflect mutations made via record()
since start) and close the span. Idempotent. Pass error to mark
it as failed; pass endTime to backdate the close.
Parameters
Returns
void
Defined in
src/genai/turn.ts:257record
▸ record(opts): this
Bulk-set any subset of the mutable fields. Replaces (does not merge).
Useful for assigning everything at once after a provider call returns.
Parameters
Returns
this
Defined in
src/genai/turn.ts:213setAttribute
▸ setAttribute(key, value): this
Parameters
Returns
this
Defined in
src/genai/turn.ts:205setAttributes
▸ 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
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
Returns
LLM
Defined in
src/genai/turn.ts:170startSubagent
▸ startSubagent(opts): SubAgent
Start a child SubAgent span under this Turn.
Parameters
Returns
SubAgent
Defined in
src/genai/turn.ts:190startTool
▸ startTool(opts): Tool
Start a child Tool span under this Turn.
Parameters
Returns
Tool
Defined in
src/genai/turn.ts:180create
▸ create(opts?): Turn
Parameters
Returns
Turn