openai/codex · error · RuntimeError
turn is not registered for streaming
Error message
turn {turn_id!r} is not registered for streaming What it means
next_turn_notification was called for a turn_id with no registered stream queue in _turn_notifications. Turn events are only routed after register_turn; requesting a stream for an unknown, finished, or unregistered turn is rejected instead of blocking forever.
Solutions
- Start the turn through the streaming API and use the returned turn id; do not attach stream listeners to unknown turns.
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at sdk/python/src/openai_codex/_message_router.py:115 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of openai/codex@339751715c (2026-08-25).
Data as JSON: /api/errors/02eee8d760b4942b.
Report an issue: GitHub.
Appendix: source
Thrown at sdk/python/src/openai_codex/_message_router.py:115
# caller receives the TurnHandle and starts streaming.
pending = self._pending_turn_notifications.pop(turn_id, deque())
self._turn_notifications[turn_id] = turn_queue
for notification in pending:
turn_queue.put(notification)
def unregister_turn(self, turn_id: str) -> None:
"""Stop routing future turn events to the stream queue."""
with self._lock:
self._turn_notifications.pop(turn_id, None)
def next_turn_notification(self, turn_id: str) -> Notification:
"""Block until the next notification for a registered turn."""
with self._lock:
turn_queue = self._turn_notifications.get(turn_id)
if turn_queue is None:
raise RuntimeError(f"turn {turn_id!r} is not registered for streaming")
item = turn_queue.get()
if isinstance(item, BaseException):
raise item
return item
def register_goal(self, thread_id: str) -> _GoalOperationState:
"""Register one thread-scoped logical goal operation before it starts."""
state = _GoalOperationState(thread_id=thread_id)
state.activate_turn_routing()
return self._register_goal(state)
def reserve_goal(self, thread_id: str) -> _GoalOperationState:
"""Reserve a thread route without accepting physical turns yet."""
return self._register_goal(_GoalOperationState(thread_id=thread_id))
def _register_goal(self, state: _GoalOperationState) -> _GoalOperationState:
with self._lock:
if state.thread_id in self._goal_operations:View on GitHub (pinned to 339751715c)