Class ClientConfig.Builder

java.lang.Object
org.a2aproject.sdk.client.config.ClientConfig.Builder
Enclosing class:
ClientConfig

public static class ClientConfig.Builder extends Object
Builder for creating 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 Details

    • Builder

      public Builder()
  • Method Details

    • setStreaming

      public ClientConfig.Builder setStreaming(@Nullable Boolean streaming)
      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 - true to enable streaming (default), false to disable
      Returns:
      this builder for method chaining
    • setPolling

      public ClientConfig.Builder setPolling(@Nullable Boolean polling)
      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 - true to enable polling, false otherwise (default)
      Returns:
      this builder for method chaining
    • setUseClientPreference

      public ClientConfig.Builder setUseClientPreference(@Nullable Boolean useClientPreference)
      Set whether to use client or server transport preference.

      When true, the client's transport order (from ClientBuilder.withTransport(java.lang.Class<T>, org.a2aproject.sdk.client.transport.spi.ClientTransportConfigBuilder<? extends org.a2aproject.sdk.client.transport.spi.ClientTransportConfig<T>, ?>) calls) takes priority. When false (default), the server's preferred transport (first in AgentCard.supportedInterfaces()) is used.

      Parameters:
      useClientPreference - true for client preference, false for server preference (default)
      Returns:
      this builder for method chaining
    • setAcceptedOutputModes

      public ClientConfig.Builder setAcceptedOutputModes(List<String> acceptedOutputModes)
      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

      public ClientConfig.Builder setHistoryLength(Integer historyLength)
      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

      public ClientConfig.Builder setMetadata(Map<String,Object> metadata)
      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

      public ClientConfig 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