Skip to content

feat(server): the host can manage the agents' memory - #2

Open
znaniye wants to merge 1 commit into
v0.1.11+ossystemsfrom
v0.1.11+ossystems-agent-memory
Open

znaniye wants to merge 1 commit into
v0.1.11+ossystemsfrom
v0.1.11+ossystems-agent-memory

Conversation

@znaniye

@znaniye znaniye commented Nov 25, 2026

Copy link
Copy Markdown

Summary

T3CODE_AGENT_SLICE_MEMORY_POLICY=host-managed leaves app-t3code-agents.slice's memory to whoever runs the machine. Unset or automatic keeps T3 Code's caps. Any other value logs a warning and keeps them.

 applyMemoryLimits                       # apps/server/src/process/agentScope.ts
+  if policy is host-managed
+    return                              # no MemoryHigh/MemoryMax on the agents slice
   total = os.totalmem()
   set-property app-t3code-agents.slice MemoryHigh=… MemoryMax=…
 set-property app-t3code.slice CPUWeight=10 IOWeight=10 TasksMax=25%   # unchanged

Why. In a workbench workspace the VM boots with 2 GiB and its host plugs more memory as it runs short, up to its max. T3 Code takes the cap from the RAM the VM has when an agent starts: 1.5 GiB right after boot. Under 0.1.10's throttle, a clone took over 10 minutes. The host already sizes the VM, so a second cap inside it only gets in the way.

Upstream proposes the same option in pingdotgg#24717. Drop this commit once that merges.

Evidence

  • Before: in the new test, the agents slice gets MemoryHigh/MemoryMax even with the variable set:
    × leaves agent memory to the host when it manages it
    expected [ 'app-t3code-agents.slice', …(2) ] to deeply equal [ 'app-t3code.slice' ]
    
    After: vp test run src/process/agentScope.test.ts passes 17 of 17. Only the parent slice's CPU, IO and task limits are set, and scopes keep OOMPolicy=stop.
  • pnpm run typecheck for apps/server exits 0, and vp fmt --check is clean.
  • nix build of t3code-nix with this as patch 0014 succeeds, install check included.

Merge Danger

Door: two-way

The change is opt-in. Without the variable, behaviour is unchanged.

Blast Radius: opt-in

Only servers started with the variable stop capping their agents. Limits set by an earlier run stay until the user manager restarts.

T3 Code caps the agents slice at a share of the RAM the machine has when an
agent starts. A VM whose host plugs memory as it runs short starts small: in
one that boots with 2 GiB and may grow to 16, agents were capped at 1.5 GiB,
or throttled at 1 GiB with swap, and the cap only caught up at the next agent
launch. An administrator's own drop-in for the slice loses to the runtime
override too.

T3CODE_AGENT_SLICE_MEMORY_POLICY=host-managed leaves the slice's memory alone.
Unset or automatic keeps the caps; anything else warns and keeps them. Scopes,
OOM reporting and the parent slice's CPU, IO and task limits are unchanged.
The same option is proposed upstream in pingdotgg#24717.
@github-actions github-actions Bot added vouch:trusted PR author is trusted by repo permissions or the VOUCHED list. size:M labels Nov 25, 2026

This branch has not been deployed

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

Labels

size:M vouch:trusted PR author is trusted by repo permissions or the VOUCHED list.

Development

Successfully merging this pull request may close these issues.

1 participant