Annotation Interface A2AClientCustomizer
ClientBuilder before the Client is constructed.
The annotated method must be static on the agent type, take a single parameter of type
org.a2aproject.sdk.client.ClientBuilder, and return void.
It is invoked once, when the client is created on the first invocation of the agent,
after the agent card has been fetched, allowing transport, interceptors, streaming,
and other low-level configuration to be specified declaratively.
Besides the ClientBuilder, it can declare parameters resolved through a
SupplierParameterResolver, which are resolved when the agent is built, like the parameters of
the other supplier methods, and not when the client is created: a value resolved per request, like a
token, is the one of the thread building the agent and not the one of the first caller.
Example:
public interface MyA2AAgent {
@A2AClientAgent(a2aServerUrl = "http://localhost:8080", outputKey = "result")
String invoke(@V("input") String input);
@A2AClientCustomizer
static void customizer(ClientBuilder cb) {
cb.withTransport(JSONRPCTransport.class,
new JSONRPCTransportConfigBuilder()
.addInterceptor(new MyOtelInterceptor()));
}
}
Like every helper method, it can be an instance method of a helper object of the agent instead of a static method
of the agent type: see the "Helper objects" section of the agentic tutorial and
AgenticServices.AgentConfigurator.