Centralized orchestration pattern.
A main agent invokes specialized subagents as tool calls. Subagents are transient, stateless processes with isolated contexts - they run a single LLM call and return the result without maintaining state.
Summary
Functions
Invokes a subagent synchronously with a single query.
Invokes several subagents in parallel, each with its own input.
Builds one tool per subagent, for an orchestrator agent to call.
Types
@type subagent_spec() :: %{ name: String.t(), description: String.t(), provider: struct(), system_prompt: String.t() | nil, tools: [ExAgent.Tool.t()] }
Functions
@spec invoke_subagent(subagent_spec(), String.t()) :: {:ok, String.t()} | {:error, term()}
Invokes a subagent synchronously with a single query.
Creates a fresh context, calls Provider.chat/3 directly
(no GenServer), and returns the assistant's response content.
@spec run( [{subagent_spec(), String.t()}], keyword() ) :: [{String.t(), {:ok, String.t()} | {:error, term()}}]
Invokes several subagents in parallel, each with its own input.
Returns a list of {spec_name, result} tuples.
@spec tools([subagent_spec()]) :: [ExAgent.Tool.t()]
Builds one tool per subagent, for an orchestrator agent to call.
Each subagent becomes a tool whose function spawns an ephemeral LLM call.
The tool's parameters accept a "query" string.