Skip to content

MCP get_fleet_health returns 500 while all per-agent get_agent_health calls return 200 #669

Closed

Description

@pandore

Summary

The MCP tool get_fleet_health consistently returns 500 Internal Server Error, while get_agent_health for every individual agent in the same fleet returns 200 with aggregate_status: "healthy". Because the per-agent path works, the bug appears to be in the fleet aggregation logic on the backend — most likely choking on agents whose 24h health rollups have not been refreshed.

Environment

  • Trinity backend: production
  • Reproduced from: MCP client (Claude Code), 2026-05-05
  • Fleet size: 9 agents
  • MCP tool: get_fleet_health → GET /api/ops/fleet/health (defined at src/backend/routers/ops.py:123, wrapped by src/mcp-server/src/tools/monitoring.ts:42)

Steps to reproduce

  1. Call mcp__trinity__list_agents → 9 running agents returned ✅
  2. Call mcp__trinity__get_fleet_health → 500 Internal Server Error ❌
  3. Call mcp__trinity__get_agent_health for each of the 9 agents → all return success: true, aggregate_status: "healthy" ✅

Likely root cause

The per-agent endpoint returns suspicious data that the fleet aggregator probably can't tolerate:

Agent last_check_at uptime_24h latency_24h
competitor-analyzer 2026-05-05 (today) 100 30.33ms
atlas 2026-03-19 null null
tom-marketing-ops 2026-04-28 null null
bdr-agent 2026-04-28 null null
rsdr-agent 2026-03-04 null null
ability-website 2026-02-28 null null
ruby-internal 2026-02-23 null null
cornelius-internal 2026-02-23 null null
source-of-truth 2026-02-23 null null

8 of 9 agents have uptime_percent_24h: null and avg_latency_24h_ms: null, and last_check_at is days-to-months old. The scheduled fleet health check loop appears to have stopped running for those agents — only competitor-analyzer has fresh data.

Two related issues:

  1. The scheduled check is not running for most agents. This is the underlying problem. perform_fleet_health_check in src/backend/services/monitoring_service.py:528 should be refreshing all running agents on a schedule.
  2. The aggregator endpoint crashes on null/stale 24h values instead of degrading gracefully. Even when stale data exists, the response should be a structured payload (e.g. aggregate_status: "unknown"), not 500.

Workaround

Loop over list_agents and call get_agent_health per agent, or call trigger_health_check(agent_name) per agent to refresh data on demand.

Doc drift noticed in passing (not blocking)

While investigating I noticed three different paths cited for fleet health across docs:

  • docs/user-docs/operations/monitoring.md → /api/monitoring/fleet-health
  • docs/memory/feature-flows/agent-monitoring.md → /api/monitoring/status
  • Actual implementation → /api/ops/fleet/health

Worth reconciling once the bug is fixed.

Asks

  • Wrap fleet aggregation in error handling so null/missing 24h rollups degrade to unknown instead of 500
  • Investigate why perform_fleet_health_check stopped running for 8 of 9 agents (check scheduler logs around 2026-02-23 — that's when the stalest agents were last refreshed)
  • Optional: reconcile fleet-health endpoint paths across docs

Activity

  1. added
    bug
    on May 5, 2026
  2. added
    status-in-progress
    priority-p1
    on May 6, 2026
  3. self-assigned this
    on May 6, 2026
  4. added
    status-in-dev
    and removed
    status-in-progress
    on May 6, 2026
  5. vybe commented on Jun 1, 2026

    @vybe
    Contributor

    Shipped in v0.6.0 (released via #998).

  6. added
    complexity-low
    and removed
    status-in-dev
    on Jun 1, 2026
  7. added a commit that references this issue on Jun 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bugcomplexity-lowpriority-p1

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions