Skip to content

Agent registry health check endpoint + auto deregister stale agents #420

Open
clintjeff2 wants to merge 2 commits into
Bitcoindefi:mainfrom
clintjeff2:Agent-registry-health-check-endpoint-+-auto-deregister-stale-agents-#193
Open

Agent registry health check endpoint + auto deregister stale agents #420
clintjeff2 wants to merge 2 commits into
Bitcoindefi:mainfrom
clintjeff2:Agent-registry-health-check-endpoint-+-auto-deregister-stale-agents-#193

Conversation

@clintjeff2

Copy link
Copy Markdown
Contributor

Motivation

  • Registered agents were never removed and stale entries accumulated when agents crashed or stopped heartbeating.
  • Agents need to signal liveliness via periodic heartbeats and the registry must mark them offline or remove them when they become stale.
  • A simple health endpoint and a status=online filter are useful for monitoring and UI filtering.

Description

  • Add lastSeen to agent manifests, extend AgentStatus with online, and introduce AGENT_OFFLINE_AFTER_MS (120s) and AGENT_STALE_AFTER_MS (600s) constants in lib/agent-registry.ts and lib/types.ts.
  • Implement sweepAgentRegistry() which runs at request time to mark agents offline after >120s and deregister agents unseen >600s, and wire it into listRegisteredAgents, listCapabilities, and getRegisteredAgent.
  • Add recordAgentHeartbeat() and a POST /api/registry/[id]/heartbeat route to update lastSeen and set status to online, and add GET /api/registry/health which returns { online, offline, stale_removed_last_run }.
  • Add status query filtering to /api/registry and set lastSeen when registering an agent; add tests covering heartbeat, offline marking, stale removal, status filtering, and health counts in __tests__/api/registry/registry.test.ts.

Testing

  • Ran npm test -- __tests__/api/registry/registry.test.ts which passed (10 tests).
  • Ran the full test runner npm test which exposed unrelated environment/dependency issues (missing lru-cache and @wagmi/connectors) causing other suites to fail; the registry-specific tests still pass.
  • Ran npx tsc --noEmit which surfaced the same missing dependency/type errors unrelated to the registry changes.

Closes #193

…gister-agents

feat: add registry heartbeat, request-time sweep and health endpoint
@sonarqubecloud

Copy link
Copy Markdown

@clintjeff2

Copy link
Copy Markdown
Contributor Author

@leocagli, review and merge.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Agent registry: health check endpoint + auto-deregister stale agents

1 participant