fix(flows): compare branch paths on segment boundaries, not raw string prefixes - #1415
Open
svetanis wants to merge 1 commit into
Open
fix(flows): compare branch paths on segment boundaries, not raw string prefixes#1415svetanis wants to merge 1 commit into
svetanis wants to merge 1 commit into
Conversation
Contributor
|
Hi @svetanis, thank you for your contribution! We appreciate you taking the time to submit this pull request. The team is currently reviewing your changes, and we will let you know if any further information or updates are needed. Thanks! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Please ensure you have read the contribution guide before creating a pull request.
Link to Issue or Description of Change
1. Link to an existing issue (if applicable):
2. Or, if no issue exists, describe the change:
Problem:
Contents.isEventBelongsToBranchgates which past events an agent sees, using a rawinvocationBranch.startsWith(eventBranch). A branch is a path of agent-name segments —BaseAgentbuilds it as
branch + "." + name()— so the test matches inside a segment:"root.agent_10".startsWith("root.agent_1")istrue. Peer agents whose names share a prefix(
agent_1/agent_10,search/search_v2) therefore see each other's output, which is whatEvent.branch()'s javadoc says branches exist to prevent. The leaked event arrives re-authored as auser-role message, with no error or warning.
Solution:
Require an exact match, or a prefix that ends on a segment boundary:
Ancestor and same-branch events stay visible; only the within-segment match is removed, and the
null/empty short-circuits are unchanged.
core/src/main/java/…/flows/llmflows/Contents.javacore/src/test/java/…/flows/llmflows/ContentsTest.javaTesting Plan
Unit Tests:
The first test fails on
main; the other four pass before and after, pinning every remaining arm ofthe predicate so the filter is visibly not tightened further:
processRequest_siblingBranchSharesNamePrefix_excludesSiblingEventagent_10onroot.agent_10does not see anagent_1event onroot.agent_1processRequest_sameBranch_includesEventprocessRequest_ancestorBranch_includesEventroot) stays visibleprocessRequest_eventWithoutBranch_includesEventprocessRequest_noInvocationBranch_includesBranchedEventOn
mainthe first one fails with the peer's output present, and note the form it arrives in:Manual End-to-End (E2E) Tests:
A real
ParallelAgentwith twoLlmAgentsub-agents ongemini-3.5-flash, run before and after thechange. Each agent's secret code lives in its own
instruction(system instruction, nevercontents) and carries a per-run token, so a code reaching a sibling can only have come from leakedhistory. A second pair with no shared name prefix runs as a control.
Before:
After:
The colliding pair now reads exactly like the control.
Checklist