Skip to main content

ClientConfig

Struct ClientConfig 

Source
#[non_exhaustive]
pub struct ClientConfig {
Show 19 fields pub preferred_bindings: Vec<String>, pub accepted_output_modes: Vec<String>, pub history_length: Option<u32>, pub return_immediately: bool, pub blocking_over_stream: bool, pub request_timeout: Duration, pub send_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>, pub propagate_trace: bool, pub baggage: BaggagePolicy, pub propagators: Propagators, pub require_https_webhooks: bool,
}
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>
👎Deprecated since 0.15.0:

nothing reads it: from_card follows the card’s interface order (spec §8.3.2); pass a ranking to ClientBuilder::from_card_preferring

The binding ranking interface selection applied.

Deprecated: nothing reads it. Until 0.15 ClientBuilder::from_card ranked the card’s interfaces by this field’s default, ["JSONRPC"]; it now follows the card’s own order, as spec §8.3.2 requires. To rank bindings, pass the ranking to ClientBuilder::from_card_preferring, which still records it here, and see which interface was chosen with ClientBuilder::chosen_interface. Setting it changes nothing. It is removed in a later minor release (STABILITY.md).

§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.

§blocking_over_stream: bool

If true, a blocking send_message to an agent whose card declares streaming is carried over SendStreamingMessage and answered with the task as the agent stores it (audit B-11). Defaults to false.

A blocking send is one request with no bytes on the wire until the turn ends, so a load balancer with a 60 s idle timeout answers 504 for a turn that takes longer while the task goes on running. A stream carries a keep-alive comment every 30 s, which keeps that connection open. See ClientBuilder::with_blocking_over_stream for what the caller gets and what it costs.

§request_timeout: Duration

Per-request timeout for non-streaming calls, except a blocking SendMessage (see send_timeout).

Defaults to 30 seconds.

§send_timeout: Duration

How long a blocking SendMessage (one without return_immediately) waits for the agent’s turn to end. Defaults to DEFAULT_SEND_TIMEOUT, ten minutes: the answer comes only when the turn ends, which for an agent that calls a model is as long as the model takes.

§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.

§propagate_trace: bool

Whether a call’s traceparent names the call’s own span, so the agent called becomes its child (default: yes).

Takes effect with the otel feature, a tracing-opentelemetry layer recording, and a transport this crate built for a binding with per-request headers. Off, nothing is written beyond what TracePropagationInterceptor writes — for a client calling agents that should not learn its trace ids.

§baggage: BaggagePolicy

Which W3C baggage entries a call sends: none by default, as baggage can carry user data to another organisation’s agent (otel_baggage; audit C-10).

§propagators: Propagators

Which propagators calls use: OTEL_PROPAGATORS when this config was made (default tracecontext,baggage).

§require_https_webhooks: bool

Whether a push-notification config whose webhook URL is http:// to a host other than loopback is refused before it is sent (default: no).

Spec §13.2: webhook URLs SHOULD use HTTPS, since the payload, the notification token and any credentials travel with it. Off, such a config is sent and a warning logged; on, create_push_config, and a send carrying the config inline, fail with ClientError::InsecureWebhook. http:// to localhost, 127.0.0.0/8 or ::1 is allowed either way.

Implementations§

Source§

impl ClientConfig

Source

pub const fn with_trace_propagation(self, on: bool) -> ClientConfig

Source

pub const fn with_require_https_webhooks(self, on: bool) -> 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

👎Deprecated since 0.15.0:

nothing reads preferred_bindings: from_card follows the card’s interface order (spec §8.3.2); pass a ranking to ClientBuilder::from_card_preferring

Sets preferred_bindings, which nothing reads; see the field.

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_blocking_over_stream(self, val: bool) -> ClientConfig

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_send_timeout(self, timeout: Duration) -> ClientConfig

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 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.

Source§

impl ClientConfig

Source

pub fn with_baggage_propagation(self, policy: BaggagePolicy) -> ClientConfig

Which baggage entries this client sends; BaggagePolicy::Off by default. See the module for why it is opt-in.

Source

pub fn with_propagators(self, propagators: Propagators) -> ClientConfig

Which propagators the calls use, instead of what OTEL_PROPAGATORS said when this config was made.

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
§

impl<'a, T, E> AsTaggedExplicit<'a, E> for T
where T: 'a,

§

fn explicit(self, class: Class, tag: u32) -> TaggedParser<'a, Explicit, Self, E>

§

impl<'a, T, E> AsTaggedImplicit<'a, E> for T
where T: 'a,

§

fn implicit( self, class: Class, constructed: bool, tag: u32, ) -> TaggedParser<'a, Implicit, Self, E>

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
§

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

§

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.

§

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

§

fn from_ref(input: &T) -> T

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

impl<T> FutureExt for T

§

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

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

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

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

impl<T> Instrument for T

§

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

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

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
§

impl<T> IntoRequest<T> for T

§

fn into_request(self) -> Request<T>

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

impl<L> LayerExt<L> for L

§

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].
§

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.
§

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

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

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
§

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

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