OptionalconnectionCaller-owned principal partition for MCP sessions. Never sent in headers or bodies. A nonempty partition opts into process-wide reuse for that partition outside a scope. Per-call transport replaces the constructor transport; repeat the partition when overriding it.
OptionalconnectionExplicitly reuse unpartitioned MCP sessions across calls outside a connection scope. Only use when all callers with the same endpoint and credentials represent one principal. Without this opt-in or a partition, unscoped calls close their session after the operation.
OptionalmaxMaximum response body size (in octets) the SDK will read before aborting
with ResponseTooLargeError.
Defaults to 4 MiB (DEFAULT_MAX_RESPONSE_BYTES). Agent responses are
untrusted input, so the cap is on by default on every MCP and A2A call
path — tool calls, endpoint discovery, tools/list, and A2A agent-card
lookup (/.well-known/agent.json). Counted across response chunks as
they arrive; pre-cancels when Content-Length already exceeds the cap.
Raise it for an agent that legitimately publishes a large catalog; lower
it when crawling untrusted agents (registries, federated discovery
layers, monitoring tools). Set it to exactly 0 to opt out of
enforcement entirely — an explicit opt-out, never the default. Infinity
and negative values are not opt-outs: they fall back to the 4 MiB
default, because they almost always arrive from a misparsed env var or a
budget subtraction rather than an intention. Use 0.
Per-call transport replaces the client constructor's transport
object rather than merging field by field
(TaskOptions.transport ?? SingleAgentClientConfig.transport), so a
per-call object that omits maxResponseBytes gets the default back, not
the constructor's value. Repeat the field when you override the object.
Cached MCP connections are keyed on the cap, so varying it per call opens
a separate connection (and MCP session) per distinct value against the
same agent. That is deliberate — a connection established under one
policy must not serve a call that configured another — but it means
raising the cap for one tool is not free. Prefer a single client-level
value where you can, or pin the session explicitly with
withMCPConnectionScope when continuity matters.
SSE is covered too. text/event-stream responses used to be exempt,
which let any peer opt itself out of the cap by changing one response
header. They now carry two bounds: no single event frame may exceed
maxResponseBytes (the memory bound — an SSE consumer buffers one frame
at a time), and the cumulative event-stream octets read during one call
may not exceed maxResponseBytes * 2
(SSE_CUMULATIVE_BUDGET_MULTIPLIER, the liveness bound that stops an
endless drip of individually legal frames). Both failures raise the same
ResponseTooLargeError; nothing is silently truncated.
A long-lived GET event-stream — MCP's standalone notification listener,
the legacy SSE transport — outlives the call that opened it, so it meters
its cumulative allowance per connection instead of per call. That makes
the cumulative number a memory bound there, not a liveness bound: a peer
that keeps tripping it gets a reconnect cycle at a bounded cost per
cycle. Cached connections are keyed on the cap in effect, so a listener
is only ever reused by calls that configured the same policy as the call
that opened it.
OptionaltrustedScoped fetch implementation for all outbound HTTP performed on behalf of this client or call, including endpoint/card discovery, tool listing, OAuth discovery and token refresh, and MCP/A2A tool requests.
The function is runtime-only configuration and is never serialized into
agent records, storyboard artifacts, or compliance output. When unset,
the SDK uses the global fetch implementation.
Supplying this function makes it the trusted network boundary: the SDK still validates URL schemes, redirect behavior, timeouts, body limits, and literal IP addresses, but delegates hostname DNS resolution and resolved address policy to the implementation. It must prevent DNS rebinding and unsafe private-address access itself (for example with an egress proxy or its own DNS pinning).
Optionalinit: RequestInitOptionalinit: RequestInitOptionalfetchOptionalinit: RequestInitOptionalinit: RequestInitOptionalallowPermit this client to connect to private DNS answers. Localhost and an initial private IP literal are allowed automatically only on their exact origin; use this for private-DNS enterprise agents.
OptionalrequestTimeout in milliseconds for bounded one-shot transport requests such as
A2A agent-card discovery and MCP read-path probes. Defaults to 60 seconds
for A2A discovery so an unresponsive card endpoint cannot hang forever.
Set to 0 to disable the SDK-imposed discovery timeout.
OptionallegacyControls the official A2A SDK's v0.3 compatibility layer. A2A only;
ignored for MCP. Defaults to { enabled: true } to preserve existing
interoperability. Set enabled: false for a native A2A 1.0-only path.
Transport-level safeguards applied to a call.
Wired into the SDK's internal fetch chain via AsyncLocalStorage, so the cap takes effect even when the underlying transport's connection cache reuses a fetch that was created on an earlier call with different limits.