#[non_exhaustive]pub struct ClientConfig {Show 13 fields
pub preferred_bindings: Vec<String>,
pub accepted_output_modes: Vec<String>,
pub history_length: Option<u32>,
pub return_immediately: bool,
pub request_timeout: Duration,
pub stream_connect_timeout: Duration,
pub stream_first_event_timeout: Duration,
pub connection_timeout: Duration,
pub stream_idle_timeout: Option<Duration>,
pub max_response_size: usize,
pub max_event_size: usize,
pub tls: TlsConfig,
pub tenant: Option<String>,
}Expand description
Configuration for an crate::A2aClient instance.
Build via crate::ClientBuilder. Reasonable defaults are provided for all
fields; most users only need to set the agent URL.
#[non_exhaustive]: build it with Default and the with_* setters,
which cover every field; a struct literal is not available outside this
crate, so a field added later does not break callers.
Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.preferred_bindings: Vec<String>Ordered list of preferred protocol bindings.
The client tries each in order, selecting the first one supported by the
target agent’s card. Defaults to ["JSONRPC"].
accepted_output_modes: Vec<String>MIME types the client will advertise in acceptedOutputModes.
Defaults to ["text/plain", "application/json"].
history_length: Option<u32>Number of historical messages to include in task responses.
None means use the agent’s default.
return_immediately: boolIf true, send_message returns immediately with the submitted task
rather than waiting for completion.
request_timeout: DurationPer-request timeout for non-streaming calls.
Defaults to 30 seconds.
stream_connect_timeout: DurationTimeout for establishing a stream: until the response headers arrive (gRPC: until the call is accepted), and for reading the error body when the answer is not a stream. Defaults to 30 seconds.
It does not bound the first event; that is
stream_first_event_timeout.
Until that knob existed this one did both, and cut off an agent that
flushed its headers and then thought for longer than 30 seconds. If
you shortened this to fail fast on a silent agent, set that one too.
stream_first_event_timeout: DurationLongest an established stream may wait for its first data;
defaults to DEFAULT_STREAM_FIRST_EVENT_TIMEOUT (5 minutes). Any
bytes satisfy it, a keep-alive comment included; after that,
stream_idle_timeout governs. Expiry
yields ClientError::Timeout.
Applied by A2aClient to every stream it opens,
on every transport — for a WebSocket transport this replaces
WebSocketTransportConfig::request_timeout as the first-frame bound.
connection_timeout: DurationTCP connection timeout (DNS + handshake).
Prevents the client from hanging for the OS default (~2 minutes) when the server is unreachable. Defaults to 10 seconds.
stream_idle_timeout: Option<Duration>Longest an established stream may go without receiving any data
once its first data has arrived; None disables the bound. Defaults
to DEFAULT_STREAM_IDLE_TIMEOUT (5 minutes; see it for why).
Any bytes reset it, SSE : keep-alive comments included, so a stream
from a server that heartbeats runs as long as the task does. Expiry
yields ClientError::Timeout and ends
the stream; the task is not cancelled, so resubscribe to continue.
Applied by A2aClient to every stream it opens,
on every transport, a custom one included. gRPC and WebSocket streams
carry no heartbeat the stream can see, so there it bounds the gap
between events: raise it, or set None, for agents known to think
silently for longer.
max_response_size: usizeMaximum size in bytes of a buffered (non-streaming) response body.
Responses exceeding this cap fail with a transport error instead of being buffered without bound. Defaults to 32 MiB — large enough for big task histories and inline artifacts while still bounding client memory against a hostile or buggy server.
§What it reaches
Every transport ClientBuilder constructs:
JSON-RPC and REST enforce it directly, and gRPC and WebSocket receive
it as their max_message_size.
It does not reach a transport supplied by
with_custom_transport,
which never sees this config and carries whatever bound it was built
with. Two shipped transports are in that position:
WebSocketTransport(behind thewebsocketfeature) — bounded byWebSocketTransportConfig::max_message_size, which defaults to this same constant. So the two agree until you change one: tighteningmax_response_sizeto 1 MiB and connecting over WebSocket still admits 32 MiB. Set it onWebSocketTransportConfiginstead.SlimRpcTransportina2a-protocol-slimrpc— receive cap is tonic’s inherited 4 MiB, eight times tighter than this default, and not settable at all.
max_event_size: usizeLargest single stream event accepted, in bytes: the data: of one SSE
event, or one gRPC or WebSocket stream message (those are bridged
through the same parser). Defaults to 16 MiB, the server’s own default.
An event over the limit is refused with
ClientError::Transport naming the
sizes and skipped, and the stream carries on with the next event. A
line that outgrows every legal event — a peer sending bytes with no
newline — is refused as soon as it does, so the parser never holds
more than about this many bytes of one line.
Applied by A2aClient to every stream it opens.
tls: TlsConfigTLS configuration.
tenant: Option<String>Default tenant identifier for multi-tenancy.
When set, this tenant is included in all requests unless overridden
per-request. Automatically populated from AgentInterface.tenant
when building via crate::ClientBuilder::from_card.
Implementations§
Source§impl ClientConfig
impl ClientConfig
Sourcepub fn default_http() -> ClientConfig
pub fn default_http() -> ClientConfig
Returns the default configuration suitable for connecting to a local or well-known agent over plain HTTP.
Source§impl ClientConfig
impl ClientConfig
Sourcepub fn with_preferred_bindings(self, bindings: Vec<String>) -> ClientConfig
pub fn with_preferred_bindings(self, bindings: Vec<String>) -> ClientConfig
Sets the ordered binding preference list.
Sourcepub fn with_accepted_output_modes(self, modes: Vec<String>) -> ClientConfig
pub fn with_accepted_output_modes(self, modes: Vec<String>) -> ClientConfig
Sets the MIME types advertised in acceptedOutputModes.
Sourcepub const fn with_history_length(self, length: Option<u32>) -> ClientConfig
pub const fn with_history_length(self, length: Option<u32>) -> ClientConfig
Sets the history length requested; None uses the agent’s default.
Sourcepub const fn with_return_immediately(self, val: bool) -> ClientConfig
pub const fn with_return_immediately(self, val: bool) -> ClientConfig
Sets whether send_message returns as soon as the task is submitted.
Sourcepub const fn with_request_timeout(self, timeout: Duration) -> ClientConfig
pub const fn with_request_timeout(self, timeout: Duration) -> ClientConfig
Sets the per-request timeout for non-streaming calls.
Sourcepub const fn with_stream_connect_timeout(
self,
timeout: Duration,
) -> ClientConfig
pub const fn with_stream_connect_timeout( self, timeout: Duration, ) -> ClientConfig
Sets the timeout for establishing a stream (headers, or an error
body). See stream_connect_timeout.
Sourcepub const fn with_stream_first_event_timeout(
self,
timeout: Duration,
) -> ClientConfig
pub const fn with_stream_first_event_timeout( self, timeout: Duration, ) -> ClientConfig
Sets how long an established stream may wait for its first data. See
stream_first_event_timeout.
Sourcepub const fn with_connection_timeout(self, timeout: Duration) -> ClientConfig
pub const fn with_connection_timeout(self, timeout: Duration) -> ClientConfig
Sets the TCP connection timeout (DNS + handshake).
Sourcepub const fn with_stream_idle_timeout(
self,
timeout: Option<Duration>,
) -> ClientConfig
pub const fn with_stream_idle_timeout( self, timeout: Option<Duration>, ) -> ClientConfig
Sets how long an established stream may receive nothing before it is
failed with a timeout; None disables the bound. See
stream_idle_timeout.
Sourcepub const fn with_max_response_size(self, max_bytes: usize) -> ClientConfig
pub const fn with_max_response_size(self, max_bytes: usize) -> ClientConfig
Sets the buffered response body cap. See
max_response_size for which transports
it reaches.
Sourcepub const fn with_max_event_size(self, max_bytes: usize) -> ClientConfig
pub const fn with_max_event_size(self, max_bytes: usize) -> ClientConfig
Sets the largest single stream event accepted. See
max_event_size.
Sourcepub const fn with_tls(self, tls: TlsConfig) -> ClientConfig
pub const fn with_tls(self, tls: TlsConfig) -> ClientConfig
Sets the TLS configuration.
Sourcepub fn with_tenant(self, tenant: Option<String>) -> ClientConfig
pub fn with_tenant(self, tenant: Option<String>) -> ClientConfig
Sets the default tenant; None sends none unless a request names one.
Trait Implementations§
Source§impl Clone for ClientConfig
impl Clone for ClientConfig
Source§fn clone(&self) -> ClientConfig
fn clone(&self) -> ClientConfig
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for ClientConfig
impl Debug for ClientConfig
Source§impl Default for ClientConfig
impl Default for ClientConfig
Source§fn default() -> ClientConfig
fn default() -> ClientConfig
Auto Trait Implementations§
impl Freeze for ClientConfig
impl RefUnwindSafe for ClientConfig
impl Send for ClientConfig
impl Sync for ClientConfig
impl Unpin for ClientConfig
impl UnsafeUnpin for ClientConfig
impl UnwindSafe for ClientConfig
Blanket Implementations§
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> FutureExt for T
impl<T> FutureExt for T
Source§fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
Source§fn with_current_context(self) -> WithContext<Self> ⓘ
fn with_current_context(self) -> WithContext<Self> ⓘ
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§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 moreSource§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request