Elixir facade for canonical BeamAgent backend routing.
This module chooses a backend according to reusable routing policy instead of forcing callers to hard-code backend choice on every session start.
Supported policies are :explicit, :sticky, :round_robin, :failover,
:capability_first, and :preferred_then_fallback. Sticky affinity and
round-robin cursors are stored as canonical BeamAgent state, but the module
itself stays process-free.
The module also acts as the primary session router — starting, stopping, querying, and managing unified sessions after resolving the backend via routing policy.
Summary
Types
Fallback behavior after preferred candidates are exhausted.
Backend health override for routing.
Routing decision map.
Routing policy name.
Routing request map.
Functions
Abort active work on the session.
Get account info from session init data.
Resolve the adapter facade module for a live session.
Resolve the backend for a live session.
Return a child spec for a unified session after resolving backend routing.
Clear sticky affinity and round-robin routing state.
Delete a tracked session from the shared store.
Ensure routing state tables exist. Idempotent.
Fork a live session.
Read shared session metadata by session id.
Get all visible messages for a session id.
Get visible messages for a session id with options.
Return the health state for a live session.
Interrupt active work on the session.
List all tracked sessions in the shared store.
List tracked sessions with filters.
Send a blocking query with default params.
Send a blocking query through the canonical router.
Pull the next message from a live query.
Revert a live session.
Select a backend using a normalized routing request.
Select a backend after deriving defaults from a session identity or session opts.
Send a control message through the appropriate native or shared path.
Send a query and return the live query reference.
Return high-level server health details when a backend exposes them.
Query session info for a live session.
Change the model at runtime.
Change the permission mode at runtime.
Share a live session with default opts.
Share a live session.
Start a unified session after resolving explicit or policy-based backend routing.
Stop a live unified session.
Summarize a live session with default opts.
Summarize a live session.
List agents from session init data.
List slash commands from session init data.
List models from session init data.
Archive a thread.
Fork a thread with default opts.
Fork a thread.
List threads for a live session.
Read a thread with default opts.
Read a thread.
Resume a thread.
Rollback a thread.
Start a thread for a live session.
Unarchive a thread.
Clear a session revert state.
Revoke sharing for a live session.
Types
@type fallback_policy() :: :beam_agent_routing.fallback_policy()
Fallback behavior after preferred candidates are exhausted.
Supported values are :none and :available.
@type health_status() :: :beam_agent_routing.health_status()
Backend health override for routing.
Supported values are :healthy, :degraded, :unhealthy, and :down.
@type route_decision() :: :beam_agent_routing.route_decision()
Routing decision map.
@type route_policy() :: :beam_agent_routing.route_policy()
Routing policy name.
Supported values are :explicit, :sticky, :round_robin, :failover,
:capability_first, and :preferred_then_fallback.
@type route_request() :: :beam_agent_routing.route_request()
Routing request map.
Functions
Abort active work on the session.
Get account info from session init data.
@spec adapter_module(pid()) :: {:ok, module()} | {:error, :beam_agent_backend.backend_lookup_error()}
Resolve the adapter facade module for a live session.
@spec backend(pid()) :: {:ok, :beam_agent_backend.backend()} | {:error, :beam_agent_backend.backend_lookup_error()}
Resolve the backend for a live session.
@spec child_spec(:beam_agent_core.session_opts()) :: :supervisor.child_spec()
Return a child spec for a unified session after resolving backend routing.
@spec clear() :: :ok
Clear sticky affinity and round-robin routing state.
@spec delete_session(binary()) :: :ok
Delete a tracked session from the shared store.
@spec ensure_tables() :: :ok
Ensure routing state tables exist. Idempotent.
Fork a live session.
@spec get_session(binary()) :: {:ok, BeamAgent.SessionStore.session_meta()} | {:error, :not_found}
Read shared session metadata by session id.
@spec get_session_messages(binary()) :: {:ok, [:beam_agent.message()]} | {:error, :not_found}
Get all visible messages for a session id.
@spec get_session_messages(binary(), BeamAgent.SessionStore.message_opts()) :: {:ok, [:beam_agent.message()]} | {:error, :not_found}
Get visible messages for a session id with options.
Return the health state for a live session.
Interrupt active work on the session.
@spec list_sessions() :: {:ok, [BeamAgent.SessionStore.session_meta()]}
List all tracked sessions in the shared store.
@spec list_sessions(BeamAgent.SessionStore.list_opts()) :: {:ok, [BeamAgent.SessionStore.session_meta()]}
List tracked sessions with filters.
@spec query(pid(), binary()) :: {:ok, [:beam_agent.message()]} | {:error, any()}
Send a blocking query with default params.
@spec query(pid(), binary(), map()) :: {:ok, [:beam_agent.message()]} | {:error, any()}
Send a blocking query through the canonical router.
@spec receive_message(pid(), reference(), timeout()) :: {:ok, :beam_agent.message()} | {:error, any()}
Pull the next message from a live query.
Revert a live session.
@spec select_backend(route_request()) :: {:ok, route_decision()} | {:error, any()}
Select a backend using a normalized routing request.
@spec select_backend(pid() | binary() | map(), route_request()) :: {:ok, route_decision()} | {:error, any()}
Select a backend after deriving defaults from a session identity or session opts.
Send a control message through the appropriate native or shared path.
@spec send_query(pid(), binary(), :beam_agent_core.query_opts(), timeout()) :: {:ok, reference()} | {:error, any()}
Send a query and return the live query reference.
Return high-level server health details when a backend exposes them.
Query session info for a live session.
Change the model at runtime.
Change the permission mode at runtime.
@spec start_session(:beam_agent_core.session_opts()) :: {:ok, pid()} | {:error, any()}
Start a unified session after resolving explicit or policy-based backend routing.
@spec stop(pid()) :: :ok
Stop a live unified session.
Summarize a live session with default opts.
Summarize a live session.
List agents from session init data.
List slash commands from session init data.
List models from session init data.
Archive a thread.
Fork a thread with default opts.
Fork a thread.
List threads for a live session.
Read a thread with default opts.
Read a thread.
Resume a thread.
Rollback a thread.
Start a thread for a live session.
Unarchive a thread.
Clear a session revert state.