Skip to content

fix(claude-code-adapter): send the prompt over stdin, not argv; retry temp cleanup - #296

Merged
EmersonBraun merged 1 commit into
mainfrom
fix/windows-argv-length-and-tempdir-cleanup
Sep 22, 2026
Merged

EmersonBraun merged 1 commit into
mainfrom
fix/windows-argv-length-and-tempdir-cleanup

Conversation

@rembradtech

Copy link
Copy Markdown
Contributor

Summary

Two real, reproducible failures reviewing PRs on Windows tonight, hit on every single review attempted, regardless of file content:

  1. spawn ENAMETOOLONG — runClaude built args = ["-p", prompt], passing the whole prompt (system + conversation, and for a file review, the file's own content) as one CLI argument. Windows' ~32K total command-line length is exceeded by a real file's content plus review instructions regardless of the file's own size — even a single, unremarkable source file failed this way. No batching or token-budget config can fix this: it's the argv itself that's too long, independent of how many files or tokens are involved.

    Fix: claude -p (bare, no literal argument) reads its prompt from stdin instead — verified live. runLocalCli gained a stdin option (written to the child before closing it; empty otherwise, so existing callers that don't pass it see no behavior change), and runClaude/claudeCode now send the prompt that way.

  2. EBUSY: resource busy or locked — cleanup()'s rmSync(tempRoot, ...) crashed the whole run uncaught, on every single invocation observed. A spawned child's handle on a file under tempRoot can linger briefly past close on Windows, racing the parent's cleanup rmSync. fs.rmSync's own maxRetries/retryDelay options exist for exactly this documented behavior.

Test plan

  • npm run typecheck
  • New tests: the stdin option writes content to the child before it closes; omitting it still closes stdin empty (no behavior change for existing callers)
  • Full suite: 222/309 passing after this change vs. 220/307 before — same 86 pre-existing failures either way (Windows path-separator assertions unrelated to this PR, confirmed via git stash against this same branch point), plus the 2 new tests above, both passing
  • Live: re-ran a real PR review that failed with ENAMETOOLONG on every attempt before this fix (AgentsKit-io/agentskit-os#6233) — completed with neither ENAMETOOLONG nor EBUSY after this fix

https://claude.ai/code/session_0137fexM8CEcWe2N2Y7igkUY

… temp cleanup

Two real, reproducible failures reviewing PRs on Windows tonight, on
every single review attempted regardless of file content:

1. `runClaude` built `args = ["-p", prompt]`, passing the whole prompt
   (system + conversation +, for a file review, the file's content) as
   one CLI argument. Windows' ~32K total command-line length is
   exceeded by a real file plus review instructions regardless of the
   file's own size — even a single small source file failed as `spawn
   ENAMETOOLONG`. No batching/token-budget config can fix this: it is
   the argv itself that is too long, independent of how many files or
   tokens are involved.

   Fix: `claude -p` (bare, no literal argument) reads its prompt from
   stdin — verified live. `runLocalCli` gained a `stdin` option
   (written to the child before closing it, empty otherwise — no
   behavior change for existing callers that don't pass it) and
   `runClaude`/`claudeCode` now send the prompt that way instead.

2. `cleanup()`'s `rmSync(tempRoot, ...)` crashed the whole run
   uncaught with `EBUSY: resource busy or locked` on Windows, on every
   single invocation observed — a child process's handle on a file
   under `tempRoot` can linger past `close`, racing the parent's
   cleanup. `fs.rmSync`'s own `maxRetries`/`retryDelay` options exist
   for exactly this documented Windows behavior.

## Test plan
- Added: `stdin` option writes content to the child before closing
  it; omitting it still closes stdin empty (unchanged behavior)
- Full suite: 222/309 passing after this change vs. 220/307 before —
  same 86 pre-existing failures either way (Windows path-separator
  assertions unrelated to this fix, confirmed via `git stash` against
  this same branch point), plus the 2 new tests above, both passing
- Live: re-ran a real PR review that failed with `ENAMETOOLONG` on
  every attempt before this fix (AgentsKit-io/agentskit-os#6233) —
  completed with neither `ENAMETOOLONG` nor `EBUSY` after this fix
@EmersonBraun
EmersonBraun merged commit 504c72c into main Sep 22, 2026
5 checks passed
@EmersonBraun
EmersonBraun deleted the fix/windows-argv-length-and-tempdir-cleanup branch September 22, 2026 14:18
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.

2 participants