File tree Expand file tree Collapse file tree
main/java/com/google/adk/events
test/java/com/google/adk/events Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -393,7 +393,7 @@ public Builder merge(EventActions other) {
393393 other .escalate ().ifPresent (this ::escalate );
394394 this .requestedAuthConfigs .putAll (other .requestedAuthConfigs ());
395395 this .requestedToolConfirmations .putAll (other .requestedToolConfirmations ());
396- this .endOfAgent = other .endOfAgent ();
396+ this .endOfAgent = this . endOfAgent || other .endOfAgent ();
397397 other .compaction ().ifPresent (this ::compaction );
398398 return this ;
399399 }
Original file line number Diff line number Diff line change @@ -111,6 +111,20 @@ public void merge_mergesAllFields() {
111111 assertThat (merged .compaction ()).hasValue (COMPACTION );
112112 }
113113
114+ @ Test
115+ public void merge_endOfAgentIsOrderIndependent () {
116+ // A tool that ends the invocation, and one that leaves the flag at its default false. Folding
117+ // parallel tool responses must keep endOfAgent set whichever order they are merged in.
118+ EventActions requestsStop = EventActions .builder ().endOfAgent (true ).build ();
119+ EventActions leavesUnset = EventActions .builder ().build ();
120+
121+ EventActions stopFirst = EventActions .builder ().merge (requestsStop ).merge (leavesUnset ).build ();
122+ EventActions stopLast = EventActions .builder ().merge (leavesUnset ).merge (requestsStop ).build ();
123+
124+ assertThat (stopFirst .endOfAgent ()).isTrue ();
125+ assertThat (stopLast .endOfAgent ()).isTrue ();
126+ }
127+
114128 @ Test
115129 public void setArtifactDelta_copiesRegularMap () {
116130 EventActions eventActions = new EventActions ();
You can’t perform that action at this time.
0 commit comments