GenAgentEnsemble.Strategies.Pool (gen_agent_ensemble v0.3.0)

Copy Markdown View Source

Fixed-size worker pool strategy.

N identical workers are started on init. Each tell/ask lands on the next free worker; idle workers rotate FIFO. When all are busy, prompts queue FIFO and dispatch as workers free up. Workers are reused across turns (their GenAgent processes stay alive).

Options

  • :worker_count (required) -- integer, number of workers to start.
  • :worker_template (required) -- {name_prefix, module, opts}. Workers are named "#{prefix}-1", ..., "#{prefix}-N".

Failure semantics

  • A worker's turn error fails the token it was running, and the worker returns to the free pool (it may recover on the next prompt).
  • If a worker's process dies, its in-flight token fails as {:worker_down, reason}. A fresh worker starts from the template under the same name and can take the next queued prompt. Its previous backend session and conversation history are lost.
  • If replacement cannot start, that worker is removed from the pool. A queued prompt assigned to it fails; other workers keep running. If none remain, the ensemble halts and closes all pending tokens.