Skip to content

feat(sandbox): warn when the session limit times agent memory exceeds the host's memory #5149

Closed

Description

@tale-code-bot

Split from #3977. Its "Host-headroom admission" criterion asks the spawner to warn at boot when
SANDBOX_MAX_SESSIONS × SANDBOX_AGENT_MEMORY is more than host RAM minus the reserve.
Re-checked against main at b2560c2 (TALE-47); line references are against that commit.

What happens

  • No SANDBOX_MAX_SESSIONS set: the spawner sizes its capacity from the host
    (autoSessionCapacity, services/sandbox/src/host-memory.ts:72).
    • It allows 768 MiB per session, at most two sessions per CPU, and never fewer than 8 sessions
      (:41-42).
    • Memory admission then checks each start against the host's free memory less a reserve
      (memoryShort, services/sandbox/src/session/session-routes.ts:1089).
    • It plans for a 512 MiB working set per agent session (host-memory.ts:31), not for the
      session's memory limit.
  • An explicit SANDBOX_MAX_SESSIONS: memory admission is off by design, because "the operator
    sized the host" (session-routes.ts:1086, :1093).
  • Nothing compares the session count with the session memory limit.
    • SANDBOX_AGENT_MEMORY (4g, or 8g with Docker inside, services/sandbox/src/config.ts:1155)
      is read only to size the build helper (services/sandbox/src/buildkitd.ts:324).
    • Its comment says the operator "sizes host RAM for the concurrent-session peak"
      (config.ts:1152), but nothing tells the operator when that peak cannot fit.
    • On Bug: concurrent runs of one agent pile into one sandbox session and can exhaust the host #3977's host (4 vCPU, 15.6 GiB), both paths give 8 sessions of 4 GiB, 32 GiB in all.
  • The platform checks counts only.
    • Its quota check compares the budget with /v1/limits
      (services/platform/backend/domains/governance/policy-writer.ts:257), which answers only
      maxSessions and deviceSessions (services/sandbox/src/server.ts:595).
    • The quota editor states only the count rule (services/platform/messages/en/sandboxes.yml:26).

Expected

  • A warning. At boot, and when the automatic sizing runs (server.ts:123), the spawner logs
    one warning when the session limit times the agent profile's memory exceeds the host's memory
    less the reserve (memoryReserveBytes).
    • The warning names the three figures and the settings that change them.
    • Unit tests use fixed memory figures.
    • Whether to clamp as well is the implementer's call, but an explicit setting should not change
      silently.
  • The figures reach the platform. /v1/limits (or /v1/capacity) carries the session memory
    limit and the host's total, so Settings › Sandboxes can say the same beside the deployment
    capacity, in EN, DE and FR.
  • The sizing rule is documented where the settings are: .env.example,
    services/sandbox/docs/sessions.md, docs/*/self-hosted/configuration/environment-reference.md
    and docs/*/platform/admin/sandboxes.md.

Related

Activity

  1. added
    agent-ready
    on Oct 30, 2026
  2. added a commit that references this issue on Oct 31, 2026
    8eeec91
  3. added 3 commits that reference this issue on Oct 31, 2026
    83067e9
    7993398
    bffc00f
  4. tale-code-bot commented on Oct 31, 2026

    @tale-code-bot
    CollaboratorAuthor

    Landed on release/0.6 with feature train #5197 (#5197, rebased in at 2026-10-31 11:15:15Z) as 7993398 (TALE-245, "feat(sandbox): warn when the session limit exceeds the host's memory"). release/0.6 was then rebased onto main df6105c at 11:25Z, where this commit is now bffc00f. It ships with 0.6.0. GitHub closes an issue only for a commit on main, so the feature-train role (TALE-239) closes it.

  5. added 19 commits that reference this issue on Oct 31, 2026
    9e362a7
    edf78fa
    b1bdd70
    3079cd5
    7b64acb
    8b09862
    8c1381b
    01adf72
    fc993a5
    ee6909e
    a16d04d
    fab0d45
    2d848d2
    047ae00
    7c54d18
    8bd75c1
    314fe47
    374291b
    a3ad3c5
  6. added a commit that references this issue on Nov 15, 2026
    b113ca2
  7. added a commit that references this issue on Nov 23, 2026
    610252a
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

    agent-readyfeat

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions