fix(spawn): stop subprocess agents from blocking on unread pipes#54
Merged
tjb-tech merged 1 commit intoHKUDS:mainfrom Mar 22, 2026
Merged
Conversation
a24ibrah
pushed a commit
to a24ibrah/ClawTeam
that referenced
this pull request
Mar 30, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
SubprocessBackend.spawn()launched long-lived agent processes with bothstdoutandstderrset tosubprocess.PIPE, but nothing ever drained those pipes. A noisy child process could eventually block once the OS pipe buffer filled up.What changed
stdoutnow goes tosubprocess.DEVNULLstderrnow goes tosubprocess.DEVNULLon-exitlifecycle hook stays in placeWhy this approach
There are two obvious fixes here: drain the pipes in the background, or stop creating unread pipes in the first place.
For this backend, the simpler choice is better. These subprocess agents are not managed as interactive streams, and the backend was never surfacing their output to callers. Redirecting to
DEVNULLremoves the hang risk without adding thread or process management.Compatibility / Security impact
on-exitbehavior is unchangedTest plan
uv run pytest -q tests/test_spawn_backends.py -k discards_output_and_preserves_exit_hook_and_registryuv run pytest -q tests/test_spawn_backends.pyuv run python -m pytest -qregister_agent(...)still receives the expected subprocess payloadEvidence / Actual results
uv run pytest -q tests/test_spawn_backends.py -k discards_output_and_preserves_exit_hook_and_registry1 passed, 24 deselected in 0.07suv run pytest -q tests/test_spawn_backends.py25 passed in 10.33suv run python -m pytest -q319 passed in 13.06sHuman verification
PIPEs that can fill and blockRisks / rollback