GenAgentEnsemble.Strategies.Supervisor (gen_agent_ensemble v0.2.0)

Copy Markdown View Source

Deterministic fan-out strategy: one coordinator agent decomposes a prompt, the strategy spawns N worker agents with the decomposed sub-prompts, and a reply lands when all workers have responded.

The first handle_response comes from the coordinator and carries the full decomposition output. A user-supplied :decomposer function turns that output into a list of sub-prompts. The strategy then issues {:start, ...} + {:dispatch, ...} ops for each worker.

When every worker has reported back, the strategy concatenates their responses (or runs a user-supplied :synthesizer if given) and issues {:reply, token, response} plus {:stop, worker} per worker.

Options

  • :coordinator (required) -- {name, module, opts} spec for the coordinator agent.
  • :worker_template (required) -- {name_prefix, module, opts}. Workers are named "#{prefix}-1", "#{prefix}-2", ...
  • :decomposer (required) -- (String.t() -> [String.t()]) that turns coordinator output into sub-prompts.
  • :synthesizer (optional) -- ([{worker_name, String.t()}] -> String.t()). Defaults to joining worker outputs with "\n\n".

Limits

Only one in-flight prompt at a time in this first version. If a second tell/ask arrives while a fan-out is in progress, it is queued and dispatched after the current one completes.

If a worker process dies during fan-out, the current run and every queued request fail with {:worker_down, worker, reason}. Remaining workers are stopped, and a later fresh request may start a new run.