Skip to content

Agent slice TasksMax=25% drops to 2.6% after any daemon-reload on systemd < 260 #34058

Open

Description

@THEtheChad

What happened

About 10 agent sessions (Claude, Codex, Muse) on my WSL2 server failed over 20 minutes with SIGABRT, and the kernel logged fork rejected by pids controller for scopes in app-t3code.slice. The slice was capped at 10,018 tasks, but T3 asks for TasksMax=25%, which is 96,327 on this machine.

Diagnosis

agentScope.ts applies TasksMax=25% to app-t3code.slice with systemctl --user set-property --runtime (AGENTS_PARENT_PROPERTIES, added in #27176). On systemd 255–259 the live value is correct, but the runtime drop-in systemd writes for it says TasksMax=2.6%. The next systemctl --user daemon-reload from anything on the machine re-reads that file and cuts the cap by about 10×.

systemd cause: in v255–v259, bus_cgroup_set_tasks_max_scale (src/core/dbus-cgroup.c) computes whole percent (DIV_ROUND_UP(v * 100, UINT32_MAX), so 25% gives 26) and prints it as tenths (%u.%u%%, so "2.6%"). Fixed in v260 by systemd/systemd@9d15e09d5c (systemd/systemd#41011). Ubuntu 24.04 (255) and Debian 13 (257) still ship the bug. Absolute values and percentages written in unit files are both unaffected.

Suggested fix: keep 25% but send a count, the same way agentSliceMemoryLimits handles memory. The value is re-applied on every server start, so it still follows the machine:

// systemd before v260 writes a percentage passed to set-property back as a tenth of itself
// (25% -> "2.6%"), and the next daemon-reload applies that. Send the count instead.
function agentTasksMax(pidMax: number, threadsMax: number): string {
  return `TasksMax=${Math.floor(Math.min(pidMax, threadsMax) / 4)}`;
}

Read /proc/sys/kernel/{pid_max,threads-max}. If either can't be read, fall back to TasksMax=25%.

Steps to reproduce

Runs without T3 on systemd 255–259 (here 255.4, Ubuntu 24.04). Same call as agentScope.ts:

u=tasksmax-probe.slice
systemd-run --user --quiet --unit=tasksmax-hold --slice=$u sleep 60   # keep slice active like app-t3code.slice
systemctl --user set-property --runtime $u TasksMax=25%
systemctl --user show $u -p TasksMax      # 39984 = 25% of threads-max 159939 (correct)
cat /run/user/$UID/systemd/user.control/$u.d/50-TasksMaxScale.conf   # TasksMax=2.6%
systemctl --user daemon-reload
systemctl --user show $u -p TasksMax      # 4158 = 2.6%

In T3: start the server, let it spawn an agent, run systemctl --user daemon-reload, then systemctl --user show app-t3code.slice -p TasksMax.

Version

0.1.7 (also on main @ 871b009)

Environment

Windows 11 + WSL2 Ubuntu 24.04, kernel 6.18, systemd 255.4-1ubuntu8.18, T3 server as a systemd user service, Claude Code + Codex

Evidence

$ systemctl --user cat app-t3code.slice
# /run/user/1000/systemd/user.control/app-t3code.slice.d/50-TasksMaxScale.conf
[Slice]
TasksMax=2.6%

# app-t3code.slice pids.peak / pids.max / pids.events
10018
10018
max 1146010

kernel: cgroup: fork rejected by pids controller in /.../app-t3code.slice/app-t3code-agents.slice/app-t3code-agents-51c6bd42ce95.slice/t3code-claude-ebbb90d8.scope
kernel: cgroup: fork rejected by pids controller in /.../app-t3code.slice/app-t3code-agents.slice/app-t3code-agents-51c6bd42ce95.slice/t3code-codex-71cb9e43.scope

Related issues

None found (searched "TasksMax", "pids controller", "fork rejected"). Introduced by #27176.

Fix applied or workaround

A persistent drop-in that sorts after systemd's 50- file:

mkdir -p ~/.config/systemd/user/app-t3code.slice.d
printf '[Slice]\nTasksMax=25%%\n' > ~/.config/systemd/user/app-t3code.slice.d/90-tasksmax.conf
systemctl --user daemon-reload

Filed by

Claude Code (claude-opus-5-5), user-directed ops investigation (not t3 triage)

Activity

  1. added
    via-triage
    on Nov 10, 2026
  2. danilosoto commented on Nov 18, 2026

    @danilosoto

    Hit this too, on an AWS Graviton box (32 cores, Ubuntu 24.04, systemd 255.4) running a bunch of Claude + Codex sessions in parallel. After a daemon-reload the slice dropped from 116,575 to 12,123 tasks, and test runs started aborting on fork. pids.events showed ~384k rejected forks before I figured out what was going on.

    The 99- drop-in workaround held for me. I've since moved the box to 26.10 (systemd 261) and it's fine there without the drop-in, so +1 on sending an absolute count for everyone running this on 24.04.

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

    via-triage

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions