Class ClientConfig.Builder
- Enclosing class:
- ClientConfig
ClientConfig instances.
All configuration options have sensible defaults and are optional. Use this builder to override specific settings as needed.
Example:
ClientConfig config = new ClientConfig.Builder()
.setStreaming(true)
.setHistoryLength(10)
.build();
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbuild()Build the ClientConfig with the configured settings.setAcceptedOutputModes(List<String> acceptedOutputModes) Set the accepted output modes.setHistoryLength(Integer historyLength) Set the conversation history length.setMetadata(Map<String, Object> metadata) Set custom metadata to be included in all requests.setPolling(@Nullable Boolean polling) Enable or disable polling mode for task updates.setStreaming(@Nullable Boolean streaming) Enable or disable streaming mode.setTaskPushNotificationConfig(TaskPushNotificationConfig taskPushNotificationConfig) Set the default push notification configuration.setUseClientPreference(@Nullable Boolean useClientPreference) Set whether to use client or server transport preference.
-
Constructor Details
-
Builder
public Builder()
-
-
Method Details
-
setStreaming
Enable or disable streaming mode.When enabled, the client will use streaming communication if the agent also supports it. When disabled, the client uses blocking request-response mode.
- Parameters:
streaming-trueto enable streaming (default),falseto disable- Returns:
- this builder for method chaining
-
setPolling
Enable or disable polling mode for task updates.When enabled, the client can poll for task status instead of blocking or streaming. Useful for asynchronous workflows.
- Parameters:
polling-trueto enable polling,falseotherwise (default)- Returns:
- this builder for method chaining
-
setUseClientPreference
Set whether to use client or server transport preference.When
true, the client's transport order (fromClientBuilder.withTransport(java.lang.Class<T>, org.a2aproject.sdk.client.transport.spi.ClientTransportConfigBuilder<? extends org.a2aproject.sdk.client.transport.spi.ClientTransportConfig<T>, ?>)calls) takes priority. Whenfalse(default), the server's preferred transport (first inAgentCard.supportedInterfaces()) is used.- Parameters:
useClientPreference-truefor client preference,falsefor server preference (default)- Returns:
- this builder for method chaining
-
setAcceptedOutputModes
Set the accepted output modes.Specify which content types the client can handle (e.g., "text", "audio", "image"). An empty list (default) means all modes are accepted.
The provided list is copied, so subsequent modifications won't affect this configuration.
- Parameters:
acceptedOutputModes- the list of accepted output modes- Returns:
- this builder for method chaining
-
setTaskPushNotificationConfig
public ClientConfig.Builder setTaskPushNotificationConfig(TaskPushNotificationConfig taskPushNotificationConfig) Set the default push notification configuration.This webhook configuration will be used for all sendMessage calls unless overridden. The agent will POST task update events to the specified URL.
- Parameters:
taskPushNotificationConfig- the push notification configuration- Returns:
- this builder for method chaining
- See Also:
-
setHistoryLength
Set the conversation history length.Specify how many previous messages should be included as context when sending a new message. For example, 10 means the last 10 messages are sent to the agent for context.
- Parameters:
historyLength- the number of previous messages to include (must be positive)- Returns:
- this builder for method chaining
-
setMetadata
Set custom metadata to be included in all requests.This metadata is attached to every message sent by the client. Useful for tracking user IDs, session identifiers, client version, etc.
The provided map is copied, so subsequent modifications won't affect this configuration.
- Parameters:
metadata- the custom metadata map- Returns:
- this builder for method chaining
-
build
Build the ClientConfig with the configured settings.Any unset options will use their default values:
- streaming:
true - polling:
false - useClientPreference:
false - acceptedOutputModes: empty list
- taskPushNotificationConfig:
null - historyLength:
null - metadata: empty map
- Returns:
- the configured ClientConfig instance
- streaming:
-