Skip to main content

Properties

string
Read-only.
string
Read-only.

Methods

end()

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

SpanEndOptions

record()

Bulk-set any subset of the mutable fields. Replaces (does not merge). Input and output messages are serialized when the span ends. The span is named from name when it starts, so pass name to startSubagent 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()

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

Attributes
required

Returns

this

Examples

startLLM()

Start a child LLM span nested under this SubAgent.

Parameters

LLMInit
required
Type: LLMInit

Returns

LLM

startSubagent()

Start a nested SubAgent span under this SubAgent.

Parameters

SubAgentInit
required

Returns

SubAgent

startTool()

Start a child Tool span nested under this SubAgent.

Parameters

ToolInit
required
Type: ToolInit

Returns

Tool
Last modified on September 28, 2026