You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[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
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:
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
Run Trinity on a host with more than one core, with agents capped at cpus: 4 (or no cap).
Give an agent any task that keeps one core busy for ~30 s.
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
fix(monitoring): scale agent CPU alerts to the container limit (#4530)