pub struct ClientBuilder { /* private fields */ }Expand description
Builder for A2aClient.
Start with ClientBuilder::new (URL) or ClientBuilder::from_card
(agent card auto-configuration).
Implementations§
Source§impl ClientBuilder
impl ClientBuilder
Sourcepub const fn with_credential_preflight(
self,
mode: CredentialPreflight,
) -> ClientBuilder
pub const fn with_credential_preflight( self, mode: CredentialPreflight, ) -> ClientBuilder
What to do with a call whose credentials match none of the agent
card’s security requirements (spec §3.1.11: the client MUST
authenticate with a scheme the card declares). Default
CredentialPreflight::Warn.
Checked after the interceptors’ before hooks, on what the request
carries: Authorization with the declared HTTP scheme (Bearer for
OAuth 2.0 and OpenID Connect), or the header, query parameter or
cookie an API-key scheme names. A mutual-TLS scheme is taken as
satisfied. Only a client built from a card that lists
securityRequirements checks anything; one built for a bare endpoint
never does. Neither the warning nor the error carries a credential:
they name schemes, headers, cookies and parameters.
Source§impl ClientBuilder
impl ClientBuilder
Sourcepub fn build(self) -> Result<A2aClient, ClientError>
pub fn build(self) -> Result<A2aClient, ClientError>
Validates configuration and constructs the A2aClient.
Binding names are matched ignoring ASCII case, as card selection
matches them. When the builder came from a card and the chosen
interface cannot be constructed here — gRPC (which needs
build_grpc), a binding this SDK does not implement, or a malformed
URL — the card’s next compatible interface is tried, in
from_card_preferring’s order, and its
endpoint and tenant are used. A binding set with
with_protocol_binding is never
substituted.
§Errors
ClientError::InvalidEndpointif the endpoint URL is malformed.ClientError::Transportif the selected transport cannot be initialized; after fallbacks, it names every interface tried.
Sourcepub async fn build_grpc(self) -> Result<A2aClient, ClientError>
Available on crate feature grpc only.
pub async fn build_grpc(self) -> Result<A2aClient, ClientError>
grpc only.Validates configuration and constructs a gRPC-backed A2aClient.
Unlike build, this method is async because gRPC
transport requires establishing a connection.
A builder from an agent card dials the card’s gRPC interface, not
whichever interface from_card chose first.
§Errors
ClientError::Configif a timeout is zero, or the card offers no gRPC interface.ClientError::InvalidEndpointif the endpoint URL is malformed.ClientError::Transportif the gRPC connection fails.
Source§impl ClientBuilder
impl ClientBuilder
Sourcepub fn from_signed_card(
card: &[u8],
keys: Jwks,
) -> Result<ClientBuilder, ClientError>
pub fn from_signed_card( card: &[u8], keys: Jwks, ) -> Result<ClientBuilder, ClientError>
Creates a builder from an agent card the caller holds as JSON,
verifying its signatures against keys first (spec §14: clients
SHOULD verify signatures when present), then as
from_card.
The JSON is verified as given, before it is read into an
AgentCard, because the typed card drops any field this SDK does
not model and the signer covered. A card fetched by this SDK’s
discovery is verified there instead, with
CardFetchOptions::with_signature_keys.
The keys are kept: the extended card, if the client fetches it, must
verify against them too
(with_card_signature_keys;
adversarial review N10, 2026-11-13).
§Errors
ClientError::Serialization for JSON that is not a card;
ClientError::Protocol for a card with no signature, or none that
verifies against a key in keys; then those of
from_card.
Source§impl ClientBuilder
impl ClientBuilder
Sourcepub fn new(endpoint: impl Into<String>) -> ClientBuilder
pub fn new(endpoint: impl Into<String>) -> ClientBuilder
Creates a builder targeting endpoint.
The endpoint is passed directly to the selected transport; it should be
the full base URL of the agent (e.g. http://localhost:8080).
Sourcepub fn from_card(card: &AgentCard) -> Result<ClientBuilder, ClientError>
pub fn from_card(card: &AgentCard) -> Result<ClientBuilder, ClientError>
Creates a builder pre-configured from an AgentCard, using the
first interface the card lists that this client supports.
Spec §8.3.2: a client MUST select the first supported interface and
prefer earlier entries in the card’s ordered list. So this applies no
binding preference of its own: among the card’s interfaces for this
SDK’s A2A protocol major, the card’s order decides, and
build moves past one it cannot construct (a gRPC
interface needs build_grpc, a binding this SDK does not implement, a
malformed URL). Until 0.15 this preferred JSON-RPC wherever the card
listed it; to rank bindings yourself, use
from_card_preferring.
§Errors
Returns ClientError::InvalidEndpoint if the card has no interfaces,
or none for this SDK’s A2A protocol major.
Sourcepub fn from_card_preferring(
card: &AgentCard,
preferences: &[String],
) -> Result<ClientBuilder, ClientError>
pub fn from_card_preferring( card: &AgentCard, preferences: &[String], ) -> Result<ClientBuilder, ClientError>
Creates a builder from an AgentCard, choosing the first interface
whose binding appears in preferences.
Only interfaces whose protocolVersion has this SDK’s major (1; an
empty version does not, and a leading v is allowed) are considered.
An agent that also serves v0.3 often lists that endpoint first; it
speaks another protocol, so it is skipped rather than connected to.
Binding names compare ignoring ASCII case. preferences is the
client’s order, not the card’s: the first
preference the agent actually offers wins. When the agent offers none
of them, the card’s first interface is used, because an agent that
speaks only bindings this caller did not rank is still worth talking to
— and failing to connect would be a worse answer than connecting over
something unranked.
§Why this exists
ClientConfig::preferred_bindings has documented exactly this since
it was introduced — “the client tries each in order, selecting the
first one supported by the target agent’s card” — and nothing read the
field. from_card took supported_interfaces.first(), which is the
agent’s first choice, inverting the preference the field describes.
A caller who ranked GRPC first and met a card listing
[JSONRPC, GRPC] silently got JSONRPC.
The remaining compatible interfaces are kept, in the same order, as
fallbacks: build moves to the next one when the chosen
interface cannot be constructed (a gRPC interface needs
build_grpc, a binding this SDK does not implement, a malformed URL).
§Errors
Returns ClientError::InvalidEndpoint if the card has no interfaces,
or none for this SDK’s A2A protocol major; the message lists what the
card offers. Earlier releases accepted such a card with a warning, and
it failed at the first call instead.
Sourcepub const fn with_trace_propagation(self, on: bool) -> ClientBuilder
pub const fn with_trace_propagation(self, on: bool) -> ClientBuilder
Whether a call’s traceparent names the call’s own span (default:
yes); see ClientConfig::propagate_trace.
Sourcepub fn with_baggage_propagation(self, policy: BaggagePolicy) -> ClientBuilder
pub fn with_baggage_propagation(self, policy: BaggagePolicy) -> ClientBuilder
Which W3C baggage entries calls send; none by default
(ClientConfig::with_baggage_propagation).
Sourcepub fn with_propagators(self, propagators: Propagators) -> ClientBuilder
pub fn with_propagators(self, propagators: Propagators) -> ClientBuilder
Which propagators calls use, instead of OTEL_PROPAGATORS
(ClientConfig::with_propagators).
Sourcepub const fn with_timeout(self, timeout: Duration) -> ClientBuilder
pub const fn with_timeout(self, timeout: Duration) -> ClientBuilder
Sets the per-request timeout for non-streaming calls, except a
blocking SendMessage, which with_send_timeout bounds.
Sourcepub const fn with_send_timeout(self, timeout: Duration) -> ClientBuilder
pub const fn with_send_timeout(self, timeout: Duration) -> ClientBuilder
Sets how long a blocking SendMessage (without
return_immediately) waits for the agent’s turn to end (default ten
minutes; ClientConfig::send_timeout).
Sourcepub const fn with_stream_connect_timeout(
self,
timeout: Duration,
) -> ClientBuilder
pub const fn with_stream_connect_timeout( self, timeout: Duration, ) -> ClientBuilder
Sets the timeout for establishing a stream: until the response headers arrive, or for reading the error body when the answer is not a stream. Defaults to 30 seconds.
It no longer bounds the wait for the first event — use
with_stream_first_event_timeout
for that. If you set this short to fail fast on a silent agent, set
that one to the same value.
Sourcepub const fn with_stream_first_event_timeout(
self,
timeout: Duration,
) -> ClientBuilder
pub const fn with_stream_first_event_timeout( self, timeout: Duration, ) -> ClientBuilder
Sets how long an established stream may wait for its first data —
an event or a keep-alive comment — before it fails with
ClientError::Timeout.
Defaults to 5 minutes; see
DEFAULT_STREAM_FIRST_EVENT_TIMEOUT
for why.
Sourcepub const fn with_connection_timeout(self, timeout: Duration) -> ClientBuilder
pub const fn with_connection_timeout(self, timeout: Duration) -> ClientBuilder
Sets the TCP connect timeout.
Defaults to 10 seconds. Prevents hanging for the OS default (~2 min)
when the server is unreachable. It bounds the TCP handshake only,
after the name is resolved, and is divided evenly across the
addresses a name resolves to (hyper-util’s HttpConnector); name
resolution and the TLS handshake are bounded by the request timeout.
Until 2026-10-18 this said it covered DNS too, which it does not.
Sourcepub const fn with_stream_idle_timeout(
self,
timeout: Option<Duration>,
) -> ClientBuilder
pub const fn with_stream_idle_timeout( self, timeout: Option<Duration>, ) -> ClientBuilder
Sets how long an established stream may receive no data at all —
events and keep-alive comments alike — before it fails with
ClientError::Timeout. None disables
the bound.
Defaults to 5 minutes; see
ClientConfig::stream_idle_timeout
for how it applies per transport and
DEFAULT_STREAM_IDLE_TIMEOUT
for why that value.
Sourcepub const fn with_max_response_size(self, max_bytes: usize) -> ClientBuilder
pub const fn with_max_response_size(self, max_bytes: usize) -> ClientBuilder
Sets the maximum size in bytes of a buffered (non-streaming) response body. Responses exceeding the cap fail with a transport error instead of being buffered without bound.
Defaults to 32 MiB.
Sourcepub const fn with_max_event_size(self, max_bytes: usize) -> ClientBuilder
pub const fn with_max_event_size(self, max_bytes: usize) -> ClientBuilder
Sets the largest single stream event accepted, in bytes; larger events
are refused and skipped. Defaults to 16 MiB. See
ClientConfig::max_event_size.
Sourcepub fn chosen_interface(&self) -> Option<&AgentInterface>
pub fn chosen_interface(&self) -> Option<&AgentInterface>
The card interface this builder will connect to, when it came from one.
from_card takes the first interface whose binding
the caller prefers, else the card’s first, and
with_protocol_binding can move it.
This is the outcome of those rules, so a caller who needs a
constructor the builder does not drive itself — a
WebSocketTransport (behind the websocket feature) for
with_custom_transport, or
build_grpc (behind the grpc feature) rather than build —
reads the endpoint and binding here instead of re-implementing the
preference.
None when the builder came from ClientBuilder::new, and after
with_protocol_binding named a binding
the card does not advertise: the endpoint is then whatever the caller
set, which is not a card interface.
Sourcepub fn with_protocol_binding(self, binding: impl Into<String>) -> ClientBuilder
pub fn with_protocol_binding(self, binding: impl Into<String>) -> ClientBuilder
Sets the protocol binding, overriding any derived from the agent card.
When this builder came from ClientBuilder::from_card and the card
advertises binding, the endpoint and tenant move to that interface
too. A card gives each binding its own URL, so binding and endpoint are
a pair: setting only the binding left the client speaking the new
protocol to the old one’s port — a card offering JSONRPC at :1111
and GRPC at :2222 produced gRPC-against-:1111, with no error.
If the card does not advertise binding — or the builder came from
ClientBuilder::new — only the binding changes and the endpoint is
left as the caller set it. There is nothing to resolve against, and the
caller is assumed to know their own URL.
A tenant the caller set with ClientBuilder::with_tenant is kept
whichever call comes first; without one, the tenant moves with the
interface (audit G-19).
Sourcepub fn without_interface_fallback(self) -> ClientBuilder
pub fn without_interface_fallback(self) -> ClientBuilder
Uses only the interface from_card chose: when it
cannot be built, build fails instead of moving on.
Without this, build falls back to the card’s next interface when the
chosen one cannot be built here (a binding this SDK does not implement,
a scheme the transports refuse), and the client then talks to whatever
host that interface names. That suits a caller who trusts the card. It is
wrong for one who attaches a credential for the host of the interface
they chose, such as an interceptor that adds Authorization or a token
provider: the card is the agent’s word, the next interface can be on any
host, and the credential would follow it (audit SEC-09).
The error is the chosen interface’s own, so it says why it could not be
built. A builder from ClientBuilder::new has nothing to fall back to,
and with_protocol_binding already does
this, so neither is affected.
Sourcepub const fn with_grpc_bare_address_scheme(
self,
scheme: GrpcBareAddressScheme,
) -> ClientBuilder
pub const fn with_grpc_bare_address_scheme( self, scheme: GrpcBareAddressScheme, ) -> ClientBuilder
Sets how a bare host:port gRPC interface address is dialled.
A card’s gRPC url is a gRPC target with no scheme. The default
(GrpcBareAddressScheme::HttpsExceptLoopback) uses TLS for every
host except loopback; a deployment whose plaintext gRPC lives on a
private network sets GrpcBareAddressScheme::Http. Only
build_grpc (behind the grpc feature) reads this; an address that already
carries a scheme is unaffected.
Sourcepub const fn with_grpc_keep_alive(
self,
interval: Duration,
timeout: Duration,
) -> ClientBuilder
pub const fn with_grpc_keep_alive( self, interval: Duration, timeout: Duration, ) -> ClientBuilder
Has build_grpc (behind the grpc feature) send an HTTP/2 PING every
interval, and drop the connection when none is answered within
timeout (audit B-10, D-12). Off by default: a PING is hop-by-hop,
keeps only the hop to the nearest proxy open, and a server that limits
PINGs (grpc-go answers a client that pings more often than every 5
minutes with GOAWAY) refuses a short interval. See
GrpcTransportConfig::http2_keep_alive_interval. (These are plain
code, not links: the method exists in every build and the gRPC items
only with the feature.)
Sourcepub fn with_grpc_tls_config(self, tls: ClientTlsConfig) -> ClientBuilder
Available on crate feature grpc-tls only.
pub fn with_grpc_tls_config(self, tls: ClientTlsConfig) -> ClientBuilder
grpc-tls only.Sets the TLS configuration build_grpc (behind the grpc feature) uses for
an https:// endpoint, explicit or chosen by the bare-address policy:
a private CA, a client certificate, or a server name that differs from
the host. Without it the server is verified against the bundled
Mozilla roots. The type is re-exported as
transport::grpc::ClientTlsConfig.
Sourcepub fn with_accepted_output_modes(self, modes: Vec<String>) -> ClientBuilder
pub fn with_accepted_output_modes(self, modes: Vec<String>) -> ClientBuilder
Sets the accepted output modes sent in SendMessage configurations.
Sourcepub const fn with_history_length(self, length: u32) -> ClientBuilder
pub const fn with_history_length(self, length: u32) -> ClientBuilder
Sets the history length to request in task responses.
Sourcepub fn with_tenant(self, tenant: impl Into<String>) -> ClientBuilder
pub fn with_tenant(self, tenant: impl Into<String>) -> ClientBuilder
Sets the default tenant for multi-tenancy.
When set, this tenant is included in all requests unless overridden
per-request. Automatically populated from AgentInterface.tenant
when building via ClientBuilder::from_card.
Sourcepub const fn with_return_immediately(self, val: bool) -> ClientBuilder
pub const fn with_return_immediately(self, val: bool) -> ClientBuilder
Sets return_immediately for SendMessage calls.
Sourcepub const fn with_blocking_over_stream(self, val: bool) -> ClientBuilder
pub const fn with_blocking_over_stream(self, val: bool) -> ClientBuilder
Carries a blocking send_message over a stream, so a load balancer’s
idle timeout does not cut a long turn (audit B-11, option 2). Off by
default.
A blocking send is one request with nothing on the wire until the turn
ends. Behind a balancer whose idle timeout is shorter than the turn the
caller gets 504 (and no task id) while the task runs on. A stream
carries a keep-alive comment every 30 s, so with this on, a blocking
send to an agent whose card declares streaming (a client built by
from_card; one built for a bare endpoint has no
card to read and sends as it always did) is opened as
SendStreamingMessage, read until the task is terminal or interrupted
(or the agent answers with one Message), and then answered with the
task as the agent stores it: a GetTask with the send’s
history_length, repeated for a moment if the store has not yet caught
up with the stream, so the result is what the agent’s own blocking
answer would be and not this client’s reading of the events. A send
with return_immediately is not changed.
What it costs and what differs:
- Three wire calls instead of one (the stream, then
GetTask), andsend_timeoutbounds the whole of them. CallInterceptors, spans and metrics seeSendStreamingMessageandGetTask, notSendMessage.- A stream that is cut before the task is terminal or interrupted ends
the send with the stream’s error, as a cut blocking send does; the
task goes on running and
A2aClient::follow_taskpicks it up. - If the stored task does not reach the state the stream reported
within a few seconds the send fails with
ClientError::InvalidAgentResponserather than answer with an older state.
Sourcepub fn with_custom_transport(self, transport: impl Transport) -> ClientBuilder
pub fn with_custom_transport(self, transport: impl Transport) -> ClientBuilder
Provides a fully custom transport implementation.
Overrides the transport that would normally be built from the endpoint URL and protocol preference.
Sourcepub fn without_tls(self) -> ClientBuilder
pub fn without_tls(self) -> ClientBuilder
Disables TLS: plain HTTP only, and build refuses an
https:// endpoint.
Sourcepub fn with_tls_config(self, tls: ClientConfig) -> ClientBuilder
Available on crate feature tls-rustls only.
pub fn with_tls_config(self, tls: ClientConfig) -> ClientBuilder
tls-rustls only.Uses tls for the HTTP bindings (JSON-RPC, HTTP+JSON): extra roots,
a pinned self-signed certificate, or a client certificate for mutual
TLS. tls::tls_config_from_pem
builds one from PEM. Without it the client trusts what
tls::default_tls_config trusts.
Sourcepub fn with_pool(self, pool: &HttpPool) -> ClientBuilder
Available on crate feature tls-rustls only.
pub fn with_pool(self, pool: &HttpPool) -> ClientBuilder
tls-rustls only.Sends the HTTP bindings’ (JSON-RPC, HTTP+JSON) calls through pool,
whose connections every client given it shares, instead of through a
pool of this client’s own. See HttpPool.
A pool owns the TLS configuration and the connect timeout, so
build fails with ClientError::Config naming the
setting if this builder also called
with_tls_config,
without_tls or
with_connection_timeout: set it on
the pool. gRPC and WebSocket clients do not use a pool.
Sourcepub fn with_balancing(
self,
source: impl EndpointSource,
policy: BalancePolicy,
) -> ClientBuilder
pub fn with_balancing( self, source: impl EndpointSource, policy: BalancePolicy, ) -> ClientBuilder
Spreads the HTTP bindings’ (JSON-RPC, HTTP+JSON) calls over the
endpoints source gives, as policy says (ADR 0050; see
balance): each call goes to the endpoint with the
fewest calls in flight, an endpoint that keeps failing is taken out of
rotation for a while, and slow idempotent calls may be hedged.
The builder’s own endpoint stays the client’s name (in spans, errors
and the plaintext check), and an endpoint of another scheme is not
used. With with_pool, the pool’s connections and
per-origin state are used, and the pool’s ejection policy:
build refuses a policy that sets its own. A custom
transport and build_grpc (grpc feature) refuse balancing.
Sourcepub const fn require_https_webhooks(self) -> ClientBuilder
pub const fn require_https_webhooks(self) -> ClientBuilder
Refuses a push-notification config whose webhook URL is http://
to a host other than loopback, before sending it (spec §13.2).
Without this such a config is sent and a warning is logged. See
ClientConfig::require_https_webhooks.
Sourcepub const fn require_https_credentials(self) -> ClientBuilder
pub const fn require_https_credentials(self) -> ClientBuilder
Refuses a call that carries a credential to an http:// or ws://
endpoint on a host other than loopback, before sending it (spec
§13.4: “Credentials SHOULD be transmitted only over encrypted
connections”).
A credential is an Authorization, Proxy-Authorization or Cookie
header, whichever interceptor wrote it, or the header or query
parameter an AuthInterceptor::api_key
writes. Without this such a call is sent and a warning logged, once
per client. Loopback (localhost, 127.0.0.0/8, ::1) is allowed
either way.
Sourcepub const fn without_capability_checks(self) -> ClientBuilder
pub const fn without_capability_checks(self) -> ClientBuilder
Sends every call, whatever the agent card declares.
A client built from a card refuses, before sending anything, a call
that needs an optional capability the card does not declare
(spec §3.3.4): SendStreamingMessage and SubscribeToTask need
capabilities.streaming, the push-config methods and a send with an
inline push config need capabilities.pushNotifications, and
GetExtendedAgentCard needs capabilities.extendedAgentCard. The
refusal is ClientError::CapabilityNotDeclared; a conformant agent
would have refused the call too.
This turns that off, for an agent that serves a capability without declaring it. A client built for a bare endpoint has no card and checks nothing either way.
Sourcepub const fn with_retry_policy(self, policy: RetryPolicy) -> ClientBuilder
pub const fn with_retry_policy(self, policy: RetryPolicy) -> ClientBuilder
Sets a retry policy for transient failures.
When set, the client automatically retries requests that fail with transient errors (connection errors, timeouts, HTTP 429/502/503/504) using exponential backoff.
§Example
use a2a_protocol_client::{ClientBuilder, RetryPolicy};
let client = ClientBuilder::new("http://localhost:8080")
.with_retry_policy(RetryPolicy::default())
.build()?;Sourcepub const fn with_max_in_flight(self, limit: usize) -> ClientBuilder
pub const fn with_max_in_flight(self, limit: usize) -> ClientBuilder
Lets at most limit calls wait for a response at once (audit H6).
A call that finds the cap reached is refused up front with
ClientError::TooManyPendingRequests
instead of being sent, so that a supervisor fanning out to a saturated
peer does not add to the saturation as fast as it can loop. The error is
retryable: with a RetryPolicy the call backs off and tries again as
responses arrive. A streaming call counts until its stream has opened,
not while it stays open. The default is no cap.
The cap is per client. Clients that share nothing each have their own;
share one Arc<A2aClient> per peer to bound the calls to it.
§Errors
build returns ClientError::Config for
a limit of zero, which would refuse every call.
Sourcepub fn with_content_keys(self, keys: Jwks) -> ClientBuilder
Available on crate feature signing only.
pub fn with_content_keys(self, keys: Jwks) -> ClientBuilder
signing only.Verifies the provenance signature (a2a_protocol_types::provenance)
of every artifact and agent message received from the agent against
keys (ADR 0027): in stream events, and in what send_message,
get_task, list_tasks and cancel_task return. Content whose
signature does not verify, because it was altered or signed by a key
not in the set, fails the call (or ends the stream) with
ClientError::ContentNotVerified.
Unsigned content is returned as it is, unverified;
require_signed_content refuses it.
Sourcepub fn with_card_signature_keys(self, keys: Jwks) -> ClientBuilder
Available on crate feature signing only.
pub fn with_card_signature_keys(self, keys: Jwks) -> ClientBuilder
signing only.Verifies the agent’s extended card against keys before anything
is adopted from it (adversarial review N10, 2026-11-13): a card with
no signature, or none that verifies against a key here, is refused by
A2aClient::get_extended_agent_card,
and the client keeps the capabilities and security requirements it had.
from_signed_card sets this with the keys
the public card was verified against; a client built from a card
verified by discovery (CardFetchOptions::with_signature_keys)
sets it here with the same keys. Without it an extended card is
checked for its shape only, as the public card then was.
Sourcepub fn require_signed_content(self) -> ClientBuilder
Available on crate feature signing only.
pub fn require_signed_content(self) -> ClientBuilder
signing only.Refuses unsigned content as well as altered content. Anyone able to
alter content can also remove its signature, so a caller that acts
only on content from known agents requires one. Needs
with_content_keys, called before this.
Sourcepub const fn with_strict_interface_tenant(self) -> ClientBuilder
pub const fn with_strict_interface_tenant(self) -> ClientBuilder
Holds every request to spec §8.3.2 rule 4: its tenant is exactly the
one the selected card interface declares, or absent when it declares
none (adversarial review N12, 2026-11-13).
Without it the client fills a request’s tenant from the selected
interface when the request names none, and two escape hatches stay
open, for a deployment whose tenants are not each a card interface (a
gateway that routes one URL by tenant): a tenant named on a request
(TaskQueryParams::with_tenant and the like) is sent as named, and
with_tenant on a builder made from a card
replaces the interface’s. Each sends a URL, binding, tenant triple
the card does not advertise, which a conforming server may refuse or
route elsewhere.
With it, a request naming another tenant fails before it is sent with
ClientError::Config, and build refuses a builder
made from a card whose tenant was replaced with with_tenant.
Sourcepub const fn with_peer_honouring_idempotency(
self,
honours: bool,
) -> ClientBuilder
pub const fn with_peer_honouring_idempotency( self, honours: bool, ) -> ClientBuilder
Asserts that the peer honours idempotency keys on message/send.
Only needed when the client was not built from an agent card:
from_card reads the advertisement itself.
§What this changes, and what it costs to get wrong
SendMessage is not retried after an ambiguous failure — a
connection dropped after the request bytes went out — because the send
may have executed. A key the server deduplicates on removes that
ambiguity, so a keyed send becomes retryable. Setting this for a peer
that does not honour the key re-introduces exactly the double
execution the rule exists to prevent: the key rides in
Message.metadata, which A2A defines as free-form, so a server that
has never heard of the extension ignores it and runs the send again.
Assert it only for a peer you know implements
https://a2a-rust.com/extensions/idempotency/v1.
Sourcepub fn with_interceptor<I>(self, interceptor: I) -> ClientBuilderwhere
I: CallInterceptor,
pub fn with_interceptor<I>(self, interceptor: I) -> ClientBuilderwhere
I: CallInterceptor,
Adds an interceptor to the chain.
Interceptors are run in the order they are added.
Sourcepub fn with_extensions<I, S>(self, uris: I) -> ClientBuilder
pub fn with_extensions<I, S>(self, uris: I) -> ClientBuilder
Asks the agent to use these extensions on every request: the
A2A-Extensions service parameter (spec §3.2.6), one comma-separated
header (gRPC metadata on gRPC). The agent activates those it supports.
Sent after the interceptors run, and only on a request none of them
gave the header, so an interceptor can ask for another set on a
request. A WebSocket transport sends headers only with its upgrade:
give it the extensions with WebSocketTransportConfig::with_extensions
(feature websocket).
The build refuses a URI that is empty, or holds a comma, whitespace or anything but visible ASCII.
Sourcepub fn skip_required_extension_check(self) -> ClientBuilder
pub fn skip_required_extension_check(self) -> ClientBuilder
Builds even when the card marks an extension required that
with_extensions does not ask for.
a2a.proto AgentExtension.required: “If true, the client must
understand and comply with the extension’s requirements”. A client
built from a card refuses, at build, with
ExtensionSupportRequired, to talk to an agent whose required
extension it has not declared, rather than have every call refused
by the agent. Call this when an interceptor of yours sends the
A2A-Extensions header instead. Since 2026-10-18.
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for ClientBuilder
impl !RefUnwindSafe for ClientBuilder
impl !UnwindSafe for ClientBuilder
impl Forget for ClientBuilder
impl Move for ClientBuilder
impl Send for ClientBuilder
impl Sync for ClientBuilder
impl Unpin for ClientBuilder
impl UnsafeUnpin for ClientBuilder
Blanket Implementations§
§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
§impl<T> FutureExt for T
impl<T> FutureExt for T
§fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
§fn with_current_context(self) -> WithContext<Self> ⓘ
fn with_current_context(self) -> WithContext<Self> ⓘ
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request§impl<L> LayerExt<L> for L
impl<L> LayerExt<L> for L
§fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>where
L: Layer<S>,
fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>where
L: Layer<S>,
Layered].