[Bug]: Box nsjail exec fails when RLIMIT_NPROC fallback counts other processes
Runtime environment
- LangBot Community Edition v4.11.0b3, source deployment
- Alibaba Cloud Linux 3 (Linux 5.10, x86_64), Python 3.11.13
- langbot-plugin 0.6.19, nsjail 3.6, LocalAgent 0.1.10
- box.enabled=true, box.backend=nsjail, local stdio Box Runtime, default Box profile
- Host uses cgroup v1; cgroup v2 is unavailable to Box. The account running LangBot has about 718 threads across its other processes.
Exception
GET /api/v1/box/status reports enabled=true, available=true, and backend.name=nsjail. A real LocalAgent native exec call (printf NSJAIL_BOX_OK) reaches the Box Runtime, but fails on three attempts:
exit_code: 254
stdout: ""
stderr: /bin/sh: fork: retry: Resource temporarily unavailable
/bin/sh: fork: Resource temporarily unavailableA direct one-shot nsjail command on the same host can fork and run with --rlimit_nproc 1024, so the binary and namespace setup work.
Reproduction steps
- Use a Linux host without usable cgroup v2 where the LangBot/Box OS account already has more than 128 threads.
- Enable the local nsjail Box backend with the default profile (pids_limit=128).
- Select a model with func_call ability and have LocalAgent invoke native exec with a shell command that forks.
- Inspect the tool result and Box status.
The SDK 0.6.19 fallback passes --rlimit_nproc <spec.pids_limit> when cgroup v2 cannot be used. Linux applies RLIMIT_NPROC to all threads sharing the real UID, so unrelated LangBot account processes consume the sandbox's nominal 128-process budget.
Expected behavior
A default-profile sandbox should be able to execute commands while respecting a sandbox-scoped PID limit. If that cannot be enforced on this host, Box should make the limitation explicit rather than reporting an available backend whose exec cannot fork.
Source: langbot-app/LangBot