Commit 08679ea
fix: read the per-turn notification queue so Codex turns stop hanging
The openai-codex SDK routes every turn-scoped notification into a dedicated queue and
drops it into a pending buffer when the turn is not registered; only unscoped events
reach the global queue. `next_notification()` -- which in the old SDK was the whole
stream -- now returns just those global leftovers, so our loop blocked forever while
the turn's deltas, items and turn/completed piled up unread. Same method name, a
narrower contract: the rename-only migration sailed straight past it.
Register the turn and drain its queue, as the SDK's own TurnHandle.stream() does.
Registration replays anything buffered between turn/start returning and the register
call, so no early event is lost.
Also route notifications back through loop.call_soon_threadsafe: the worker thread was
calling asyncio.Queue.put_nowait directly, which is not thread-safe.
Verified with a live turn against codex 0.144.3: 6 events, reply "PONG".
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>1 parent 79cfc64 commit 08679ea
1 file changed
Lines changed: 31 additions & 25 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
304 | 304 | | |
305 | 305 | | |
306 | 306 | | |
| 307 | + | |
307 | 308 | | |
308 | 309 | | |
309 | 310 | | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
310 | 316 | | |
311 | 317 | | |
312 | 318 | | |
| |||
316 | 322 | | |
317 | 323 | | |
318 | 324 | | |
319 | | - | |
320 | | - | |
321 | | - | |
322 | | - | |
323 | | - | |
324 | | - | |
325 | | - | |
326 | | - | |
327 | | - | |
328 | | - | |
329 | | - | |
330 | | - | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
| 334 | + | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
331 | 338 | | |
332 | | - | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
| 345 | + | |
| 346 | + | |
333 | 347 | | |
334 | | - | |
335 | | - | |
336 | | - | |
337 | | - | |
338 | | - | |
339 | | - | |
340 | | - | |
341 | | - | |
342 | | - | |
343 | | - | |
| 348 | + | |
| 349 | + | |
| 350 | + | |
344 | 351 | | |
345 | 352 | | |
346 | 353 | | |
347 | 354 | | |
348 | | - | |
| 355 | + | |
349 | 356 | | |
350 | 357 | | |
351 | | - | |
352 | 358 | | |
353 | 359 | | |
354 | 360 | | |
| |||
0 commit comments