A trivial always-compiled GenAgent.Backend for demos and iex
experimentation.
Each prompt turn emits a single :result event whose text is
derived from the prompt. No external dependencies, no API keys,
no subprocess -- makes it possible to wire up an ensemble and
exercise GenAgentEnsemble.ask/2 or tell/2 end-to-end from a
fresh iex -S mix session with zero setup.
Not for production use. For real work, reach for
GenAgent.Backends.Anthropic, GenAgent.Backends.Claude,
GenAgent.Backends.OpenAI, or GenAgent.Backends.Codex.
Options
:transform-- a function(String.t() -> String.t())that maps the prompt text to the response text. Defaults to prepending"echo: ".:delay_ms-- milliseconds to sleep before emitting the response. Useful for simulating a slow backend during iex prototyping. Default:0.
Example
{:ok, _} =
GenAgentEnsemble.start_link(
name: "echo",
strategy: GenAgentEnsemble.Strategies.Solo,
opts: [
agent: {"w", GenAgentEnsemble.Agents.Simple,
backend: GenAgentEnsemble.Backends.Echo,
transform: &String.upcase/1,
delay_ms: 500}
]
)
{:ok, %{text: "HELLO"}} = GenAgentEnsemble.ask("echo", "hello")
Summary
Types
@type t() :: %GenAgentEnsemble.Backends.Echo{ delay_ms: non_neg_integer(), transform: (String.t() -> String.t()) }