Annotation Interface A2AClientCustomizer


@Retention(RUNTIME) @Target(METHOD) public @interface A2AClientCustomizer
Marks a static method that customizes the underlying A2A SDK ClientBuilder before the Client is constructed.

The annotated method must be static, 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()));
    }
}