Skip to content

fix(compliance): bound agent response size during hosted compliance runs - #8187

Merged
bokelley merged 1 commit into
mainfrom
bokelley/compliance-response-cap
Oct 14, 2026
Merged

bokelley merged 1 commit into
mainfrom
bokelley/compliance-response-cap

Conversation

@bokelley

@bokelley bokelley commented Oct 14, 2026 •

Copy link
Copy Markdown
Contributor

Problem

Hosted compliance calls untrusted agents with no response-size limit. On 2026-10-13, one seller answered a get_products refine request (media_buy_seller/refine_products) with a 17.8 MB body containing 26,163 proposals for 7 products. While the SDK processed it, the worker's RSS went past 10 GB, and the kernel OOM-killed it (exit_code=137, oom_killed=true).

The heartbeat claims its whole batch before running it, so each crash also dropped every other agent in the batch. Six agents went 7–9 days without a recorded run. #8188 fixes that claim-recovery gap separately.

Fix

Every hosted compliance SDK call in compliance-testing.ts now goes through withHostedComplianceTransport. The helper sets transport.maxResponseBytes to 4 MiB unless the caller already set a bound, which matches the cap capabilities.ts uses for discovery. An oversized reply now fails that agent's step; the worker keeps running.

Evidence

I ran the hosted comply() path locally against the same agent, single storyboard, and measured peak RSS with /usr/bin/time -l:

Configuration Peak RSS
no bound (two runs) 10.5 GB, 10.9 GB
--no-maglev, no bound 1.6 GB
4 MiB bound 1.6 GB; storyboard graded partial

The growth is native memory, not JS heap: the heap stayed under about 900 MB. Native stack samples are dominated by V8 Maglev compilation and deopt work while the response is processed. Underneath that is a Maglev memory pathology, which this PR does not fix. Bounding untrusted input is the right control either way.

Tests

  • Unit: comply() hands the SDK the bound for the run and for its capability pre-discovery, and a caller-supplied bound is kept. I checked that the test fails when the default is removed.

🤖 Generated with Claude Code

Hosted compliance calls untrusted agents with no response size limit.
On 2026-10-13 one seller answered a get_products refine request with a
17.8 MB body (26,163 proposals). Processing it pushed the worker past
10 GB RSS and the kernel OOM-killed it. Because the heartbeat claims a
batch before running it, every agent in that batch lost its run, and the
cycle repeated on each re-claim.

All hosted compliance SDK calls now go through one helper that sets
transport.maxResponseBytes to 4 MiB unless the caller set a bound. That
matches the cap capability discovery already uses. An oversized reply
now fails that agent's step instead of the worker. Reproduced locally
against the same agent: peak RSS 10.5-10.9 GB without the bound,
1.6 GB with it.

Co-Authored-By: Claude Opus 5.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 — bounds hosted compliance SDK responses to 4 MiB at all five hosted SDK call sites to fix the reported 17.8 MB OOM incident.

Checked: caller-supplied bounds preserved, deadline/timeout signals present, fetch-boundary enforcement, and changeset scope (server-only operational path, not protocol surface — no changeset required). Clean, empirically validated fix.

Medium findings (non-blocking):

  • server/src/addie/services/compliance-testing.ts:74 — Response cap relies on SDK maxResponseBytes, which excludes SSE tool responses; comply() requests text/event-stream, leaving an SSE-delivered oversized reply able to OOM the heartbeat worker.

Decision rationale: No critical/high findings (row 1 n/a). gated_paths is false (row 2 n/a). high_risk is true but the only reason is a (modified) file — row 5 requires a medium finding on the modified file AND it fires only together; row 5 does apply here: high_risk=true + (modified) + a medium finding. Re-checking: row 5 condition is met.

Medium findings

  • server/src/addie/services/compliance-testing.ts:74 — Response cap relies on SDK maxResponseBytes, which excludes SSE tool responses

Copy link
Copy Markdown
Contributor Author

Note on the cap's coverage: this passes the SDK's maxResponseBytes, which in @adcp/sdk skips Content-Type: text/event-stream responses entirely. An agent that replies over SSE with one large event bypasses the 4 MiB cap and can still exhaust worker memory. The agent behind the observed OOMs replied with plain JSON, so this PR does fix that incident.

The real fix belongs in the SDK: adcontextprotocol/adcp-client#3253. Cross-SDK default and spec wording: #8190.

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