Repository navigation
Commit ea43537
committed
fix(sessions): reject resuming a run whose accepted terminal output was not persisted
Replaces the hybrid recovery design with the issue's explicit non-resumable
contract. Terminal-output persistence, result reconstruction, string-only
settlement, the compaction-specific branch, and the settlement control flow in
both runners are all gone.
A resumed turn that ends via tool_use_behavior appends its terminal batch after
the output guardrails, so the run owns an accepted result for the whole of that
fallible append. If it failed, the exception propagated but nothing recorded
that the output, its guardrails, and its terminal hooks had already completed,
so retrying the state ran the model again and repeated the agent lifecycle
hooks for a result the caller had already received.
RunState now carries a terminal_unrecoverable marker. It is set once the final
output, its output guardrails, and its terminal hooks have completed but before
the fallible Session append, serialized on the unreleased 1.17 schema boundary,
and cleared only after that append and any post-append maintenance both
succeed. While it is set, every resume is rejected with an actionable UserError
raised ahead of Session reconciliation, sandbox preparation, and any model,
tool, guardrail, or hook work.1 parent aafce1c commit ea43537
5 files changed
Lines changed: 216 additions & 246 deletions
File tree
- src/agents
- run_internal
- tests
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
65 | 65 | | |
66 | 66 | | |
67 | 67 | | |
68 | | - | |
69 | 68 | | |
70 | 69 | | |
71 | 70 | | |
72 | 71 | | |
73 | 72 | | |
| 73 | + | |
74 | 74 | | |
75 | 75 | | |
76 | 76 | | |
| |||
140 | 140 | | |
141 | 141 | | |
142 | 142 | | |
143 | | - | |
144 | 143 | | |
145 | 144 | | |
146 | | - | |
147 | 145 | | |
148 | 146 | | |
149 | 147 | | |
150 | | - | |
151 | | - | |
152 | 148 | | |
153 | 149 | | |
154 | 150 | | |
| |||
597 | 593 | | |
598 | 594 | | |
599 | 595 | | |
600 | | - | |
601 | 596 | | |
602 | 597 | | |
603 | 598 | | |
| |||
641 | 636 | | |
642 | 637 | | |
643 | 638 | | |
644 | | - | |
645 | | - | |
646 | | - | |
647 | | - | |
648 | | - | |
649 | | - | |
650 | | - | |
651 | | - | |
652 | | - | |
653 | | - | |
| 639 | + | |
654 | 640 | | |
655 | 641 | | |
656 | 642 | | |
| |||
994 | 980 | | |
995 | 981 | | |
996 | 982 | | |
997 | | - | |
998 | | - | |
999 | | - | |
1000 | | - | |
1001 | | - | |
1002 | | - | |
1003 | | - | |
1004 | | - | |
1005 | | - | |
1006 | | - | |
1007 | | - | |
1008 | | - | |
1009 | | - | |
1010 | | - | |
1011 | | - | |
1012 | | - | |
1013 | | - | |
1014 | | - | |
1015 | | - | |
1016 | | - | |
1017 | | - | |
1018 | | - | |
1019 | | - | |
1020 | | - | |
1021 | 983 | | |
1022 | 984 | | |
1023 | 985 | | |
| |||
1205 | 1167 | | |
1206 | 1168 | | |
1207 | 1169 | | |
1208 | | - | |
| 1170 | + | |
1209 | 1171 | | |
1210 | 1172 | | |
1211 | 1173 | | |
| |||
1407 | 1369 | | |
1408 | 1370 | | |
1409 | 1371 | | |
1410 | | - | |
1411 | | - | |
1412 | | - | |
1413 | | - | |
1414 | | - | |
1415 | | - | |
1416 | | - | |
1417 | | - | |
1418 | | - | |
1419 | | - | |
1420 | | - | |
1421 | | - | |
1422 | | - | |
| 1372 | + | |
| 1373 | + | |
| 1374 | + | |
| 1375 | + | |
| 1376 | + | |
1423 | 1377 | | |
1424 | 1378 | | |
1425 | 1379 | | |
| |||
1429 | 1383 | | |
1430 | 1384 | | |
1431 | 1385 | | |
1432 | | - | |
1433 | | - | |
1434 | 1386 | | |
| 1387 | + | |
| 1388 | + | |
| 1389 | + | |
| 1390 | + | |
1435 | 1391 | | |
1436 | 1392 | | |
1437 | 1393 | | |
| |||
2049 | 2005 | | |
2050 | 2006 | | |
2051 | 2007 | | |
| 2008 | + | |
| 2009 | + | |
2052 | 2010 | | |
2053 | 2011 | | |
2054 | 2012 | | |
| |||
2059 | 2017 | | |
2060 | 2018 | | |
2061 | 2019 | | |
| 2020 | + | |
| 2021 | + | |
2062 | 2022 | | |
2063 | 2023 | | |
2064 | 2024 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
13 | | - | |
| 13 | + | |
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
| |||
41 | 41 | | |
42 | 42 | | |
43 | 43 | | |
44 | | - | |
45 | | - | |
46 | | - | |
47 | | - | |
48 | | - | |
| 44 | + | |
49 | 45 | | |
50 | 46 | | |
51 | 47 | | |
| |||
55 | 51 | | |
56 | 52 | | |
57 | 53 | | |
58 | | - | |
59 | 54 | | |
60 | 55 | | |
| 56 | + | |
61 | 57 | | |
62 | 58 | | |
63 | 59 | | |
| |||
496 | 492 | | |
497 | 493 | | |
498 | 494 | | |
499 | | - | |
500 | | - | |
501 | | - | |
502 | | - | |
503 | | - | |
504 | | - | |
505 | | - | |
506 | | - | |
507 | | - | |
508 | | - | |
509 | | - | |
510 | | - | |
511 | | - | |
512 | | - | |
513 | | - | |
514 | | - | |
515 | | - | |
516 | | - | |
517 | | - | |
518 | | - | |
519 | | - | |
520 | | - | |
521 | | - | |
522 | | - | |
523 | | - | |
524 | | - | |
525 | | - | |
526 | | - | |
527 | | - | |
528 | | - | |
529 | | - | |
530 | | - | |
531 | | - | |
532 | | - | |
533 | | - | |
534 | | - | |
535 | | - | |
536 | | - | |
537 | | - | |
538 | | - | |
539 | | - | |
540 | | - | |
541 | | - | |
542 | | - | |
543 | | - | |
544 | | - | |
545 | | - | |
| 495 | + | |
| 496 | + | |
| 497 | + | |
| 498 | + | |
| 499 | + | |
| 500 | + | |
| 501 | + | |
| 502 | + | |
| 503 | + | |
| 504 | + | |
| 505 | + | |
| 506 | + | |
| 507 | + | |
| 508 | + | |
546 | 509 | | |
547 | 510 | | |
548 | 511 | | |
| |||
619 | 582 | | |
620 | 583 | | |
621 | 584 | | |
622 | | - | |
623 | 585 | | |
624 | 586 | | |
625 | 587 | | |
626 | 588 | | |
627 | 589 | | |
628 | 590 | | |
629 | | - | |
630 | | - | |
631 | | - | |
632 | | - | |
633 | | - | |
634 | | - | |
635 | 591 | | |
636 | 592 | | |
637 | 593 | | |
| |||
641 | 597 | | |
642 | 598 | | |
643 | 599 | | |
644 | | - | |
645 | 600 | | |
646 | 601 | | |
647 | 602 | | |
| |||
653 | 608 | | |
654 | 609 | | |
655 | 610 | | |
656 | | - | |
657 | 611 | | |
658 | 612 | | |
659 | 613 | | |
| |||
0 commit comments