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 Parameters
Section titled “Type Parameters”Type Parameter | Default type |
---|---|
|
|
|
|
|
|
Type declaration
Section titled “Type declaration”{ agentRunResult?: RunResult<Context, Agent<Context, any>>; interruptions?: RunToolApprovalItem[]; output: string | unknown; runItem: RunToolCallOutputItem; tool: FunctionTool<Context, TParameters, Result>; type: "function_output";}
agentRunResult?
Section titled “agentRunResult?”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.
interruptions?
Section titled “interruptions?”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
Section titled “output”output: string | unknown;
The output of the tool call. This can be a string or a stringifable item.
runItem
Section titled “runItem”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
Section titled “runItem”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
Section titled “runItem”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.