Skip to content

FunctionToolResult

type FunctionToolResult<Context, TParameters, Result> =
| {
output: string | unknown;
runItem: RunToolCallOutputItem;
tool: FunctionTool<Context, TParameters, Result>;
type: "function_output";
}
| {
runItem: RunToolApprovalItem;
tool: FunctionTool<Context, TParameters, Result>;
type: "function_approval";
};

The result of invoking a function tool. Either the actual output of the execution or a tool approval request.

These get passed for example to the toolUseBehavior option of the Agent constructor.

Type Parameter Default type

Context

UnknownContext

TParameters extends ToolInputParameters

any

Result

any

{ output: string | unknown; runItem: RunToolCallOutputItem; tool: FunctionTool<Context, TParameters, Result>; type: "function_output"; }

output: string | unknown;

The output of the tool call. This can be a string or a stringifable item.

runItem: RunToolCallOutputItem;

The run item representing the tool call output.

tool: FunctionTool<Context, TParameters, Result>;

The tool that was called.

type: "function_output";

{ runItem: RunToolApprovalItem; tool: FunctionTool<Context, TParameters, Result>; type: "function_approval"; }

runItem: RunToolApprovalItem;

The item representing the tool call that is requiring approval.

tool: FunctionTool<Context, TParameters, Result>;

The tool that is requiring to be approved.

type: "function_approval";

Indiciates that the tool requires approval before it can be called.