LegionWeb. AgentTracker behaviour
(LegionWeb v0.5.0)
View Source
Query interface for a Legion agent activity tracker.
An implementation provides the dashboard's read model for agents and their events. The configured tracker is supervised by LegionWeb and called directly by the dashboard.
Built-in trackers
LegionWeb.AgentTracker.Telemetryis the default. It keeps recent agents and events in memory from Legion telemetry.LegionWeb.AgentTracker.Postgresrebuilds the dashboard from a PostgreSQL-backedLegion.Storeand follows changes through database notifications.
The telemetry tracker needs no configuration. To select another tracker, configure its module and startup options:
config :legion_web, :agent_tracker,
{LegionWeb.AgentTracker.Postgres, store: MyApp.AgentStore}A custom tracker must implement this behavior and provide a child specification so LegionWeb can supervise it. Implementations may use any process model, storage mechanism, or ingestion strategy as long as they return the records described by this interface.
Summary
Callbacks
Returns the tracked agent with the given ID, or nil when it is absent.
Returns an agent's events in chronological order.
Returns an agent's LLM usage entries in request order.
Lists up to limit tracked agents, newest first.
Types
@type agent() :: LegionWeb.AgentTracker.LegionAgent.t()
@type agent_id() :: Legion.Store.agent_id()
@type event() :: LegionWeb.AgentTracker.LegionEvent.t()
@type status() :: :running | :idle | :waiting_for_human | :done | :error | :dead
@type timestamp() :: integer()
@type usage() :: map()
Callbacks
Returns the tracked agent with the given ID, or nil when it is absent.
Returns an agent's events in chronological order.
Returns an agent's LLM usage entries in request order.
Each entry is the string-keyed usage map Legion records for one LLM request,
including its "at" timestamp in milliseconds. Only the agent's own requests
are included; a sub-agent's usage is tracked under the sub-agent.
@callback list_agents(pos_integer()) :: [agent()]
Lists up to limit tracked agents, newest first.