openai / openai/codex

Python SDK can drop an early turn/completed notification

Open
#41,078 15 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

app-server bug
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:

  1. turn/started or a turn delta for the new turn.
  2. turn/completed for that same turn.
  3. Return the successful turn/start response.

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:

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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.