File tree Expand file tree Collapse file tree 2 files changed +27
-2
lines changed
main/java/com/google/adk/a2a/agent
test/java/com/google/adk/a2a/agent Expand file tree Collapse file tree 2 files changed +27
-2
lines changed Original file line number Diff line number Diff line change @@ -117,7 +117,7 @@ private RemoteA2AAgent(Builder builder) {
117117 if (this .description .isEmpty () && this .agentCard .description () != null ) {
118118 this .description = this .agentCard .description ();
119119 }
120- this .streaming = this .agentCard .capabilities ().streaming ();
120+ this .streaming = builder . streaming && this .agentCard .capabilities ().streaming ();
121121 }
122122
123123 public static Builder builder () {
@@ -133,6 +133,13 @@ public static class Builder {
133133 private List <? extends BaseAgent > subAgents ;
134134 private List <Callbacks .BeforeAgentCallback > beforeAgentCallback ;
135135 private List <Callbacks .AfterAgentCallback > afterAgentCallback ;
136+ private boolean streaming ;
137+
138+ @ CanIgnoreReturnValue
139+ public Builder streaming (boolean streaming ) {
140+ this .streaming = streaming ;
141+ return this ;
142+ }
136143
137144 @ CanIgnoreReturnValue
138145 public Builder name (String name ) {
@@ -181,6 +188,10 @@ public RemoteA2AAgent build() {
181188 }
182189 }
183190
191+ public boolean isStreaming () {
192+ return streaming ;
193+ }
194+
184195 private Message .Builder newA2AMessage (Message .Role role , List <io .a2a .spec .Part <?>> parts ) {
185196 return new Message .Builder ().messageId (UUID .randomUUID ().toString ()).role (role ).parts (parts );
186197 }
Original file line number Diff line number Diff line change @@ -113,6 +113,20 @@ public void setUp() {
113113 .build ();
114114 }
115115
116+ @ Test
117+ public void createAgent_streaming_false_returnsNonStreamingAgent () {
118+ // With streaming false, the agent should not stream even if the AgentCard supports streaming.
119+ RemoteA2AAgent agent = getAgentBuilder ().streaming (false ).build ();
120+ assertThat (agent .isStreaming ()).isFalse ();
121+ }
122+
123+ @ Test
124+ public void createAgent_streaming_true_returnsStreamingAgent () {
125+ // With streaming true, the agent should support streaming if the AgentCard supports streaming.
126+ RemoteA2AAgent agent = getAgentBuilder ().streaming (true ).build ();
127+ assertThat (agent .isStreaming ()).isTrue ();
128+ }
129+
116130 @ Test
117131 public void runAsync_aggregatesPartialEvents () {
118132 RemoteA2AAgent agent = createAgent ();
@@ -763,7 +777,7 @@ private RemoteA2AAgent.Builder getAgentBuilder() {
763777 }
764778
765779 private RemoteA2AAgent createAgent () {
766- return getAgentBuilder ().build ();
780+ return getAgentBuilder ().streaming ( true ). build ();
767781 }
768782
769783 @ SuppressWarnings ("unchecked" ) // cast for Mockito
You can’t perform that action at this time.
0 commit comments