Skip to main content

Module agents

Module agents 

Source
Expand description

GET /sessions/{id}/agents REST route over the session.get_agents JSON-RPC method (#2983 Slice 6).

Why: DOC-39 §5.4 names session.get_agents “the principled endpoint” a late-attaching UI client needs to ask “who is running right now?” for one session, without folding the SSE ring-buffer replay itself (see crate::session::protocol_agents module docs). As with every route in this gateway, the handler stays thin — extract the path param, call super::respond — because the actual behaviour (the live per-agent roster fold, -32007 session_not_found mapping) already lives in crate::session::registry_agents/protocol_agents; duplicating it here would fork the two surfaces (see super module docs). What: routes builds a standalone axum::Router<()> (its own AgentsState carrying just the Arc<Router>, with_state-erased before return, mirroring super::sessions::SessionsState) mapping GET /sessions/{id}/agents -> session.get_agents.

Deviation from the literal GET /agents shape: session.get_agents REQUIRES a session_id param (verified in crate::session::protocol_agents::get_agents and crate::session::protocol::SessionIdParams) — there is no roster independent of a session. A bare GET /agents route would therefore have nothing to forward as session_id. Nesting it under /sessions/{id} instead is both correct per the RPC’s actual signature AND consistent with how Slice 2 (super::sessions) already nests every other session-scoped read route (.../transcript, .../readiness, .../goals) — /sessions/{id}/agents slots into that same family. crate::serve::http::build_axum_router merges this into the daemon’s main router alongside POST /rpc, GET /health, GET /sessions/{id}/events, and the other REST resource groups. /sessions/{id}/agents does not collide with any path Slice 2/3 already registered under /sessions/{id}. Test: tests::*.

Functions§

routes
Build the GET /sessions/{id}/agents route group.