Skip to main content

Documentation Index

Fetch the complete documentation index at: https://wb-21fd5541-update-reference-docs-34.mintlify.app/llms.txt

Use this file to discover all available pages before exploring further.

weave / Tool A tool invocation. Emits an 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
const tool = weave.startTool({
  name: tc.function.name,
  args: tc.function.arguments,
  toolCallId: tc.id,
});
try {
  tool.result = await wikipediaSearch(JSON.parse(tc.function.arguments));
} finally {
  tool.end();
}

Table of contents

Properties

Methods

Properties

args

Readonly args: string

Defined in

genai/tool.ts:52

name

Readonly name: string

Defined in

genai/tool.ts:51

result

Optional result: string Tool output as a string. Recorded on gen_ai.tool.call.result at end().

Defined in

genai/tool.ts:45

toolCallId

Readonly toolCallId: string

Defined in

genai/tool.ts:53

Methods

end

end(opts?): void Flush result to the span and close it. Idempotent. Pass error to mark the span as failed.

Parameters

NameType
opts?Object
opts.error?Error

Returns

void

Defined in

genai/tool.ts:83

create

create(opts): Tool

Parameters

NameType
optsToolInit & ChildSpanContext

Returns

Tool

Defined in

genai/tool.ts:56