Interface A2AClientConfigurator


public interface A2AClientConfigurator
Configures every A2A client agent, including those declared with A2AClientAgent. It lets a framework apply the same configuration, such as credentials, to all the A2A agents of an application.

Implementations are loaded with ServiceLoader when an A2A client agent is built, and all of them are applied, in the order they are found. Headers returned by several configurators are merged; when two return the same header, the one found later wins.

Prefer agentCardHeaders(A2AClientContext) and messageHeaders(A2AClientContext) for credentials: they are sent with each request, on any transport, and an agent's own client customizer cannot remove them.

  • Method Details

    • agentCardHeaders

      default Map<String,String> agentCardHeaders(A2AClientContext context)
      Returns headers for the request that fetches the Agent Card of an agent. It is called each time the card is fetched, so it can return a refreshed token. The headers of the agent's own A2AClientBuilder.agentCardHeaders(java.util.function.Supplier) take precedence over these.
      Parameters:
      context - the agent being configured; its Agent Card is not known yet
      Returns:
      the headers to add, or an empty map or null for none
    • messageHeaders

      default Map<String,String> messageHeaders(A2AClientContext context)
      Returns headers for each message sent to an agent. It is called for every message, so it can return a refreshed token. The headers are sent with the call itself, so they apply to any transport and are kept when the agent's own client customizer configures a transport.
      Parameters:
      context - the agent being called, with its Agent Card and the tenant of this call
      Returns:
      the headers to add, or an empty map or null for none
    • customize

      default void customize(A2AClientContext context, org.a2aproject.sdk.client.ClientBuilder clientBuilder)
      Configures the A2A SDK client of an agent, for what headers cannot do. It runs before the agent's own client customizer. Note that ClientBuilder.withTransport(Class, ClientTransportConfigBuilder) replaces the configuration of a transport, so a customizer that configures the same transport replaces what is set here; use the header methods for credentials.
      Parameters:
      context - the agent being configured, with its Agent Card
      clientBuilder - the builder of the agent's A2A SDK client