Skip to content

FunctionToolResult

type FunctionToolResult<Context, TParameters, Result> =
| {
agentRunResult?: RunResult<Context, Agent<Context, any>>;
interruptions?: RunToolApprovalItem[];
output: string | unknown;
runItem: RunToolCallOutputItem;
tool: FunctionTool<Context, TParameters, Result>;
type: "function_output";
}
| {
runItem: RunToolApprovalItem;
tool: FunctionTool<Context, TParameters, Result>;
type: "function_approval";
}
| {
runItem: RunToolApprovalItem;
tool: HostedMCPTool<Context>;
type: "hosted_mcp_tool_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

{
agentRunResult?: RunResult<Context, Agent<Context, any>>;
interruptions?: RunToolApprovalItem[];
output: string | unknown;
runItem: RunToolCallOutputItem;
tool: FunctionTool<Context, TParameters, Result>;
type: "function_output";
}
optional agentRunResult: RunResult<Context, Agent<Context, any>>;

The result returned when the tool execution runs another agent. Populated when the invocation originated from Agent.asTool and the nested agent completed a run.

optional interruptions: RunToolApprovalItem[];

Any interruptions collected while the nested agent executed. These are surfaced to allow callers to pause and resume workflows that require approvals.

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";

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

{
runItem: RunToolApprovalItem;
tool: HostedMCPTool<Context>;
type: "hosted_mcp_tool_approval";
}
runItem: RunToolApprovalItem;

The item representing the tool call that is requiring approval.

tool: HostedMCPTool<Context>;

The tool that is requiring to be approved.

type: "hosted_mcp_tool_approval";

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