Skip to content

feat(backend): Implement Agent Health Monitoring with Automatic Failover #273

Description

@devJaja

Summary

Enhance agent health monitoring with automatic failover: when an agent fails health checks, tasks are rerouted to alternative agents automatically.

Motivation

Currently, agent failures require manual intervention. Automatic failover improves task completion rates and reduces downtime.

Acceptance Criteria

  • Health check runs every 30 seconds for all agents
  • Agent marked offline after 3 consecutive failed health checks
  • Active tasks on offline agent automatically retried with alternative agent
  • Fallback agent selection: same capability, highest reputation
  • Agent recovery: marked online after passing health check
  • Events emitted: AgentFailedOver, AgentRecovered, AgentMarkedOffline
  • Failover logged with correlation ID for tracing
  • Unit tests for failover, recovery, and retry logic

Files to Modify

File Action
backend/src/agents/heartbeat.ts Enhance with failover logic
backend/src/coordinator/coordinator.ts Add failover and retry to node execution
backend/src/coordinator/dispatch.ts Add agent selection fallback
backend/src/services/agentMonitor.ts New: centralized agent health monitoring
backend/src/agents/heartbeat.test.ts Add failover tests

How to Contribute

  1. Create branch feat/agent-failover
  2. Build centralized agent monitoring service
  3. Implement automatic failover in coordinator
  4. Add recovery detection logic
  5. Write comprehensive failover tests
  6. Run npm run test && npm run lint before submitting PR

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions