Title: Connection._receive_loop EOF does not reject pending requests, causing infinite hang · Issue #85 · agentclientprotocol/python-sdk · GitHub
Open Graph Title: Connection._receive_loop EOF does not reject pending requests, causing infinite hang · Issue #85 · agentclientprotocol/python-sdk
X Title: Connection._receive_loop EOF does not reject pending requests, causing infinite hang · Issue #85 · agentclientprotocol/python-sdk
Description: Summary When the remote ACP subprocess crashes or closes its stdout, Connection._receive_loop exits cleanly on EOF without rejecting pending outgoing requests. Any in-flight send_request() futures hang forever. This means a subprocess cr...
Open Graph Description: Summary When the remote ACP subprocess crashes or closes its stdout, Connection._receive_loop exits cleanly on EOF without rejecting pending outgoing requests. Any in-flight send_request() futures ...
X Description: Summary When the remote ACP subprocess crashes or closes its stdout, Connection._receive_loop exits cleanly on EOF without rejecting pending outgoing requests. Any in-flight send_request() futures ...
Opengraph URL: https://github.com/agentclientprotocol/python-sdk/issues/85
X: @github
Domain: github.com
IPv4 address: 140.82.114.3
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Connection._receive_loop EOF does not reject pending requests, causing infinite hang","articleBody":"## Summary\n\nWhen the remote ACP subprocess crashes or closes its stdout, `Connection._receive_loop` exits cleanly on EOF without rejecting pending outgoing requests. Any in-flight `send_request()` futures hang **forever**.\n\nThis means a subprocess crash during `initialize()`, `new_session()`, or `prompt()` is silently converted into an infinite hang instead of raising an error.\n\n## Reproduction\n\n1. Spawn an ACP subprocess that crashes immediately on startup (e.g., `claude-agent-acp` on Node.js \u003c 20 which crashes with `SyntaxError`)\n2. Call `conn.initialize()` — it sends the JSON-RPC request and awaits the response future\n3. The subprocess exits with code 1, stdout closes\n4. `_filter_jsonrpc_lines` reads EOF → feeds EOF to `filtered_reader`\n5. `_receive_loop` reads empty line → breaks normally (no exception)\n6. `TaskSupervisor._on_done` calls `task.result()` → returns `None` (clean exit)\n7. `_on_receive_error` is **never called** (only fires on exceptions)\n8. `_state.reject_all_outgoing()` is **never called**\n9. The `initialize()` future **hangs forever**\n\n## Root Cause\n\nIn `connection.py`:\n\n```python\nasync def _receive_loop(self) -> None:\n try:\n while True:\n line = await self._reader.readline()\n if not line:\n break # EOF — exits cleanly, no exception raised\n ...\n except asyncio.CancelledError:\n return\n```\n\nThe `_on_receive_error` callback is registered via `TaskSupervisor.create(..., on_error=self._on_receive_error)`, but `_on_done` only calls `on_error` when `task.result()` raises an exception. A clean EOF exit does not raise, so `reject_all_outgoing` is never invoked.\n\n## Suggested Fix\n\nReject all pending requests when the receive loop exits on EOF:\n\n```python\nasync def _receive_loop(self) -> None:\n try:\n while True:\n line = await self._reader.readline()\n if not line:\n break\n ...\n except asyncio.CancelledError:\n return\n # EOF: remote end closed. Reject any in-flight requests so callers\n # get an exception instead of hanging forever.\n self._state.reject_all_outgoing(\n ConnectionError(\"Connection closed: remote end sent EOF\")\n )\n```\n\n## Impact\n\nWe discovered this while debugging why ACP evals (SWE-bench Multimodal) hang indefinitely for certain repos. The ACP subprocess crashed on startup due to incompatible Node.js versions, but instead of getting an error, the SDK hung forever at `conn.initialize()`. This affected ~65% of eval instances. \n\n## Environment\n\n- `agent-client-protocol` version: 0.8.1\n- Python: 3.12/3.13\n- OS: Linux (K8s pods)","author":{"url":"https://github.com/simonrosenberg","@type":"Person","name":"simonrosenberg"},"datePublished":"2026-04-01T18:15:28Z","url":"https://github.com/agentclientprotocol/python-sdk/issues/85"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:c974d85f-7b73-d97c-4919-f04d92add46f |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 9422:194442:377758:4A13BD:6B04BA45 |
| html-safe-nonce | 8f75596e1ce8c200be0f4ad1ebdc8ff3f0f9f5b21dcf97a0a69019bdce5092c6 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5NDIyOjE5NDQ0MjozNzc3NTg6NEExM0JEOjZCMDRCQTQ1IiwidmlzaXRvcl9pZCI6IjE2NDA0NzgwOTM1MzU5MTg2NjIiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 7ccf8b410452e3535992f7a4f80d559a11a996671fc2152dc2dc1712815c0c1e |
| hovercard-subject-tag | issue:4188934171 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/agentclientprotocol/python-sdk/85/issue_layout |
| twitter:image | https://opengraph.githubassets.com/62ac0e21ef12cc1b314ce58d6df69e61c3a5003ab6de70c8b2a6d7b828d1f0c7/agentclientprotocol/python-sdk/issues/85 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/62ac0e21ef12cc1b314ce58d6df69e61c3a5003ab6de70c8b2a6d7b828d1f0c7/agentclientprotocol/python-sdk/issues/85 |
| og:image:alt | Summary When the remote ACP subprocess crashes or closes its stdout, Connection._receive_loop exits cleanly on EOF without rejecting pending outgoing requests. Any in-flight send_request() futures ... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | simonrosenberg |
| hostname | github.com |
| expected-hostname | github.com |
| None | 378bd702ac792b3550e484ad39d9a898fcd25bb52ba6962b0c9cc457c1ea71c7 |
| turbo-cache-control | no-preview |
| go-import | github.com/agentclientprotocol/python-sdk git https://github.com/agentclientprotocol/python-sdk.git |
| octolytics-dimension-user_id | 235308037 |
| octolytics-dimension-user_login | agentclientprotocol |
| octolytics-dimension-repository_id | 1051445009 |
| octolytics-dimension-repository_nwo | agentclientprotocol/python-sdk |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 1051445009 |
| octolytics-dimension-repository_network_root_nwo | agentclientprotocol/python-sdk |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | b032e77f1ea437ede6c115446a0a467709b468e7 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
| Server | github.com |
| Content-Type | text/html; charset=utf-8 |
| Cache-Control | max-age=0, private, must-revalidate |
Viewport: width=device-width