GenAgentEnsemble.Strategies.Debate (gen_agent_ensemble v0.2.0)

Copy Markdown View Source

Two agents take turns arguing about a prompt until they converge or a round cap is reached.

The incoming prompt hits the first agent. That agent's response text becomes the prompt for the second agent, whose response becomes the prompt for the first again, and so on. Each agent's own GenAgent session keeps the full back-and-forth in its backend memory, so turn N sees turns 1..N-1 in context.

Options

  • :agents (required) -- exactly two {name, module, opts} specs. Names must be distinct.
  • :first (optional) -- name of the agent who speaks first. Defaults to the first entry in :agents.
  • :rounds (optional) -- hard cap on total agent responses. Defaults to 6 (three exchanges per side).
  • :converge (optional) -- (String.t() -> boolean()). Called on each response's text starting from turn 2. Returning true ends the debate immediately. Defaults to fn _ -> false end (round cap only).
  • :reply (optional) -- how to shape the final response:
    • :transcript (default) -- join every turn as "#{agent}:\n#{text}", separated by blank lines.
    • :last -- just the last agent's response text.
    • {:synthesize, fun} -- call fun.(transcript) where transcript is [{agent_name, text}, ...] in order.

Concurrency

One debate runs at a time. Additional tell/ask calls queue FIFO and begin when the current debate completes.

Failure semantics

  • A turn error aborts the debate: token fails with the backend reason; next queued prompt (if any) starts.
  • If either agent's process dies, the session halts -- neither agent alone can debate.