← Back to PRs

#12917: feat(gateway): add agents.health RPC method for per-agent health over…

by jlwainwright open 2026-02-09 22:46 View on GitHub →
gateway stale
…view Adds a new `agents.health` gateway RPC method that aggregates existing data from agents.list, sessions, and cron into a single per-agent health summary. Useful for dashboard rendering and CLI health checks. Each agent entry includes: - status (healthy/warning/error/unknown) with reason - main session info (model, tokens, last activity) - active session count - cron summary (total, enabled, failing, next run, last failure) Status is derived automatically: - warning: cron jobs failing or main session idle >30m - unknown: no sessions and no cron jobs - healthy: everything nominal Registered as a read-scope method, available in the control UI and via WebSocket RPC. <!-- greptile_comment --> <h2>Greptile Overview</h2> <h3>Greptile Summary</h3> This PR adds a new gateway RPC method `agents.health`, registers it in the gateway method list, and grants it read-scope access. The new handler aggregates agent metadata, session store entries, and cron jobs into a per-agent health summary (status + reason, main session info, active session count, cron summary) intended for dashboards/CLI. The overall approach fits the gateway’s existing “server-methods” pattern by adding a dedicated handler module and wiring it into `coreGatewayHandlers` alongside existing `agents.*`/`cron.*` methods. <h3>Confidence Score: 2/5</h3> - Not safe to merge as-is due to a definite runtime bug in cron aggregation for `agents.health`. - `agents.health` calls `context.cron.list` and treats its return value as an array, but the established contract returns an object `{ jobs }` (per existing `cron.list` handler). This will break cron grouping/status derivation at runtime, and the accompanying test currently mocks the wrong shape so it won’t catch the issue. - src/gateway/server-methods/agents-health.ts, src/gateway/server-methods/agents-health.test.ts <!-- greptile_other_comments_section --> <sub>(2/5) Greptile learns from your feedback when you react with thumbs up/down!</sub> <!-- /greptile_comment -->

Most Similar PRs