Skip to content

AgentToolOptions

type AgentToolOptions<TContext, TAgent, TParameters> = object;
Type Parameter

TContext

TAgent extends Agent<TContext, any>

TParameters extends AgentToolInputParameters

customOutputExtractor?: (output) => string | Promise<string>;

A function that extracts the output text from the agent. By default, runs with output guardrail results or a handled error use the final output, including an empty string. Other runs prefer text from the latest model response, falling back to the final output.

Parameter Type

output

CompletedAgentToolInvocationRunResult<TContext, TAgent>

string | Promise<string>


includeInputSchema?: boolean;

Include the full JSON Schema for the structured tool input when invoking the agent.


inputBuilder?: AgentToolInputBuilder<TParameters>;

Builds the nested agent input from structured tool input data.


isEnabled?: boolean | ((args) => boolean | Promise<boolean>);

Determines whether this tool should be exposed to the model for the current run.


needsApproval?: boolean | ToolApprovalFunction<TParameters>;

Whether invoking this tool requires approval, matching the behavior of tool helpers. When provided as a function it receives the tool arguments and can implement custom approval logic.


onStream?: (event) => void | Promise<void>;

Optional hook to receive streamed events from the nested agent run.

Parameter Type

event

AgentToolStreamEvent<TAgent>

void | Promise<void>


onStreamMaxPendingEvents?: number | null;

Maximum events waiting for onStream or on(…) handlers, excluding the event currently being handled. Defaults to 1024; null permits an unlimited backlog. Must be a positive safe integer when set. Overflow aborts the nested run and fails the tool through its normal error handling. Already started handler promises cannot be cancelled. This bounds event count, not event sizes or total memory, and has no effect without streaming handlers.


parameters?: TParameters;

The schema used to validate tool input. Defaults to { input: string }.


resumeState?: AgentToolResumeStateOptions;

Controls how context is applied when resuming from serialized run state.


runConfig?: Partial<RunConfig>;

Run configuration for initializing the internal agent runner. When the child uses an explicit Model object, parent transport overrides in providerData are not inherited. Supply child transport overrides here.


runOptions?: AgentToolRunOptions<TContext, TAgent>;

Additional run options for the agent (as tool) execution.


toolDescription?: string;

The description of the tool, which should indicate what the tool does and when to use it.


toolName?: string;

The name of the tool. If not provided, the name of the agent will be used.