Hierarchy
-
SpanBase↳Turn
Table of contents
Accessors
Methods
Accessors
agentName
•get agentName(): string
Returns
string
Defined in
src/genai/turn.ts:103model
•get model(): string
Returns
string
Defined in
src/genai/turn.ts:107Methods
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
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
| Name | Type |
|---|---|
opts? | SpanEndOptions |
Returns
void
Defined in
src/genai/turn.ts:241record
▸ 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
| Name | Type |
|---|---|
opts | Object |
opts.agentDescription? | string |
opts.agentId? | string |
opts.agentName? | string |
opts.agentVersion? | string |
opts.messages? | Message[] |
opts.model? | string |
opts.systemInstructions? | string[] |
Returns
this
Defined in
src/genai/turn.ts:201setAttribute
▸ setAttribute(key, value): this
Parameters
| Name | Type |
|---|---|
key | string |
value | AttributeValue |
Returns
this
Defined in
src/genai/turn.ts:193setAttributes
▸ 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:161startSubagent
▸ startSubagent(opts): SubAgent
Start a child SubAgent span under this Turn.
Parameters
| Name | Type |
|---|---|
opts | SubAgentInit |
Returns
SubAgent
Defined in
src/genai/turn.ts:179startTool
▸ startTool(opts): Tool
Start a child Tool span under this Turn.
Parameters
| Name | Type |
|---|---|
opts | ToolInit |
Returns
Tool
Defined in
src/genai/turn.ts:170create
▸ create(opts?): Turn
Parameters
| Name | Type |
|---|---|
opts | TurnInit & { conversationId?: string } |
Returns
Turn