Skip to content

CloudAgentNext - Enable tool cgroup resource limits for all orgs#4476

Merged
eshurakov merged 1 commit into
mainfrom
crocus-fisher
Jul 9, 2026
Merged

CloudAgentNext - Enable tool cgroup resource limits for all orgs#4476
eshurakov merged 1 commit into
mainfrom
crocus-fisher

Conversation

@eshurakov

Copy link
Copy Markdown
Contributor

What

Permanently enable the sandbox tool/server cgroup partition in production (was disabled for every org by default).

Changes

Adds production vars to services/cloud-agent-next/wrangler.jsonc:

  • TOOL_CGROUP_ORG_IDS=* — opens the per-org gate to all orgs (was unset → off for everyone)
  • TOOL_CGROUP_MODE=enforce — applies memory.max to the tool slice (was defaulting to off)
  • TOOL_CGROUP_RESERVE_MB=1024 — 1GB reserved back from the tool cap (default was 1536)
  • TOOL_CGROUP_CPU_WEIGHT=50 — tool slice cpu.weight; the kilo-server slice keeps the kernel default (100), giving the server 2x the CPU share of tools under contention

Effect

Tool cap = MemTotal − 1GB. Smallest sandbox (4GB) yields a 3GB cap, clearing the 1GB minimum-cap floor on every container class, so enforce applies everywhere. A runaway tool is now OOM-killed in seconds instead of thrashing the whole container.

Dev (env.dev) stays disabled (TOOL_CGROUP_ORG_IDS=""); macOS local dev can't do cgroups.

Verification

  • wrangler.jsonc parses; production values confirmed, dev unchanged.
  • Config-reading tests pass (40/40): queue-config.test.ts, devcontainer.test.ts.
  • Cgroup gating/passthrough tests pass (130/130): cloudflare-agent-sandbox.test.ts, wrapper-client.test.ts.
  • Wrapper cgroup unit tests pass (216/216).

Permanently enable the sandbox tool/server cgroup partition in production
by setting the per-org gate to all orgs (TOOL_CGROUP_ORG_IDS=*), enforce
mode (memory.max applied), 1GB reserved memory, and tool cpu.weight 50
(server slice keeps the kernel default of 100 for 2x priority).
@kilo-code-bot

kilo-code-bot Bot commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

Code Review Summary

Status: No Issues Found | Recommendation: Merge

Executive Summary

Reviewed the 4-line wrangler.jsonc addition enabling tool cgroup enforcement in production; the reserve/CPU-weight values are within validated ranges and cannot produce a zero/negative memory cap given the wrapper's existing min-cap fallback logic.

Files Reviewed (1 files)
  • services/cloud-agent-next/wrangler.jsonc

Reviewed by claude-sonnet-5-20260630 · Input: 14 · Output: 4K · Cached: 354.2K

Review guidance: REVIEW.md from base branch main

@eshurakov eshurakov merged commit 3038a6d into main Jul 9, 2026
15 checks passed
@eshurakov eshurakov deleted the crocus-fisher branch July 9, 2026 19:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants