Skip to content

ui-sdk: bound each agent worker's memory, processes, file size and CPU, and report which limits the host enforces #1660

Closed

Description

@schlessera

Guardrail class: G1 (system integrity: resource exhaustion).

Context

Decision: docs/decisions/governed-writable-workers.md ("Resource limits (G1)"). In the maintainer's 2026-10-11 addition to #1636, resource exhaustion is part of system integrity. The /dev/shm budget from #1621 and #1625 is one instance of it.

The launcher sets namespaces and capabilities but no resource limits (export function workerCommand, packages/ui-sdk/src/server/worker-launcher.ts:105). The bootstrap validates descriptors before execve (export function workerBootstrap, worker-launcher.ts:146).

Scope

  • rlimits. The trusted bootstrap sets RLIMIT_AS, RLIMIT_NPROC, RLIMIT_FSIZE and RLIMIT_NOFILE before execve, with generous defaults recorded in docs/hosting/agent-workers.md. Measure them first: a Claude turn, a pi turn, a brain index and a Chromium render must pass under them.
  • cgroups. When the server runs in a delegated cgroup v2 subtree, as under systemd user delegation or a container with cgroupns, it creates one child cgroup per worker with memory.max, pids.max and cpu.max. When it cannot, it records which limits are absent.
  • Status. The result goes into ui-server: learn at boot that the host cannot run agent workers and report it, instead of failing every turn #1632's host status and into the capabilities note.
  • Roadblocks. A worker step that fails on a limit is recorded as a roadblock, with the limit named.

Out of scope

Acceptance criteria

  • A fixture worker that forks without bound is stopped by RLIMIT_NPROC or pids.max, and the host stays responsive. A test with a short timeout shows this.
  • A fixture that allocates past the memory limit fails inside the worker only.
  • The four first-party workloads named above pass under the defaults. The test records their peak usage.
  • Host status reports enforced and absent limits. A test runs it on a host without delegation.
  • Mutation receipt: drop the NPROC limit and the fork test fails.

Verification

ui-sdk tests on a supported Linux host and the integrated worker proof, then bun run check:pr --base origin/main.

Contract impact

Additive status fields. Minor changeset.

Activity

  1. added
    type: feat
    area: ui-sdk
    area: ui-server
    priority: p1
    agent-ready
    security
    on Oct 11, 2026
  2. self-assigned this
    on Oct 11, 2026
  3. schlessera commented on Oct 11, 2026

    @schlessera
    OwnerAuthor

    Claiming (claim token gov-1660-a04b). Branch: feat/1660-worker-resource-limits. Plan: rlimits in the trusted worker bootstrap before execve, an optional per-worker cgroup v2 child when the server's cgroup is delegated, a named worker_resource_limit failure class, limits in the host status and the capabilities note, host-configurable generous defaults.

  4. schlessera commented on Oct 11, 2026

    @schlessera
    OwnerAuthor

    Coordination from #1654 (PR #1695): the capabilities note now has a seam for limits. workerSandboxNote(sandbox, { limits }) (packages/ui-sdk/src/server/worker-sandbox.ts) takes WorkerNoteLimit entries ({ name, value, onHit }), each rendered from the value that enforces it, as a closing "Limits in this turn:" list. Suggest #1692 passes its resolved limits there instead of appending a separate note, so both backends keep injecting one generated text.

  5. added this to the 0.42.0 milestone on Oct 11, 2026
  6. schlessera commented on Oct 12, 2026

    @schlessera
    OwnerAuthor

    Merged in #1692 as 2b196b3. Its parent is 703a922, and its tree is the one CI tested on head 943f99a: all CI jobs and contract passed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

agent-readyarea: ui-sdkarea: ui-serverpriority: p1securitytype: feat

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions