Repository navigation
Commit 75fc64b
committed
address Codex review: checkpoint the handoff batch and reorder the agent-update event
Two issues from the automated Codex review on this PR, both real:
1. _save_stream_items_without_count() never registered a pending_session_write
checkpoint for the handoff batch, unlike the sibling is_resumed_state branch's
_save_resumed_stream_items(). A failed append followed by a successful resume
invoked the correct (delegate) agent but permanently dropped the handoff's
function_call/function_call_output pair from session history, since nothing
recorded the batch for the existing resume_pending_session_write() recovery
path to replay. Fixed by threading resumed_write_state through
_save_stream_items into save_result_to_session, gated on the handoff branch
already having set _current_step to NextStepRunAgain.
2. AgentUpdatedStreamEvent was still queued after the fallible session append,
so a live stream_events() consumer would see handoff items followed directly
by an error with no semantic agent-transition event, even though the result
and resumed run both correctly identify the new agent. Moved the event queue
call to sit with the other state-transition updates, before the append.
Both fixes are scoped to only the generic-loop branch this PR already touches;
the already-merged is_resumed_state branch (openai#4725) has the same pre-existing
event-ordering gap but is out of scope here.
Extended test_fresh_streamed_handoff_preserves_agent_after_session_append_failure
with a session-history assertion for issue 1, and added
test_fresh_streamed_handoff_publishes_agent_update_before_session_append_failure
for issue 2 (using a new session double that yields before failing, since a
purely synchronous raise never gives stream_events() a scheduling boundary to
prove event delivery either way).1 parent 09e928a commit 75fc64b
2 files changed
Lines changed: 75 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
418 | 418 | | |
419 | 419 | | |
420 | 420 | | |
| 421 | + | |
421 | 422 | | |
422 | 423 | | |
423 | 424 | | |
| |||
433 | 434 | | |
434 | 435 | | |
435 | 436 | | |
| 437 | + | |
436 | 438 | | |
437 | 439 | | |
438 | 440 | | |
| |||
1152 | 1154 | | |
1153 | 1155 | | |
1154 | 1156 | | |
| 1157 | + | |
| 1158 | + | |
| 1159 | + | |
| 1160 | + | |
| 1161 | + | |
| 1162 | + | |
1155 | 1163 | | |
1156 | 1164 | | |
1157 | 1165 | | |
| |||
1885 | 1893 | | |
1886 | 1894 | | |
1887 | 1895 | | |
| 1896 | + | |
| 1897 | + | |
| 1898 | + | |
| 1899 | + | |
| 1900 | + | |
1888 | 1901 | | |
1889 | 1902 | | |
1890 | 1903 | | |
| |||
1893 | 1906 | | |
1894 | 1907 | | |
1895 | 1908 | | |
1896 | | - | |
1897 | | - | |
1898 | | - | |
1899 | 1909 | | |
1900 | 1910 | | |
1901 | 1911 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
12 | | - | |
| 12 | + | |
13 | 13 | | |
14 | 14 | | |
15 | 15 | | |
| |||
101 | 101 | | |
102 | 102 | | |
103 | 103 | | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
104 | 118 | | |
105 | 119 | | |
106 | 120 | | |
| |||
1277 | 1291 | | |
1278 | 1292 | | |
1279 | 1293 | | |
| 1294 | + | |
| 1295 | + | |
| 1296 | + | |
| 1297 | + | |
| 1298 | + | |
| 1299 | + | |
| 1300 | + | |
| 1301 | + | |
| 1302 | + | |
| 1303 | + | |
| 1304 | + | |
| 1305 | + | |
| 1306 | + | |
| 1307 | + | |
| 1308 | + | |
| 1309 | + | |
| 1310 | + | |
| 1311 | + | |
| 1312 | + | |
| 1313 | + | |
| 1314 | + | |
| 1315 | + | |
| 1316 | + | |
| 1317 | + | |
| 1318 | + | |
| 1319 | + | |
| 1320 | + | |
| 1321 | + | |
| 1322 | + | |
| 1323 | + | |
| 1324 | + | |
| 1325 | + | |
| 1326 | + | |
| 1327 | + | |
| 1328 | + | |
| 1329 | + | |
| 1330 | + | |
| 1331 | + | |
| 1332 | + | |
| 1333 | + | |
| 1334 | + | |
| 1335 | + | |
| 1336 | + | |
| 1337 | + | |
| 1338 | + | |
| 1339 | + | |
| 1340 | + | |
0 commit comments