Parallel dispatch and synthesis pattern.
A stateless module that classifies input, dispatches to multiple specialized agents in parallel, and synthesizes results into a single response.
Summary
Functions
Evaluates each route's match_fn against the input.
Dispatches input to all given routes' agents in parallel.
Routes input through matching agents and synthesizes results.
Combines results with route name headers.
Types
Functions
Evaluates each route's match_fn against the input.
Returns all routes whose match_fn returns true.
@spec dispatch(String.t(), [route()], pos_integer()) :: [{String.t(), String.t()}]
Dispatches input to all given routes' agents in parallel.
Returns a list of {route_name, response_content} tuples.
Failed agents are included with an error message.
@spec route(String.t(), router_opts()) :: {:ok, String.t()} | {:error, term()}
Routes input through matching agents and synthesizes results.
- Classifies the input by evaluating each route's
match_fn - Dispatches to all matching agents in parallel
- Synthesizes the results using the provided synthesizer function
Options
:routes(required) - list of route maps with:name,:agent,:match_fn:synthesizer- function(input, results) -> combined_string(default: joins with headers):timeout- milliseconds to wait for each agent (default: 30_000)
Combines results with route name headers.