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 Summary
Modifier and TypeMethodDescriptionagentCardHeaders(A2AClientContext context) Returns headers for the request that fetches the Agent Card of an agent.default voidcustomize(A2AClientContext context, org.a2aproject.sdk.client.ClientBuilder clientBuilder) Configures the A2A SDK client of an agent, for what headers cannot do.messageHeaders(A2AClientContext context) Returns headers for each message sent to an agent.
-
Method Details
-
agentCardHeaders
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 ownA2AClientBuilder.agentCardHeaders(java.util.function.Supplier)take precedence over these.- Parameters:
context- the agent being configured; itsAgent Cardis not known yet- Returns:
- the headers to add, or an empty map or
nullfor none
-
messageHeaders
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
nullfor 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 thatClientBuilder.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 CardclientBuilder- the builder of the agent's A2A SDK client
-