Python SDK can drop an early turn/completed notification
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 125k
- Forks
- 19.4k
- PR merge metrics
- PR metrics pending
Description
Summary
The Python SDK can wait indefinitely when a server sends turn/* notifications before the turn/start response. In particular, an early turn/completed notification is discarded before the response registers the turn queue.
Reproduction
Use a server or transport that emits these notifications while the turn/start request is still awaiting its response:
turn/startedor a turn delta for the new turn.turn/completedfor that same turn.- Return the successful
turn/startresponse.
Expected: after turn_start returns, both notifications are available to the caller, including the terminal completion.
Actual: the router has no registered turn queue when the notifications arrive, drops the terminal event during cleanup, and a subsequent wait for completion can block forever.
Root cause
The client registered the turn notification queue only after the RPC response arrived. The router buffered some unregistered notifications by turn ID, but treated an unregistered turn/completed as a cleanup-only event and discarded it.
PR-ready reference
I prepared a tested reference branch with a narrow reservation-and-replay fix:
- Commit: https://github.com/Hughhhhcoder/codex/commit/5b73a326836281eb4c2402fb08453d4fb6075a4c
- Branch:
codex/codex-message-router-completed
The client reserves the thread before sending turn/start, buffers early notifications, replays the response turn's notifications into its queue, and clears pending state if the request fails.
Validation
PYTHONPATH=src pytest -q tests/test_client_rpc_methods.py — 19 passed.
Because the current contribution policy does not accept external code contributions or pull requests, I am submitting this analysis and reference commit here instead of opening a PR. Please feel free to implement or adapt the fix.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the Python client’s turn_start path and the message router, focusing on notification queue registration, buffering, replay, and failed-request cleanup. Reproduce the early turn/started, turn delta, and turn/completed sequence, then run tests/test_client_rpc_methods.py. Done means both early notifications remain available after turn_start returns and completion does not block indefinitely.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- api
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Active
- Clarity
- Clearly specified
- Newbie friendliness
- 68/100