Skip to content

[BUG] Agent CPU alerts fire on normal runs: cpu_percent is on a host-core scale (0-2400% on 24 cores) but thresholds default to 80/95 #4529

Open

Description

@jordanallenlewis

Describe the bug
Agent CPU alerts fire on ordinary runs. check_docker_health computes container CPU the way docker stats does, against every host core:

num_cpus = stats["cpu_stats"].get("online_cpus", 1)
cpu_percent = (cpu_delta / system_delta) * num_cpus * 100   # monitoring_service.py:180

So 100% means one busy core, and the ceiling is online_cpus × 100. On a 24-core host that's 0–2400%. The default thresholds in MonitoringConfig (cpu_warning_percent: 80, cpu_critical_percent: 95, db_models.py:1353) read like a 0–100 scale. Any agent that keeps one core busy for a check interval (any Claude Code turn) is reported critical, then degraded, then recovered a minute later.

On one self-hosted install that came to 48 notifications in about 8 hours across 4 agents. Every reading was between 98% and 396%, and the agents are capped at 4 or 8 CPUs, so none of them was close to its limit.

To Reproduce

  1. Run Trinity on a host with more than one core, with agents capped at cpus: 4 (or no cap).
  2. Give an agent any task that keeps one core busy for ~30 s.
  3. Operations → Notifications: "Agent X has critical CPU usage — CPU usage at 10x%", "is degraded", "recovered".

Expected behavior
A CPU alert means the agent is near its own CPU limit. Two options:

  • Normalise to the container's limit: HostConfig.NanoCpus / 1e9, falling back to the CPU quota/period, then to online_cpus when there's no limit. 100% then means "using everything it's allowed", and the 80/95 defaults mean what they say.
  • Or keep the docker-stats scale and document it, scaling the defaults by the agent's CPU limit.

The first option is a backend change in check_docker_health (plus the cpu metric it records). Health cards and the circuit breaker would read the same normalised number.

Workaround
PUT /api/monitoring/config with cpu_warning_percent: 395, cpu_critical_percent: 795 (sized for 4- and 8-CPU agents).

Environment:

  • Trinity version: 1.0.0 self-hosted; the same code is on dev (monitoring_service.py:177-180, db_models.py:1353-1354)
  • Host: 24 logical cores, agents at 4 and 8 CPUs
  • OS: Debian 13, Docker 29.9.3

I can open a PR for the first option if you'd like it.

Activity

  1. added a commit that references this issue on Nov 17, 2026
    7d64a39
  2. added
    status-in-dev
    on Nov 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    priority-p2status-in-devtype-bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions