Skip to content

docs(security): default agent response cap to 4 MiB and keep discovery responses small - #8200

Merged
bokelley merged 1 commit into
mainfrom
conductor/response-size-default-4mib
Oct 14, 2026
Merged

bokelley merged 1 commit into
mainfrom
conductor/response-size-default-4mib

Conversation

@bokelley

@bokelley bokelley commented Oct 14, 2026 •

Copy link
Copy Markdown
Contributor

Follow-up to #8192 (d1fa747d9), implementing three maintainer decisions. Tracking issue: #8190.

Decisions implemented

  1. Default 1 MiB → 4 MiB. The Go (Fix missing spacing in web chat after tool use #561), TypeScript (docs(security): production key storage subsection for RFC 9421 signing #3255), Python (Reskin registry pages and add cross-navigation #1504) and Java (Enhance AdCP schemas with comprehensive targeting and format types #40) SDKs and the hosted grader all default to 4 MiB, so the spec now matches. 4 MiB remains the ceiling on what any default may be; a tighter default stays conformant.
  2. Strength stays SHOULD. Unchanged.
  3. Seller-side guidance added. Agents SHOULD keep tools/list, get_adcp_capabilities and the A2A agent card well under the default client cap, and paginate large catalogs.

Two sub-default figures that would have made the raise cosmetic

Review caught these, and they are the substantive part of the PR.

A2A's per-DataPart 1 MiB had to move. The instruction was to leave it alone unless it contradicts the whole-call text — it does. a2a-response-extraction.mdx states the single-artifact invariant: an AdCP task produces one artifact, and the last DataPart in it is the authoritative response. So the authoritative part is the whole payload; the bounds do not compose. A 1 MiB per-part figure would have silently become the effective A2A cap and rejected over A2A exactly what the byte-identical MCP call accepts — the transport divergence this bound exists to prevent, relocated rather than removed. It is now the call limit, with the reasoning written into the page so it is not "corrected" back. Earlier DataParts are superseded progress snapshots and a client MAY bound those more tightly.

MCP had the same bug, untouched by the original PR. The normative extraction algorithm hard-codes a 1 MB check on content[].text. For a server that returns only content[].text, that item is the entire response, so raising the streamed cap to 4 MiB would have changed nothing for those servers. Now the configured limit, with the reference implementation in tests/mcp-response-extraction.test.cjs kept in sync.

Two bounds the 4x raise makes load-bearing

  • Aggregate exposure (requirement 9) was the only requirement without a number, and raising the per-call figure 4x makes it the one that bites: 64 concurrent peers at 4 MiB is 256 MiB raw and several times that resident, every peer individually conformant — against the fan-out deployment cited as the reason to move to 4 MiB. It now says the aggregate budget covers nodes as well as bytes and is not the per-call default multiplied by concurrency.
  • Scalar length (requirement 6). Depth 64 and 100,000 members do not bound one string; a 4 MiB scalar is one node and trivially conformant. The old 1 MiB default capped this incidentally. Per-field length limits, not node count, are what keep it out of a log or a model context.

Corrections to claims in the first draft of this PR

  • The 64 KiB agent-card figure was invented. It appears nowhere else in the repo, and security.mdx places the agent card under the general bound — which this PR just set to 4 MiB. A client implementer could have read the table as a reject threshold and become non-interoperable with conformant agents. It is now explicitly an editorial target, by analogy with MAX_JWKS_BYTES/MAX_CAPABILITIES_BYTES, with "a client MUST NOT reject an agent card at 64 KiB" stated outright. The migration-guide sentence is split so the normative 64 KiB is not conflated with the advisory one.
  • "No fallback" was false for get_adcp_capabilities. protocols[] narrows it. The text now distinguishes per-surface recourse: the agent card has no narrowing lever (and the authenticated extended card is larger), tools/list page size is the server's choice since MCP's cursor has no page-size parameter, and capabilities can be narrowed — but the signing-key discovery path does not narrow, which is the case that matters.
  • An anchor did not support its claim. "Signing-key discovery path" pointed at #agent-key-publication, which never mentions MAX_CAPABILITIES_BYTES. Retargeted, and request_signature_capabilities_unreachable is now named so a reader can verify the chain.
  • The capabilities 64 KiB binds signers, not everyone; a purely non-signing agent is bounded only by the client default. Qualified.
  • "thirty-fold" → "32x" (exact). Section-name drift fixed.

Loosening documented on the brand.json precedent

This loosens a limit, which the migration guide previously said only brand.json did. Added ### Client response-size default rises to 4 MiB modeled on #brand-json-size-cap-rises-to-2-mib, including the transition-window rule that has no analogue otherwise: a seller spending the new headroom still breaks against every 3.2-era 1 MiB client, with no protocol error it can see. Also added the 3.3 feature-narrative entry that #8192 never wrote, which 3-2-to-3-3.mdx already pointed readers to.

The precedence list now also names the attestation resolution fetch cap, the max_embedded_credential_bytes ceiling, the format_schema/adagents.json publisher-origin cap, and the A2A auth-challenge cap, since that paragraph is the sole assertion that 4 MiB did not move them.

Follow-ups filed

Both are referenced from the new docs section as known tensions.

Tests

tests/response-size-bounds.test.cjs is at 42 assertions, all mutation-checked. New guard: no L0 transport profile may state a byte figure below the whole-call default without a justification clause — the invariant both transports had broken.

Local: test:contracts, test:docs-nav, test:doc-compliance-drift, test:compliance-snippets, lint:schema-links, test:json-schema, test-coverage registration, and the full pre-commit hook all pass. test:snippets has 12 pre-existing failures in get_products.mdx, sync_creatives.mdx and testable-examples-demo.md — files not touched here, which execute against a hosted test agent.

Reviewed before opening by an ad-tech-protocol-expert and a security-reviewer agent; every finding is implemented or answered above.

🤖 Generated with Claude Code


Open workspace in Conductor

…y responses small

The Go, TypeScript, Python and Java SDKs and the hosted grader all ship a
4 MiB default, so raise the MCP and A2A whole-call defaults from 1 MiB to
match. 4 MiB stays the ceiling on what any default may be, and a tighter
default stays conformant. This loosens a limit: a client still enforcing
1 MiB rejects a response a 3.3 client accepts.

Aligning the defaults raises no path-specific cap. The precedence list
now also names the attestation resolution fetch cap, the
max_embedded_credential_bytes ceiling, the format_schema and
adagents.json publisher-origin cap, and the A2A auth-challenge cap.

Correct two sub-default figures that would otherwise have become the
real cap:

- A2A's per-DataPart bound was 1 MiB. The single-artifact invariant
  makes the authoritative DataPart the whole response, so a tighter
  per-part number silently became the effective A2A cap and rejected
  over A2A what the byte-identical MCP call accepts. It is now the call
  limit, with the reasoning stated so it is not "fixed" back.
- The MCP extraction algorithm hard-coded a 1 MB content[].text check.
  For a server that returns only content[].text, that item is the entire
  response. It is now the configured limit.

Two bounds gain the detail the 4x raise makes load-bearing: an aggregate
budget covers nodes as well as bytes and is not the per-call default
multiplied by concurrency, and depth and node bounds do not limit the
length of a single scalar, so per-field length limits are what keep a
4 MiB string out of a log or a model context.

Add the seller-side counterpart. Agents SHOULD keep tools/list,
get_adcp_capabilities and the agent card well under the default client
cap and paginate large catalogs. Discovery is where oversize makes an
agent unreachable rather than slow, and the recourse differs per
surface: the agent card has no narrowing lever, tools/list page size is
the server's choice, and get_adcp_capabilities narrows with protocols[]
but the signing-key discovery path does not — so a capabilities document
over MAX_CAPABILITIES_BYTES fails request_signature_capabilities_unreachable
and makes signing keys unresolvable. The agent-card target is marked
editorial rather than a cap a client may enforce, and the capabilities
target is scoped to agents that sign.

Flags two tensions found in review: #8197 (a third party can inflate
publisher_domains past the capabilities budget and break key discovery)
and #8198 (supported_formats pushes creative agents past the same
budget).

Refs: #8190

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>

@aao-secretariat aao-secretariat Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ladon verdict: Approve

Approve — docs/spec-only PR raising the client response-size default from 1 MiB to 4 MiB across the MCP and A2A transport profiles, with migration/whats-new updates, seller-side discovery guidance, and matching tests.

What I checked:

  • No static/schemas/source/** touched, so no schema↔docs drift, oneOf discriminator, or dist-immutability concern applies.
  • The minor changeset is present and correctly scoped — loosening a client-enforced default to codify SDK behavior is non-breaking (existing tighter clients stay conformant), so this is not a Breaking-class change and the hard gate does not fire.
  • Reviewer spot-checked every newly-cited cap (256 KB auth-challenge, 1 MiB format_schema/adagents, 1 MiB attestation resolution, 64 KiB MAX_CAPABILITIES_BYTES) and the request_signature_capabilities_unreachable error code against base — all accurate; new heading anchors resolve.
  • No blocking or medium findings.

high_risk is true only because two docs/reference/** files were (modified); with no medium-or-higher findings on those files, the modification is presumed safe (no deletions). gated_paths is false, and no no-auto-approve team match. None of decision rows 1–8 fire, so the outcome falls through to row 9: approve.

@bokelley
bokelley merged commit d033bae into main Oct 14, 2026
37 checks passed
@bokelley
bokelley deleted the conductor/response-size-default-4mib branch October 14, 2026 11:18
bokelley added a commit to adcontextprotocol/adcp-client-python that referenced this pull request Oct 15, 2026
adcp#8200 aligned the spec and removed the hard-coded 1 MB `content[].text`
check from the MCP extraction algorithm. The reason is specific: for a
server that answers with `content[].text` and no `structuredContent`, that
one item *is* the whole response, so a per-text limit tighter than the call
limit silently becomes the effective call cap. This SDK shipped exactly that
— `_MAX_TEXT_SIZE_BYTES = 1_048_576` — so a text-fallback server was bounded
at 1 MiB no matter what `max_response_bytes` said, and a 2 MiB response
failed under a 4 MiB default.

The bound is now the configured per-call budget, resolved through
`resolve_max_response_bytes` so a `TaskOptions` override reaches the
post-parse check too, and `None` disables it exactly as it does on the
transport.

It raises rather than skipping. A skipped item left extraction reporting "no
structured data found", which a caller cannot tell from a server that
genuinely sent none — worse, when a later item parsed, the oversized one
vanished entirely and the call succeeded on whatever followed it. Spec
§Response Size Bounds (7) requires the distinct error instead.

Bytes, not characters: the budget is a wire figure, so the check measures
UTF-8 length, skipping the encode for any string short enough that it cannot
matter.

The error path shares the budget for the same reason — `isError: true` plus
a giant payload is the same allocation primitive, and the 4 KiB `adcp_error`
cap only applies after `json.loads` has already run.

A2A has no equivalent per-part figure; nothing to change there.

Refs #1503, adcontextprotocol/adcp#8200

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
bokelley added a commit to adcontextprotocol/adcp-client-python that referenced this pull request Oct 15, 2026
… live path

Both review passes landed on the same two things.

The guard allocated what it was defending against. Past the `limit // 4`
short-circuit it encoded unconditionally, so a 64 MiB text item under a
4 MiB budget peaked at 64 MiB of transient `bytes` to conclude 4 MiB was
exceeded — 16x the budget, and the one place in this PR that broke the
discipline `_response_limit.py` states for itself. UTF-8 is at least one
byte per character, so `len(text) > limit` already proves the overrun; the
encode is now the last resort, reached only for a string already known to be
within a factor of four, and `received` reads as the lower bound the message
already called it.

`from_mcp_client()` was documented as uncapped while the new bound applied to
it — and applied to only one of its two extraction paths, decided by whether
the in-process server happened to emit `structuredContent` or text. The
contradiction resolves toward keeping the bound, because that session is
exactly where it is load-bearing: this SDK does not own that transport, so
nothing counted those bytes on the way in. `from_mcp_client()` now takes
`max_response_bytes`, and the docstring and README say which half of the
budget applies. The asymmetry with `structuredContent` stays and is now
explained: it arrives already parsed by the MCP SDK, so its allocation has
happened before any SDK code runs.

Both reviews also noted the end-to-end tests passed without reaching the
code they test — the transport pre-rejects on the declared Content-Length,
and `caught.value.limit` cannot tell the layers apart. They now assert
`declared`, and an injected-session test covers the raise on the only path
that can reach it. Deleting the bound fails 8 tests; it failed none of the
end-to-end ones before.

Smaller, from the same reviews:

- `max_response_bytes=None` removed the last backstop silently. Spec
  §Response Size Bounds (8) asks that calls made without a bound be logged;
  it now says so once per agent.
- `f"Got content: {result.content}"` put up to a whole budget of unhygienated
  server text into `TaskResult.error`, which in an agentic buyer goes
  straight into a model context — the leak class point 7 forbids, one branch
  from where this PR gets it right. Bounded to 512 characters.
- `ADCPResponseTooLargeError`'s docstring promised the body was never
  buffered, which stopped being true of every path.
- Tests for the astral-plane case that makes `limit // 4` exactly tight, a
  lone surrogate (which would crash the guard without `surrogatepass`), the
  equality boundary, and `structuredContent` winning over an over-budget
  text item.
- The CHANGELOG now states that two public functions raise where they used
  to return `None`.

Refs #1503, adcontextprotocol/adcp#8200

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
bokelley added a commit to adcontextprotocol/adcp-client-python that referenced this pull request Oct 15, 2026
* feat(client): cap agent response size by default

Agent responses are untrusted input. A seller answering one tool call with
tens of megabytes could exhaust a buyer's memory long before any parser ran:
nothing on the MCP or A2A call path bounded a response body, and the existing
1 MiB `_MAX_TEXT_SIZE_BYTES` check only skipped oversized `content[].text`
after the whole result was already in memory.

Add `AgentConfig.max_response_bytes`, defaulting to 4 MiB, and enforce it in a
size-limiting httpx transport installed under every client the adapters build —
MCP streamable HTTP, MCP SSE, the MCP session-close DELETE, and A2A (JSON-RPC,
streamed events, and the agent card). The budget is enforced while the body is
read: an over-cap `Content-Length` is refused before the first body byte, and
decoded bytes are counted as they arrive so a compression bomb trips on the
chunk that expands past the cap. SSE is measured per event as well as
cumulatively per call, so a peer cannot slip a large payload past the budget by
replying with `Content-Type: text/event-stream`. Only `gzip`/`deflate` are
requested, and a response in another coding is refused rather than expanded
unmeasured.

An oversized response raises the new `ADCPResponseTooLargeError` and is never
truncated. Both adapters recover the typed error from the transport failures
that bury it — MCP's anyio writer task reports a `CancelledError`, and
`a2a-sdk` rewraps as its own error type.

Override per agent with `AgentConfig.max_response_bytes`, per call with
`TaskOptions(max_response_bytes=...)`, or opt out with
`AgentConfig.max_response_bytes=None`.

Closes #1503
Refs adcontextprotocol/adcp#8190

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>

* fix(client): close the response-cap gaps found in review

Expert code review and security review of the previous commit each found
ways the budget could be evaded, mis-scoped, or lost.

Surfacing. An oversized *handshake* escaped as a bare `asyncio.CancelledError`
— the cancellation branch in `_get_session` ran before the budget check, and a
limiter abort inside MCP's writer task arrives precisely as a cancellation.
`tools/list` and `get_agent_info` had no conversion at all, so an oversized
tool listing killed them the same way. Both now run through one helper that
also balances the swallowed cancellation with `Task.uncancel()`, and the
unsupported-coding rejection is typed (`ADCPResponseEncodingError`) so it
travels the same path.

Scope. The cumulative cap was per HTTP response, but MCP's legacy SSE
transport and its standalone notification stream carry a whole session on one
`GET` body — so a healthy long session would eventually fail. A session-
lifetime `GET` event-stream is now capped per event only; a per-call body
(including the event-stream answer to a streamable-HTTP POST) keeps both caps.
A per-call `TaskOptions` override no longer reaches that background stream,
where MCP's context snapshot would have let it outlive its call and rebind the
budget for the rest of the session.

Containment. `ADCPMultiAgentClient` fanned out with bare `asyncio.gather`, so
one hostile seller padding a reply discarded every honest seller's results.
A budget rejection now becomes that agent's failed `TaskResult`; every other
exception keeps abort-on-first-exception.

The limiter itself. It asked zlib for the whole remaining budget in one call
and copied the result, allocating 2x the budget to measure a bomb — it now
decodes in 64 KiB slices and keeps decoded bytes only when SSE needs them.
Concatenated gzip/deflate members are counted whole instead of stopping at the
first. Compressed bodies get a wire ceiling, so a stream padded with empty
deflate blocks cannot run forever under a decoded-bytes budget. `identity` is
no longer read as an extra coding, and the URL in the error message is
stripped of userinfo, query and fragment.

Installation fails closed on the SDK's own clients and warns on an adopter's:
a custom `httpx_client_factory` may return a duck-typed client this SDK cannot
reach into, which stays supported but is no longer silently uncapped.

Refs #1503, adcontextprotocol/adcp#8190

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>

* fix(client): propagate the encoding rejection typed on every path

Review found the MCP tool-call path listing only `ADCPResponseTooLargeError`
in its re-raise tuple, so an unmeasurable-coding rejection fell through to
`TaskResult(FAILED)` there while A2A and MCP's own session paths raised it.
The body was still refused either way — only the typed surface diverged by
protocol. Both now share `_BUDGET_ERRORS`, with a test on the tool-call path.

Also narrow the two `except BaseException` handlers to
`(Exception, asyncio.CancelledError)`: the cancellation is the one base
exception that has to be caught, because that is how a limiter abort inside
MCP's writer task reaches the awaiting call. `GeneratorExit`,
`KeyboardInterrupt` and `SystemExit` now propagate as they should. Drop a
redundant local `import asyncio` in the new fan-out helper.

Refs #1503

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>

* fix(client): bound content[].text by the call budget, not a fixed 1 MiB

adcp#8200 aligned the spec and removed the hard-coded 1 MB `content[].text`
check from the MCP extraction algorithm. The reason is specific: for a
server that answers with `content[].text` and no `structuredContent`, that
one item *is* the whole response, so a per-text limit tighter than the call
limit silently becomes the effective call cap. This SDK shipped exactly that
— `_MAX_TEXT_SIZE_BYTES = 1_048_576` — so a text-fallback server was bounded
at 1 MiB no matter what `max_response_bytes` said, and a 2 MiB response
failed under a 4 MiB default.

The bound is now the configured per-call budget, resolved through
`resolve_max_response_bytes` so a `TaskOptions` override reaches the
post-parse check too, and `None` disables it exactly as it does on the
transport.

It raises rather than skipping. A skipped item left extraction reporting "no
structured data found", which a caller cannot tell from a server that
genuinely sent none — worse, when a later item parsed, the oversized one
vanished entirely and the call succeeded on whatever followed it. Spec
§Response Size Bounds (7) requires the distinct error instead.

Bytes, not characters: the budget is a wire figure, so the check measures
UTF-8 length, skipping the encode for any string short enough that it cannot
matter.

The error path shares the budget for the same reason — `isError: true` plus
a giant payload is the same allocation primitive, and the 4 KiB `adcp_error`
cap only applies after `json.loads` has already run.

A2A has no equivalent per-part figure; nothing to change there.

Refs #1503, adcontextprotocol/adcp#8200

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>

* fix(client): bound the extraction guard's own allocation and name its live path

Both review passes landed on the same two things.

The guard allocated what it was defending against. Past the `limit // 4`
short-circuit it encoded unconditionally, so a 64 MiB text item under a
4 MiB budget peaked at 64 MiB of transient `bytes` to conclude 4 MiB was
exceeded — 16x the budget, and the one place in this PR that broke the
discipline `_response_limit.py` states for itself. UTF-8 is at least one
byte per character, so `len(text) > limit` already proves the overrun; the
encode is now the last resort, reached only for a string already known to be
within a factor of four, and `received` reads as the lower bound the message
already called it.

`from_mcp_client()` was documented as uncapped while the new bound applied to
it — and applied to only one of its two extraction paths, decided by whether
the in-process server happened to emit `structuredContent` or text. The
contradiction resolves toward keeping the bound, because that session is
exactly where it is load-bearing: this SDK does not own that transport, so
nothing counted those bytes on the way in. `from_mcp_client()` now takes
`max_response_bytes`, and the docstring and README say which half of the
budget applies. The asymmetry with `structuredContent` stays and is now
explained: it arrives already parsed by the MCP SDK, so its allocation has
happened before any SDK code runs.

Both reviews also noted the end-to-end tests passed without reaching the
code they test — the transport pre-rejects on the declared Content-Length,
and `caught.value.limit` cannot tell the layers apart. They now assert
`declared`, and an injected-session test covers the raise on the only path
that can reach it. Deleting the bound fails 8 tests; it failed none of the
end-to-end ones before.

Smaller, from the same reviews:

- `max_response_bytes=None` removed the last backstop silently. Spec
  §Response Size Bounds (8) asks that calls made without a bound be logged;
  it now says so once per agent.
- `f"Got content: {result.content}"` put up to a whole budget of unhygienated
  server text into `TaskResult.error`, which in an agentic buyer goes
  straight into a model context — the leak class point 7 forbids, one branch
  from where this PR gets it right. Bounded to 512 characters.
- `ADCPResponseTooLargeError`'s docstring promised the body was never
  buffered, which stopped being true of every path.
- Tests for the astral-plane case that makes `limit // 4` exactly tight, a
  lone surrogate (which would crash the guard without `surrogatepass`), the
  equality boundary, and `structuredContent` winning over an over-budget
  text item.
- The CHANGELOG now states that two public functions raise where they used
  to return `None`.

Refs #1503, adcontextprotocol/adcp#8200

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>

---------

Co-authored-by: Claude Opus 5 (1M context) <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant