Commit be8fcf4
docs: correct the documented contract of the invocation-subtree event filter
`_get_events(current_branch=True)` documented itself as returning events on
"the current branch or any descendant sub-branch", but that is only the user
arm, and not even all of it. The docstring now states the whole rule:
* A user event matches this branch, a descendant sub-branch, or no branch.
* When `self.branch` is `None`, every user event matches whatever branch it
is on. An empty-string branch is the opposite rather than a synonym: it is
a real value in the workflow code and matches no branched event.
* A user event carrying function responses must additionally answer a call
issued on this branch or below it, and is dropped otherwise even when it
sits on exactly this branch.
* Every other event must sit on exactly this branch.
So a confirmation answered by the user on a sub-branch is visible while the
agent event that requested it is not. The asymmetry needs a per-caller review
before it is widened -- not because sibling trees would become reachable
(`_BranchPath.is_descendant_of` already excludes those) but because every
caller would start seeing a descendant's internal events.
No behavior change. The docstring also notes that
`contents._is_event_belongs_to_branch` deliberately matches the *opposite*
direction, because it answers a different question -- "what history may this
agent see?" rather than "what happened inside this invocation?".
The descendant test also now uses `_BranchPath.is_descendant_of` instead of a
hand-rolled `startswith(f"{branch}.")`. That helper was already imported and
used elsewhere in the same file. The empty-branch guard is kept: an empty
branch is a real value in the workflow code, and a bare descendant test would
treat every branched event as its descendant.
Co-authored-by: Shangjie Chen <deanchen@google.com>
PiperOrigin-RevId: 9707896101 parent ef2d680 commit be8fcf4
2 files changed
Lines changed: 170 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
449 | 449 | | |
450 | 450 | | |
451 | 451 | | |
452 | | - | |
| 452 | + | |
| 453 | + | |
| 454 | + | |
| 455 | + | |
| 456 | + | |
| 457 | + | |
| 458 | + | |
| 459 | + | |
| 460 | + | |
| 461 | + | |
| 462 | + | |
| 463 | + | |
| 464 | + | |
| 465 | + | |
| 466 | + | |
| 467 | + | |
| 468 | + | |
| 469 | + | |
| 470 | + | |
| 471 | + | |
| 472 | + | |
| 473 | + | |
| 474 | + | |
| 475 | + | |
| 476 | + | |
| 477 | + | |
| 478 | + | |
| 479 | + | |
| 480 | + | |
| 481 | + | |
453 | 482 | | |
454 | 483 | | |
455 | 484 | | |
| |||
477 | 506 | | |
478 | 507 | | |
479 | 508 | | |
480 | | - | |
481 | | - | |
| 509 | + | |
| 510 | + | |
| 511 | + | |
| 512 | + | |
482 | 513 | | |
483 | 514 | | |
484 | 515 | | |
485 | 516 | | |
486 | | - | |
| 517 | + | |
| 518 | + | |
| 519 | + | |
| 520 | + | |
| 521 | + | |
| 522 | + | |
487 | 523 | | |
488 | 524 | | |
489 | 525 | | |
| 526 | + | |
490 | 527 | | |
491 | 528 | | |
492 | 529 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
26 | 26 | | |
27 | 27 | | |
28 | 28 | | |
| 29 | + | |
29 | 30 | | |
30 | 31 | | |
31 | 32 | | |
| |||
794 | 795 | | |
795 | 796 | | |
796 | 797 | | |
| 798 | + | |
| 799 | + | |
| 800 | + | |
| 801 | + | |
| 802 | + | |
| 803 | + | |
| 804 | + | |
| 805 | + | |
| 806 | + | |
| 807 | + | |
| 808 | + | |
| 809 | + | |
| 810 | + | |
| 811 | + | |
| 812 | + | |
| 813 | + | |
| 814 | + | |
| 815 | + | |
| 816 | + | |
| 817 | + | |
| 818 | + | |
| 819 | + | |
| 820 | + | |
| 821 | + | |
| 822 | + | |
| 823 | + | |
| 824 | + | |
| 825 | + | |
| 826 | + | |
| 827 | + | |
| 828 | + | |
| 829 | + | |
| 830 | + | |
| 831 | + | |
| 832 | + | |
| 833 | + | |
| 834 | + | |
| 835 | + | |
| 836 | + | |
| 837 | + | |
| 838 | + | |
| 839 | + | |
| 840 | + | |
| 841 | + | |
| 842 | + | |
| 843 | + | |
| 844 | + | |
| 845 | + | |
| 846 | + | |
| 847 | + | |
| 848 | + | |
| 849 | + | |
| 850 | + | |
| 851 | + | |
| 852 | + | |
| 853 | + | |
| 854 | + | |
| 855 | + | |
| 856 | + | |
| 857 | + | |
| 858 | + | |
| 859 | + | |
| 860 | + | |
| 861 | + | |
| 862 | + | |
| 863 | + | |
| 864 | + | |
| 865 | + | |
| 866 | + | |
| 867 | + | |
| 868 | + | |
| 869 | + | |
| 870 | + | |
| 871 | + | |
| 872 | + | |
| 873 | + | |
| 874 | + | |
| 875 | + | |
| 876 | + | |
| 877 | + | |
| 878 | + | |
| 879 | + | |
| 880 | + | |
| 881 | + | |
| 882 | + | |
| 883 | + | |
| 884 | + | |
| 885 | + | |
| 886 | + | |
| 887 | + | |
| 888 | + | |
| 889 | + | |
| 890 | + | |
| 891 | + | |
| 892 | + | |
| 893 | + | |
| 894 | + | |
| 895 | + | |
| 896 | + | |
| 897 | + | |
| 898 | + | |
| 899 | + | |
| 900 | + | |
| 901 | + | |
| 902 | + | |
| 903 | + | |
| 904 | + | |
| 905 | + | |
| 906 | + | |
| 907 | + | |
| 908 | + | |
| 909 | + | |
| 910 | + | |
| 911 | + | |
| 912 | + | |
| 913 | + | |
| 914 | + | |
| 915 | + | |
| 916 | + | |
| 917 | + | |
| 918 | + | |
| 919 | + | |
| 920 | + | |
| 921 | + | |
| 922 | + | |
| 923 | + | |
| 924 | + | |
| 925 | + | |
0 commit comments