Skip to content

Type Alias: SubAgentToolRun()

@providerprotocol/agents


@providerprotocol/agents / index / SubAgentToolRun

SubAgentToolRun = (params, context?) => Promise<string>

Defined in: src/subagent/index.ts:421

Function signature for a sub-agent tool’s run method.

This type represents the shape of the run function created by createSubAgentTool. It accepts the tool parameters and an optional execution context that provides event propagation capabilities.

Record<string, unknown>

The tool parameters as defined by the tool’s JSON Schema

ToolExecutionContext

Optional execution context for event propagation and tracing

Promise<string>

A promise resolving to the sub-agent’s text response

// Type-safe tool invocation
const tool = createSubAgentTool({ ... });
const run = tool.run as SubAgentToolRun;
const result = await run(
{ query: 'search term' },
{ toolCallId: 'call_123', onSubagentEvent: handleEvent }
);