Skip to main content
A tool invocation. Emits an execute_tool span carrying the tool name, the arguments, the tool-call id, and the result. String arguments and results are recorded as-is; other JSON values are serialized. Created by tracing.startTool() (or turn.startTool(), or llm.startTool()) and terminated with end(), which accepts the result and optional error metadata.

Examples

Properties

string
Read-only.
string
Read-only.
string
Read-only.

Methods

end()

Record an optional result and error type, then close the span. Idempotent. Pass error to mark the span as failed and endTime to backdate the close.

Parameters

ToolEndOptions

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

Last modified on September 30, 2026