Skip to content
Source
Sign inSign up
pingdotgg/t3code

fix(server): stop throttling agents when swap is full #39976

OpenSikun(GitHub profile, opens in a new tab)wants to merge 1 commit intomain fromrefs/pull/39976/headopened View on GitHub

Sikun(GitHub profile, opens in a new tab)commented

Problem

On a Linux systemd host with configured swap fully occupied, Codex and Antigravity stalled before sending their prompts. The host showed sustained memory reclaim. The shared agent slice’s policy only checked SwapTotal, so it kept applying a finite MemoryHigh even when SwapFree was zero.

Under sustained memory pressure, all agents on the host can stop responding. To recover, the operator has to access the server through a separate route, such as SSH.

Change

Treat zero free swap like zero configured swap. On the next agent launch, use the existing unlimited MemoryHigh policy and keep the same MemoryMax. If swap becomes available again, a later launch restores the soft limit.

Scope

This covers the exhausted-swap case of the agent-slice policy behind #39287, with symptoms previously reported in #25918. It uses the existing launch-time check.

Verification

  • The focused regression failed on main because the finite soft limit stayed in place. With the patch, all 16 tests in agentScope.test.ts passed. The test covers exhausted swap, recovered swap, and removal of swap.

  • I evaluated both revisions’ policies with a synthetic 16 GiB host snapshot and SwapTotal: 524284 kB, SwapFree: 0 kB. Applying the resulting limits in isolated transient systemd scopes produced these cgroup values.

    base:  memory.high=10737418240 memory.max=12884901888
    patch: memory.high=max         memory.max=12884901888

    This verifies the applied limits without exhausting host swap or running a provider turn.

GPT-6.2-Sol via the Codex harness in T3 Code.

    1. tanstack-source added labelsbug

    2. coderabbitai[bot](GitHub profile, opens in a new tab)commented
      Explain Change →

      No actionable comments were generated in the recent review.

      Walkthrough

      The memory-limit logic now treats zero SwapTotal or zero SwapFree as no available swap. The test fixture provides configurable free swap, and the test checks MemoryHigh with zero and positive free swap.

      Changes: Swap availability detection

      Layer / File(s)Summary
      Detect swap availability and verify memory limits
      apps/server/src/process/agentScope.ts, apps/server/src/process/agentScope.test.ts
      Swap detection now checks whether SwapTotal or SwapFree is 0 kB. The memory fixture emits configurable SwapFree, and the test checks MemoryHigh behavior when free swap is zero or positive.

      Estimated code review effort: 2 (Simple) | ~10 minutes

      Change: Bug fix

      Suggested reviewers: juliusmarminge, maria-rcks

      Merge Risk: Minimal · up to 995eb

      Agents are no longer throttled by the soft memory limit when swap is fully used. The hard limit is unchanged, and the new behavior is covered by tests. No merge-blocking risk is identified.

      Pre-merge checks: Passed 4

      Check nameStatusExplanation
      Title checkPassedThe title "fix(server): stop throttling agents when swap is full" names the main change: the agent-slice memory policy now treats exhausted free swap like zero configured swap, so MemoryHigh no longer…
      Linked Issues checkPassedCheck skipped because no linked issues were found for this pull request.
      Out of Scope Changes checkPassedCheck skipped because no linked issues were found for this pull request.
      Description checkPassedThe description is mostly complete and follows the template. It states the problem (exhausted swap leaves a finite MemoryHigh applied, stalling agents), the change (treat zero free swap like zero conf…
      Full details: Title check

      Explanation

      The title "fix(server): stop throttling agents when swap is full" names the main change: the agent-slice memory policy now treats exhausted free swap like zero configured swap, so MemoryHigh no longer throttles agents. It follows conventional commit form and is specific to the changeset.

      Full details: Description check

      Explanation

      The description is mostly complete and follows the template. It states the problem (exhausted swap leaves a finite MemoryHigh applied, stalling agents), the change (treat zero free swap like zero configured swap, use the unlimited MemoryHigh policy, keep MemoryMax), and the scope (exhausted-swap case of the agent-slice policy, linked to #39287 and #25918). Verification is concrete: the focused regression failed on main and passed with the patch (16 of 16 tests in agentScope.test.ts), and the author ran a synthetic cgroup-value comparison. Gaps: the Scope section does not state whether the referenced issues are the bug reports, and the template asks for a conventional commit title, which is not shown in the description. The template also asks for the model and harness used; the author gives 'GPT-6.2-Sol via the Codex harness in T3 Code', which satisfies that. Remaining items are minor.

      Finishing Touches

      Generate unit tests (beta)

      • Create a new PR
      • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
      Recent review info

      Run configuration

      Commits

      Reviewing files that changed from the base of the PR and between d984b71385910bd575d4ed10ae6c0d1caf48f008 and 995ebfe96577ccab2ebc97ee155000c81ca436ee.

      Files selected for processing: 2

      • apps/server/src/process/agentScope.test.ts
      • apps/server/src/process/agentScope.ts

      Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.

Sign in to join this conversation.