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 tracing.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.
Examples
Properties
string
Read-only.
string
Read-only.
Methods
end()
record()
since start) and close the span. Idempotent. Pass error to mark
it as failed; pass endTime to backdate the close.
Parameters
SpanEndOptions
record()
agentName when it starts, so pass agentName to
startTurn if the name has to carry it. record still updates the field
that end() writes to gen_ai.agent.name; it does not rename the span.
Parameters
object
required
Returns
this
setAttributes()
end(). Mirrors OTel Span.setAttributes (and the Python SDK’s
set_attributes).
Parameters
Attributes
required
Returns
this
Examples
startLLM()
Parameters
Returns
LLM
startSubagent()
Parameters
SubAgentInit
required
Type:
SubAgentInitReturns
SubAgent
startTool()
Parameters
Returns
Tool