Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion a2a/src/main/java/com/google/adk/a2a/agent/RemoteA2AAgent.java
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ private RemoteA2AAgent(Builder builder) {
if (this.description.isEmpty() && this.agentCard.description() != null) {
this.description = this.agentCard.description();
}
this.streaming = this.agentCard.capabilities().streaming();
this.streaming = builder.streaming && this.agentCard.capabilities().streaming();
}

public static Builder builder() {
Expand All @@ -133,6 +133,13 @@ public static class Builder {
private List<? extends BaseAgent> subAgents;
private List<Callbacks.BeforeAgentCallback> beforeAgentCallback;
private List<Callbacks.AfterAgentCallback> afterAgentCallback;
private boolean streaming;

@CanIgnoreReturnValue
public Builder streaming(boolean streaming) {
this.streaming = streaming;
return this;
}

@CanIgnoreReturnValue
public Builder name(String name) {
Expand Down Expand Up @@ -181,6 +188,10 @@ public RemoteA2AAgent build() {
}
}

public boolean isStreaming() {
return streaming;
}

private Message.Builder newA2AMessage(Message.Role role, List<io.a2a.spec.Part<?>> parts) {
return new Message.Builder().messageId(UUID.randomUUID().toString()).role(role).parts(parts);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,20 @@ public void setUp() {
.build();
}

@Test
public void createAgent_streaming_false_returnsNonStreamingAgent() {
// With streaming false, the agent should not stream even if the AgentCard supports streaming.
RemoteA2AAgent agent = getAgentBuilder().streaming(false).build();
assertThat(agent.isStreaming()).isFalse();
}

@Test
public void createAgent_streaming_true_returnsStreamingAgent() {
// With streaming true, the agent should support streaming if the AgentCard supports streaming.
RemoteA2AAgent agent = getAgentBuilder().streaming(true).build();
assertThat(agent.isStreaming()).isTrue();
}

@Test
public void runAsync_aggregatesPartialEvents() {
RemoteA2AAgent agent = createAgent();
Expand Down Expand Up @@ -763,7 +777,7 @@ private RemoteA2AAgent.Builder getAgentBuilder() {
}

private RemoteA2AAgent createAgent() {
return getAgentBuilder().build();
return getAgentBuilder().streaming(true).build();
}

@SuppressWarnings("unchecked") // cast for Mockito
Expand Down
Loading