Repository navigation
Description
What happens
On a Docker sandbox host every agent session runs under --cpus=$SANDBOX_AGENT_CPUS (default 2, services/sandbox/src/session/docker-session-args.ts). A session that builds at that cap is throttled, and a throttled task counts as stalled in every cgroup above it up to the root. So /proc/pressure/cpu some reads about 70 % for one throttled session and about 90 % for two, while most of the host's CPUs are idle.
Host admission judges exactly that reading (services/sandbox/src/host-pressure-assessment.ts):
- under the
defaultpreset, session starts are held atSANDBOX_CPU_PRESSURE_PERCENT(60); - heavy-phase leases are always judged conservatively, at 20 % CPU pressure and released only below 10 %.
tightenThresholdskeeps the conservative 20 whatever the deployment sets.
One session building at its own quota therefore holds every new start, and every other session's lease for an install, a build or a test suite, on a host that has room for them.
Observed
agents.tale.dev on 2026-10-30, v0.5.94, 12 threads, 13 sessions at cpu.max 200000 100000:
- Host CPU
some avg10was 86–89 %, whilempstatshowed 40 % idle and a load of 6. - The two Reviewer sessions that were building read 70–71 %
some avg10in their own cgroups. - For about ten minutes dispatch stopped with
host_pressure, and a standing role's run started no build. - A Reviewer's build lease was refused from 15:28 to 15:35 UTC, which cost it a landing.
After every session's quota was raised to the host's CPU count (docker update --cpus 12, SANDBOX_AGENT_CPUS=12), host CPU some avg10 fell to 4.6 % at 51 % CPU use.
Expected
The CPU pressure that admission reads measures contention for the host's CPUs, not a session's own quota. A host with idle CPUs admits a start and grants a lease, and a host whose CPUs are contended holds them, as it does now.
Done means
- A host-pressure assessment test: sessions throttled by their quota on a host with idle CPUs are admitted.
- The same test with the host's CPUs contended stays pressed, for both starts and leases.
- The environment reference and
services/sandbox/README.md("Host admission") say what the CPU signal measures.
The design is open. For example, the CPU signal could be judged from something quota throttling cannot inflate (the host's busy share, or the stall with the sessions' throttled time taken out). Or the default session quota could follow the host's CPUs, with the low CPU weight that config.ts already gives sessions sharing them under contention.
Activity
fix(sandbox): judge CPU pressure by how busy the host's CPUs are