Skip to content

fix(stdio): close owned agent stdio streams on shutdown - #218

Open
PsiACE wants to merge 1 commit into
mainfrom
fix/close-owned-agent-stdio-streams
Open

PsiACE wants to merge 1 commit into
mainfrom
fix/close-owned-agent-stdio-streams

Conversation

@PsiACE

@PsiACE PsiACE commented Nov 29, 2026 •

Copy link
Copy Markdown
Member

Closes owned stdio streams created by agent runners on exit, eliminating ResourceWarnings after stdin EOF.

Summary

  • Add internal _owned_stdio_streams() context manager in src/acp/stdio.py that closes the owned stdin read transport and bounds stdout close flush (timeout=2.0, aborting on timeout) without affecting caller-owned streams, and closes read_transport if POSIX stdout pipe setup fails.
  • Use _owned_stdio_streams() in v1 run_agent(), v2.run_agent(), and AgentProtocolRouter.run() when no streams are passed.
  • Add real-subprocess EOF and full-unread-stdout tests under -W error::ResourceWarning in tests/real_user/test_stdio_shutdown.py.

Verification

  • make gen-check
  • make check
  • make test (690 passed, 1 skipped, 0 warnings)

@PsiACE
PsiACE force-pushed the fix/close-owned-agent-stdio-streams branch from f91c050 to 42ce4c0 Compare November 29, 2026 06:38

This branch has not been deployed

No deployments
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.

1 participant