Skip to main content

ClientConfig

Struct ClientConfig 

Source
#[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
Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional 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: bool

If true, send_message returns immediately with the submitted task rather than waiting for completion.

§request_timeout: Duration

Per-request timeout for non-streaming calls.

Defaults to 30 seconds.

§stream_connect_timeout: Duration

Timeout 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: Duration

Longest 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: Duration

TCP 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: usize

Maximum 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 the websocket feature) — bounded by WebSocketTransportConfig::max_message_size, which defaults to this same constant. So the two agree until you change one: tightening max_response_size to 1 MiB and connecting over WebSocket still admits 32 MiB. Set it on WebSocketTransportConfig instead.
  • SlimRpcTransport in a2a-protocol-slimrpc — receive cap is tonic’s inherited 4 MiB, eight times tighter than this default, and not settable at all.
§max_event_size: usize

Largest 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: TlsConfig

TLS 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

Source

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

Source

pub fn with_preferred_bindings(self, bindings: Vec<String>) -> ClientConfig

Sets the ordered binding preference list.

Source

pub fn with_accepted_output_modes(self, modes: Vec<String>) -> ClientConfig

Sets the MIME types advertised in acceptedOutputModes.

Source

pub const fn with_history_length(self, length: Option<u32>) -> ClientConfig

Sets the history length requested; None uses the agent’s default.

Source

pub const fn with_return_immediately(self, val: bool) -> ClientConfig

Sets whether send_message returns as soon as the task is submitted.

Source

pub const fn with_request_timeout(self, timeout: Duration) -> ClientConfig

Sets the per-request timeout for non-streaming calls.

Source

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.

Source

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.

Source

pub const fn with_connection_timeout(self, timeout: Duration) -> ClientConfig

Sets the TCP connection timeout (DNS + handshake).

Source

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.

Source

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.

Source

pub const fn with_max_event_size(self, max_bytes: usize) -> ClientConfig

Sets the largest single stream event accepted. See max_event_size.

Source

pub const fn with_tls(self, tls: TlsConfig) -> ClientConfig

Sets the TLS configuration.

Source

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

Source§

fn clone(&self) -> ClientConfig

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for ClientConfig

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl Default for ClientConfig

Source§

fn default() -> ClientConfig

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> FromRef<T> for T
where T: Clone,

Source§

fn from_ref(input: &T) -> T

Converts to this type from a reference to the input type.
Source§

impl<T> FutureExt for T

Source§

fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ

Attaches the provided Context to this type, returning a WithContext wrapper. Read more
Source§

fn with_current_context(self) -> WithContext<Self> ⓘ

Attaches the current Context to this type, returning a WithContext wrapper. Read more
Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> IntoRequest<T> for T

Source§

fn into_request(self) -> Request<T>

Wrap the input message T in a tonic::Request
Source§

impl<L> LayerExt<L> for L

Source§

fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>
where L: Layer<S>,

Applies the layer to a service and wraps it in Layered.
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more