Skip to content

Commit 3be6ee9

Browse files
authored
fix: Fix usages of ClientConfig#polling (#297)
# Description Thank you for opening a Pull Request! Before submitting your PR, there are a few things you can do to make sure it goes smoothly: - [x] Follow the [`CONTRIBUTING` Guide](../CONTRIBUTING.md). - [x] Make your Pull Request title in the <https://www.conventionalcommits.org/> specification. - Important Prefixes for [release-please](https://github.com/googleapis/release-please): - `fix:` which represents bug fixes, and correlates to a [SemVer](https://semver.org/) patch. - `feat:` represents a new feature, and correlates to a SemVer minor. - `feat!:`, or `fix!:`, `refactor!:`, etc., which represent a breaking change (indicated by the `!`) and will result in a SemVer major. - [x] Ensure the tests pass - [x] Appropriate READMEs were updated (if necessary) Fixes #294 🦕
1 parent 9b8bbb2 commit 3be6ee9

File tree

1 file changed

+11
-12
lines changed

1 file changed

+11
-12
lines changed

client/base/src/main/java/io/a2a/client/Client.java

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -66,12 +66,7 @@ public void sendMessage(Message request, List<BiConsumer<ClientEvent, AgentCard>
6666
@Override
6767
public void sendMessage(Message request, PushNotificationConfig pushNotificationConfiguration,
6868
Map<String, Object> metatadata, ClientCallContext context) throws A2AClientException {
69-
MessageSendConfiguration messageSendConfiguration = new MessageSendConfiguration.Builder()
70-
.acceptedOutputModes(clientConfig.getAcceptedOutputModes())
71-
.blocking(clientConfig.isPolling())
72-
.historyLength(clientConfig.getHistoryLength())
73-
.pushNotificationConfig(pushNotificationConfiguration)
74-
.build();
69+
MessageSendConfiguration messageSendConfiguration = createMessageSendConfiguration(pushNotificationConfiguration);
7570

7671
MessageSendParams messageSendParams = new MessageSendParams.Builder()
7772
.message(request)
@@ -155,6 +150,15 @@ private ClientEvent getClientEvent(StreamingEventKind event, ClientTaskManager t
155150
}
156151
}
157152

153+
private MessageSendConfiguration createMessageSendConfiguration(PushNotificationConfig pushNotificationConfig) {
154+
return new MessageSendConfiguration.Builder()
155+
.acceptedOutputModes(clientConfig.getAcceptedOutputModes())
156+
.blocking(!clientConfig.isPolling())
157+
.historyLength(clientConfig.getHistoryLength())
158+
.pushNotificationConfig(pushNotificationConfig)
159+
.build();
160+
}
161+
158162
private void sendMessage(MessageSendParams messageSendParams, List<BiConsumer<ClientEvent, AgentCard>> consumers,
159163
Consumer<Throwable> errorHandler, ClientCallContext context) throws A2AClientException {
160164
if (! clientConfig.isStreaming() || ! agentCard.capabilities().streaming()) {
@@ -225,12 +229,7 @@ private void consume(ClientEvent clientEvent, AgentCard agentCard, List<BiConsum
225229
}
226230

227231
private MessageSendParams getMessageSendParams(Message request, ClientConfig clientConfig) {
228-
MessageSendConfiguration messageSendConfiguration = new MessageSendConfiguration.Builder()
229-
.acceptedOutputModes(clientConfig.getAcceptedOutputModes())
230-
.blocking(clientConfig.isPolling())
231-
.historyLength(clientConfig.getHistoryLength())
232-
.pushNotificationConfig(clientConfig.getPushNotificationConfig())
233-
.build();
232+
MessageSendConfiguration messageSendConfiguration = createMessageSendConfiguration(clientConfig.getPushNotificationConfig());
234233

235234
return new MessageSendParams.Builder()
236235
.message(request)

0 commit comments

Comments
 (0)