Skip to content

fix(subagents): drain spawn hook stdout before exiting - #80

Open
thisisjun786 wants to merge 5 commits into
lidge-jun:devfrom
thisisjun786:fix/spawn-hook-stdout-drain
Open

fix(subagents): drain spawn hook stdout before exiting#80
thisisjun786 wants to merge 5 commits into
lidge-jun:devfrom
thisisjun786:fix/spawn-hook-stdout-drain

Conversation

@thisisjun786

Copy link
Copy Markdown

Problem

Large spawn-hook responses are truncated when stdout is a pipe on POSIX. The CLI calls process.exit(0) immediately after process.stdout.write(out), before the asynchronous write drains. This can discard the entire updatedInput rewrite, including configured subagent model/effort and attached skill instructions.

A real three-skill spawn produced 81,754 bytes, but the installed CLI emitted only 65,536 bytes and exited 0. Changing pipe capacity to 4 KiB or 8 KiB moved the truncation boundary accordingly.

Change

Allow pending stdout writes to finish by using process.exitCode = 0 and natural exit. Regenerate the shipped JavaScript and add real CLI regression coverage for large piped JSON, including model/effort and message preservation.

Validation

  • Linux / Node 24.20.0: restored the original exit temporarily; the new CLI regression fails with truncated/unterminated JSON. Restored the patch; source and committed dist both pass.
  • Focused spawn-hook suite: 80 passed, 0 failed.
  • Full npm test: 2,580 total, 2,509 passed, 0 failed, 71 skipped. Used an isolated TMPDIR because this host has an unrelated /tmp/.git marker that affects the existing project-root tests.
  • npm run build, inventory check with measured total 2,580, and repository gate: passed. README test badges were regenerated as required by CI.
  • Patched installed CLI: complete 81,754-byte JSON at 4/8/64 KiB pipe capacity.
  • Live fresh worker spawn with three skill attachments and no explicit model/effort: project-configured model/effort preserved; worker ran six checks, wrote its evidence receipt, and completed normally.

No role detection, configuration schema, or policy changes. Local live verification is Linux-only; the existing CI matrix covers macOS and Windows.

lidge-jun and others added 5 commits September 6, 2026 14:03
release: promote CodexClaw 0.2.18
docs: promote corrected hook lifecycle references
chore(release): promote v0.2.19 quiet peer coordination
chore(release): promote v0.2.20 native-stack opt-in policy
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