Repository navigation
Commit 92891a6
committed
address 2nd Codex review round: guardrail race, event drain, deferred compaction
Three more issues from the automated Codex review on commit 75fc64b, all
verified with live reproduction before being fixed:
1. The handoff transition committed current_agent/run_state before a
still-in-flight parallel input guardrail had resolved. A non-tripwire
exception from that guardrail then left the resumable state pointing at
the delegate agent, even though the starting agent's input guardrails
never definitively cleared. Fixed by explicitly awaiting
input_guardrail_tripwire_triggered_for_stream() as the first statement
in the handoff branch, before any state mutation.
2. Queuing AgentUpdatedStreamEvent before the fallible session append
doesn't guarantee delivery: stream_events() checks a stored exception
before draining the queue, so a real (non-instant) consumer can lose an
already-queued event to a task that raised without ever being marked for
draining. Fixed by marking the session-persistence exception via
_mark_error_to_drain_stream_events() before re-raising, the same pattern
already used for model-behavior errors.
3. The pending_session_write checkpoint recovers the raw item append but
never carried enough information (response_id, store, whether the batch
had local tool outputs) for a later, separate resume to replay the same
post-write Responses compaction decision save_result_to_session would
have applied inline. Extracted the compaction decision into a shared
_apply_post_write_compaction() helper, extended the checkpoint schema
with those fields (optional, so an old-shaped serialized RunState still
round-trips), and call the helper from resume_pending_session_write()
once a checkpoint settles -- whether inline or on a separate resume --
instead of duplicating the call at both sites.
Added 3 new regression tests to tests/test_run_impl_resume_paths.py
(72 total in the file, up from 69), each confirmed to fail against the
pre-fix code and pass after. Full verification stack clean: make format/
lint/typecheck, and the full suite (9372 passed, 33 skipped, 0 failed).1 parent 75fc64b commit 92891a6
4 files changed
Lines changed: 315 additions & 47 deletions
File tree
- src/agents
- run_internal
- tests
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
43 | 43 | | |
44 | 44 | | |
45 | 45 | | |
| 46 | + | |
46 | 47 | | |
47 | 48 | | |
48 | 49 | | |
| |||
1887 | 1888 | | |
1888 | 1889 | | |
1889 | 1890 | | |
| 1891 | + | |
| 1892 | + | |
| 1893 | + | |
| 1894 | + | |
| 1895 | + | |
1890 | 1896 | | |
1891 | 1897 | | |
1892 | 1898 | | |
| |||
1898 | 1904 | | |
1899 | 1905 | | |
1900 | 1906 | | |
1901 | | - | |
1902 | | - | |
1903 | | - | |
1904 | | - | |
1905 | | - | |
| 1907 | + | |
| 1908 | + | |
| 1909 | + | |
| 1910 | + | |
| 1911 | + | |
| 1912 | + | |
| 1913 | + | |
| 1914 | + | |
| 1915 | + | |
1906 | 1916 | | |
1907 | 1917 | | |
1908 | 1918 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
556 | 556 | | |
557 | 557 | | |
558 | 558 | | |
| 559 | + | |
| 560 | + | |
| 561 | + | |
| 562 | + | |
| 563 | + | |
| 564 | + | |
| 565 | + | |
| 566 | + | |
| 567 | + | |
| 568 | + | |
| 569 | + | |
| 570 | + | |
| 571 | + | |
| 572 | + | |
| 573 | + | |
| 574 | + | |
| 575 | + | |
| 576 | + | |
| 577 | + | |
| 578 | + | |
| 579 | + | |
| 580 | + | |
| 581 | + | |
| 582 | + | |
| 583 | + | |
| 584 | + | |
| 585 | + | |
| 586 | + | |
| 587 | + | |
| 588 | + | |
| 589 | + | |
| 590 | + | |
| 591 | + | |
| 592 | + | |
| 593 | + | |
| 594 | + | |
| 595 | + | |
| 596 | + | |
| 597 | + | |
| 598 | + | |
| 599 | + | |
| 600 | + | |
| 601 | + | |
| 602 | + | |
| 603 | + | |
| 604 | + | |
| 605 | + | |
| 606 | + | |
| 607 | + | |
| 608 | + | |
| 609 | + | |
| 610 | + | |
| 611 | + | |
| 612 | + | |
| 613 | + | |
| 614 | + | |
| 615 | + | |
| 616 | + | |
| 617 | + | |
559 | 618 | | |
560 | 619 | | |
561 | 620 | | |
| |||
663 | 722 | | |
664 | 723 | | |
665 | 724 | | |
| 725 | + | |
| 726 | + | |
| 727 | + | |
| 728 | + | |
666 | 729 | | |
667 | 730 | | |
668 | 731 | | |
| |||
673 | 736 | | |
674 | 737 | | |
675 | 738 | | |
| 739 | + | |
| 740 | + | |
| 741 | + | |
676 | 742 | | |
677 | | - | |
| 743 | + | |
| 744 | + | |
| 745 | + | |
| 746 | + | |
| 747 | + | |
| 748 | + | |
| 749 | + | |
| 750 | + | |
| 751 | + | |
678 | 752 | | |
679 | 753 | | |
680 | 754 | | |
681 | 755 | | |
682 | 756 | | |
683 | 757 | | |
684 | | - | |
685 | | - | |
686 | | - | |
687 | | - | |
688 | | - | |
689 | | - | |
690 | | - | |
691 | | - | |
692 | | - | |
693 | | - | |
694 | | - | |
695 | | - | |
696 | | - | |
697 | | - | |
698 | | - | |
699 | | - | |
700 | | - | |
701 | | - | |
702 | | - | |
703 | | - | |
704 | | - | |
705 | | - | |
706 | | - | |
707 | | - | |
708 | | - | |
709 | | - | |
710 | | - | |
711 | | - | |
712 | | - | |
713 | | - | |
714 | | - | |
715 | | - | |
716 | | - | |
717 | | - | |
718 | | - | |
719 | | - | |
720 | | - | |
721 | | - | |
722 | | - | |
| 758 | + | |
| 759 | + | |
| 760 | + | |
| 761 | + | |
| 762 | + | |
| 763 | + | |
723 | 764 | | |
724 | 765 | | |
725 | 766 | | |
| |||
764 | 805 | | |
765 | 806 | | |
766 | 807 | | |
| 808 | + | |
767 | 809 | | |
768 | 810 | | |
769 | 811 | | |
770 | 812 | | |
771 | 813 | | |
772 | 814 | | |
| 815 | + | |
| 816 | + | |
| 817 | + | |
| 818 | + | |
| 819 | + | |
773 | 820 | | |
774 | 821 | | |
775 | 822 | | |
| |||
819 | 866 | | |
820 | 867 | | |
821 | 868 | | |
| 869 | + | |
| 870 | + | |
| 871 | + | |
| 872 | + | |
| 873 | + | |
| 874 | + | |
| 875 | + | |
| 876 | + | |
822 | 877 | | |
823 | 878 | | |
824 | 879 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
38 | 38 | | |
39 | 39 | | |
40 | 40 | | |
41 | | - | |
| 41 | + | |
42 | 42 | | |
43 | 43 | | |
44 | 44 | | |
| |||
172 | 172 | | |
173 | 173 | | |
174 | 174 | | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
175 | 183 | | |
176 | 184 | | |
177 | 185 | | |
| |||
4360 | 4368 | | |
4361 | 4369 | | |
4362 | 4370 | | |
| 4371 | + | |
| 4372 | + | |
| 4373 | + | |
| 4374 | + | |
| 4375 | + | |
| 4376 | + | |
4363 | 4377 | | |
4364 | 4378 | | |
4365 | 4379 | | |
4366 | 4380 | | |
4367 | | - | |
| 4381 | + | |
| 4382 | + | |
4368 | 4383 | | |
4369 | 4384 | | |
4370 | 4385 | | |
| |||
4378 | 4393 | | |
4379 | 4394 | | |
4380 | 4395 | | |
| 4396 | + | |
| 4397 | + | |
| 4398 | + | |
| 4399 | + | |
| 4400 | + | |
| 4401 | + | |
| 4402 | + | |
| 4403 | + | |
| 4404 | + | |
| 4405 | + | |
| 4406 | + | |
| 4407 | + | |
| 4408 | + | |
| 4409 | + | |
4381 | 4410 | | |
4382 | 4411 | | |
4383 | 4412 | | |
| |||
0 commit comments