Skip to content

fix(tools): raise the open-file limit at startup + actionable fd-quota errors (#122) - #172

Merged
justrach merged 1 commit into
mainfrom
fix/122-fd-limit
Jul 12, 2026
Merged

justrach merged 1 commit into
mainfrom
fix/122-fd-limit

Conversation

@justrach

Copy link
Copy Markdown
Owner

What

  • std.process.raiseFileDescriptorLimit() in main() before subcommand dispatch: lifts the soft NOFILE cap to the OS hard cap (Darwin: OPEN_MAX 10240 vs the 256 default). Zig 0.16.0 std ships this with correct Darwin clamping, so the fix is the one-liner discussed on the issue.
  • tools.failure() special-cases ProcessFdQuotaExceeded with an actionable message (what it means, retry sequentially, ulimit -n 4096) instead of the bare error name.
  • The background-job spawn path no longer suggests "run it in the foreground instead" for an fd-quota hit — backgrounding costs more fds, so that advice was actively wrong for this error.

Why

The audit on #122 disproved the FD-leak theory (graff's own FD count is flat at 11 across turns; 150 sequential bash spawns under ulimit -n 256 all succeed) — the failure mode is parallel tool/subagent/MCP fan-out pressure against the 256 default. Raising the limit at startup defuses it.

Verification (end-to-end A/B)

Scripted lmstudio-slot mock orders a bash: ulimit -n tool call through a real --json turn, parent shell capped at ulimit -n 256:

binary child sees
this branch 10240
installed v0.0.200 256

zig build + zig build test clean.

Closes #122 (remaining items on that issue — fan-out caps — are follow-up material; the limit raise + error message were the actionable core).

…a errors (#122)

std.process.raiseFileDescriptorLimit() in main() before subcommand dispatch
lifts the soft NOFILE cap to the OS hard cap (Darwin: OPEN_MAX 10240 vs the
256 default), so parallel tool/subagent/MCP fan-out in one turn no longer
dies with ProcessFdQuotaExceeded. tools.failure() and the background-job
spawn path now explain an fd-quota hit and what to do about it instead of a
bare error name (the old job-spawn advice — run it in the foreground — was
actively wrong for this error).

Verified end-to-end vs a scripted lmstudio mock: under ulimit -n 256 a bash
tool child sees 10240 with this fix, 256 on v0.0.200.

Co-Authored-By: blackfloofie <265516171+blackfloofie@users.noreply.github.com>
@justrach
justrach merged commit 78b83bb into main Jul 12, 2026
6 checks passed
@justrach
justrach deleted the fix/122-fd-limit branch July 15, 2026 10:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Long sessions can exhaust 256-FD limit and break shell tools with ProcessFdQuotaExceeded

1 participant