execute_tool span carrying the tool name,
the JSON-encoded arguments, the tool-call id, and the result.
Created by weave.startTool() (or turn.startTool(), or
llm.startTool()) and terminated with end(). Assign result before
calling end() to record the tool’s output on the span.
Example
Hierarchy
-
SpanBase↳Tool
Table of contents
Properties
Methods
Properties
args
•Readonly args: string
Defined in
src/genai/tool.ts:52name
•Readonly name: string
Defined in
src/genai/tool.ts:51result
•Optional result: string
Tool output as a string. Recorded on gen_ai.tool.call.result at end().
Defined in
src/genai/tool.ts:47toolCallId
•Readonly toolCallId: string
Defined in
src/genai/tool.ts:53Methods
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
Example
Inherited from
SpanBase.addEventDefined in
src/genai/spanBase.ts:77end
▸ end(opts?): void
Flush result to the span and close it. Idempotent. Pass error to mark
the span as failed; pass endTime to backdate the close.
Parameters
| Name | Type |
|---|---|
opts? | SpanEndOptions |
Returns
void
Defined in
src/genai/tool.ts:87setAttributes
▸ 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:63create
▸ create(opts): Tool
Parameters
| Name | Type |
|---|---|
opts | ToolInit & ChildSpanContext |
Returns
Tool