Skip to content

Agent nodes flap between active/inactive due to aggressive health check timeout #167

Description

@williamhdean

Description

Agent nodes intermittently disappear from the active node list due to an aggressive health check timeout in the control plane. Nodes sending heartbeats every 2 seconds still experience flapping, where they appear and disappear from the /api/v1/nodes endpoint.

Environment

  • Control Plane Version: v0.1.39 (also tested with latest)
  • Agent SDK: agentfield==0.1.38 (Python)
  • Deployment: Docker containers on same network
  • Heartbeat Interval: 2 seconds (default), also tested with 1 second

Steps to Reproduce

  1. Start the AgentField control plane via Docker
  2. Start 2+ agent nodes that register with the control plane
  3. Query the nodes endpoint repeatedly:
    for i in $(seq 1 10); do
      curl -s "http://localhost:8080/api/v1/nodes" | jq -c '[.nodes[].id]'
      sleep 2
    done

Expected Behavior

All registered nodes should consistently appear in the node list as long as they are sending heartbeats within the configured interval.

Actual Behavior

Nodes intermittently disappear from the list. Example output:

["campaign-planner", "content-writer"]
["campaign-planner"]
[]
["content-writer"]
["campaign-planner", "content-writer"]
["campaign-planner"]

The control plane logs show:

{"level":"error","error":"agent node with ID 'content-writer' not found","message":"❌ Node content-writer not found during heartbeat update"}

Workarounds

  1. Query specific nodes directly: GET /api/v1/nodes/{node_id}
  2. Query without health filter: GET /api/v1/nodes?health_status=

Feature Request

Please add configurable health check timeout settings, either via:

  1. Environment variables:

    AGENTFIELD_NODE_HEALTH_TIMEOUT=30s
    AGENTFIELD_HEARTBEAT_TIMEOUT=10s
    
  2. YAML configuration:

    nodes:
      health_timeout: 30s
      heartbeat_timeout: 10s

The current ~2-3 second timeout is too aggressive for production use, especially in containerized environments where network latency can vary.

Additional Context

  • Tested with both SQLite (local) and attempted PostgreSQL storage modes
  • Issue persists across control plane restarts
  • Agents successfully re-register on next heartbeat, but the flapping causes issues for monitoring and orchestration

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions