Skip to content

Interface: CreateSubAgentToolOptions

@providerprotocol/agents


@providerprotocol/agents / index / CreateSubAgentToolOptions

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

Configuration options for creating a sub-agent tool.

Defines how an agent should be exposed as a callable tool, including its name, parameters, and how to transform tool arguments into prompts.

createSubAgentTool for usage examples

agent: Agent

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

The agent instance to expose as a tool.

This agent will be invoked when the parent agent calls the tool. The sub-agent executes independently with its own tools and system prompt.


buildPrompt: (params) => string

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

Transforms tool parameters into a prompt string for the sub-agent.

This function receives the arguments generated by the parent agent’s model and should return a natural language prompt for the sub-agent.

Record<string, unknown>

The tool arguments matching the parameters schema

string

A prompt string to send to the sub-agent


description: string

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

Description of what the tool does.

This is provided to the parent agent’s model to help it decide when to use this tool. Be specific about the sub-agent’s capabilities.


name: string

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

Unique name for the tool.

Must be unique within the parent agent’s tool set. This name is used by the parent agent’s model to invoke the sub-agent.


parameters: JSONSchema

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

JSON Schema defining the tool’s input parameters.

The parent agent’s model will generate arguments matching this schema when invoking the tool. These arguments are passed to buildPrompt.


optional stream: boolean

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

Whether to stream the sub-agent execution.

When true, inner events from the sub-agent (text deltas, tool calls, etc.) are forwarded to the parent through subagent_event events, enabling real-time visibility into sub-agent progress.

When false, only subagent_start and subagent_end events are emitted.

true

optional subagentType: string

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

Identifier for the sub-agent type used in event payloads.

Useful for distinguishing between different sub-agent types in logs and event handlers. Defaults to the tool name if not specified.

The tool name