Sagents.Routers.Single (Sagents v0.8.0-rc.5)

Copy Markdown

Trivial single-factory router. Use when your app has one agent type.

defmodule MyApp.Agents.Router do
  use Sagents.Routers.Single,
    factory: MyApp.Agents.Factory,
    config: MyApp.Agents.FactoryConfig
end

The generated resolve/3 always returns the configured factory paired with a config built from the configured Config module. The Config module must expose:

  • from_inputs(map) :: Ecto.Changeset.t() — start a build pipeline from a map containing at least :scope and :conversation_id.
  • build(Ecto.Changeset.t()) :: {:ok, struct} | {:error, Ecto.Changeset.t()} — finalize.

Apps with multiple agent types should hand-write resolve/3 instead.