Skip to content

feat: Agent heartbeat push for fast failure detection (RELIABILITY-004) #307

Closed

Description

@vybe

Summary

Agent health is currently detected by polling every 30 seconds from the backend. This means an agent crash takes up to 30s to detect, and during that window other agents continue sending requests to a dead container. Combined with no circuit breaker (see RELIABILITY-001), this causes long cascading timeouts.

Solution

Flip from pull to push: agents send a lightweight heartbeat to the platform every 5 seconds. A missed heartbeat triggers immediate status change and (with RELIABILITY-001) opens the circuit breaker preemptively.

Scope

Backend:

  • New internal endpoint: POST /api/internal/heartbeat (no auth, internal network only)
  • Store heartbeat timestamp in Redis with 15s TTL: heartbeat:{agent_name}
  • Health check reads Redis key — missing key = agent unresponsive
  • Feed heartbeat status into monitoring service and circuit breaker (if RELIABILITY-001 is implemented)

Agent-side:

  • Add background task in agent-server.py that POSTs heartbeat every 5s
  • Include basic health info in payload: memory usage, active execution count, uptime

Acceptance Criteria

  • Running agents send heartbeat every 5 seconds
  • Backend detects missing heartbeat within 15 seconds (vs 30s+ currently)
  • Heartbeat status reflected in fleet health endpoint
  • Agent server continues working normally if backend is temporarily unreachable (heartbeat fails silently)
  • ~40 lines total (backend endpoint + agent-side background task)
  • No new infrastructure — uses existing Redis

Key Files

  • src/backend/routers/internal.py — new heartbeat endpoint
  • src/backend/services/monitoring_service.py — consume heartbeat data
  • docker/base-image/agent_server/ — add heartbeat background task

Dependencies

  • Enhances RELIABILITY-001 (circuit breaker) — heartbeat loss can proactively open circuit
  • Independent of other reliability issues

Activity

  1. added
    priority-p2
    type-feature
    on Apr 11, 2026
  2. added
    priority-p1
    and removed
    priority-p2
    on May 26, 2026
  3. added
    complexity-medium
    theme-reliability
    on Jun 3, 2026
  4. added
    priority-p2
    and removed
    priority-p1
    on Jun 5, 2026
  5. vybe commented on Jun 5, 2026

    @vybe
    ContributorAuthor

    Under the pull model (#1081) the heartbeat is no longer a dispatch gate: a dead agent simply stops pulling, so no compute is wasted and the backend never floods a sick agent. The missed-heartbeat signal is repurposed into an operator alert (queue depth climbing + no successful results = unhealthy), not a mechanism that fails work pre-emptively. Pull does not depend on this, so de-prioritized p1→p2.

  6. added
    status-in-dev
    on Jun 8, 2026
  7. added a commit that references this issue on Jul 26, 2026
  8. removed
    status-in-dev
    on Aug 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

complexity-mediumpriority-p2theme-reliabilitytype-feature

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions