@@ -45,38 +45,14 @@ public Client(AgentCard agentCard, ClientConfig clientConfig, ClientTransport cl
4545
4646 @ Override
4747 public void sendMessage (Message request , ClientCallContext context ) throws A2AClientException {
48- MessageSendConfiguration messageSendConfiguration = new MessageSendConfiguration .Builder ()
49- .acceptedOutputModes (clientConfig .getAcceptedOutputModes ())
50- .blocking (clientConfig .isPolling ())
51- .historyLength (clientConfig .getHistoryLength ())
52- .pushNotification (clientConfig .getPushNotificationConfig ())
53- .build ();
54-
55- MessageSendParams messageSendParams = new MessageSendParams .Builder ()
56- .message (request )
57- .configuration (messageSendConfiguration )
58- .metadata (clientConfig .getMetadata ())
59- .build ();
60-
48+ MessageSendParams messageSendParams = getMessageSendParams (request , clientConfig );
6149 sendMessage (messageSendParams , null , null , context );
6250 }
6351
6452 @ Override
6553 public void sendMessage (Message request , List <BiConsumer <ClientEvent , AgentCard >> consumers ,
6654 Consumer <Throwable > streamingErrorHandler , ClientCallContext context ) throws A2AClientException {
67- MessageSendConfiguration messageSendConfiguration = new MessageSendConfiguration .Builder ()
68- .acceptedOutputModes (clientConfig .getAcceptedOutputModes ())
69- .blocking (clientConfig .isPolling ())
70- .historyLength (clientConfig .getHistoryLength ())
71- .pushNotification (clientConfig .getPushNotificationConfig ())
72- .build ();
73-
74- MessageSendParams messageSendParams = new MessageSendParams .Builder ()
75- .message (request )
76- .configuration (messageSendConfiguration )
77- .metadata (clientConfig .getMetadata ())
78- .build ();
79-
55+ MessageSendParams messageSendParams = getMessageSendParams (request , clientConfig );
8056 sendMessage (messageSendParams , consumers , streamingErrorHandler , context );
8157 }
8258
@@ -240,4 +216,19 @@ private void consume(ClientEvent clientEvent, AgentCard agentCard, List<BiConsum
240216 consume (clientEvent , agentCard );
241217 }
242218 }
219+
220+ private MessageSendParams getMessageSendParams (Message request , ClientConfig clientConfig ) {
221+ MessageSendConfiguration messageSendConfiguration = new MessageSendConfiguration .Builder ()
222+ .acceptedOutputModes (clientConfig .getAcceptedOutputModes ())
223+ .blocking (clientConfig .isPolling ())
224+ .historyLength (clientConfig .getHistoryLength ())
225+ .pushNotification (clientConfig .getPushNotificationConfig ())
226+ .build ();
227+
228+ return new MessageSendParams .Builder ()
229+ .message (request )
230+ .configuration (messageSendConfiguration )
231+ .metadata (clientConfig .getMetadata ())
232+ .build ();
233+ }
243234}
0 commit comments