different-ai/openwork · warning · SafeProbeFailure
response_too_large
response_too_large
Error message
response_too_large
What it means
readBoundedBody in the cloud probe enforces a response-size budget. Before reading the stream, it checks the declared content-length header; if it exceeds budget.remaining, the body is cancelled and a SafeProbeFailure('response_too_large') is thrown. SafeProbeFailure is a controlled probe failure, not a crash — the probe reports it safely.
Source
Thrown at apps/server/src/agent-context-cloud-probe.ts:446
async function cancelBody(response: Response, deadline?: ProbeDeadline): Promise<void> {
try {
const cancellation = response.body?.cancel();
if (cancellation) await (deadline ? deadline.race(cancellation) : cancellation);
} catch {
// Cancellation is best effort and its error is never reported.
}
}
async function readBoundedBody(
response: Response,
deadline: ProbeDeadline,
budget: ProbeResponseBudget,
): Promise<string> {
const declared = Number(response.headers.get("content-length"));
if (Number.isFinite(declared) && declared > budget.remaining) {
await cancelBody(response, deadline);
throw new SafeProbeFailure("response_too_large");
}
const reader = response.body?.getReader();
if (!reader) return "";
const chunks: Uint8Array[] = [];
let size = 0;
try {
while (true) {
const next = await deadline.race(reader.read());
if (next.done) break;
size += next.value.byteLength;
if (next.value.byteLength > budget.remaining) {
await deadline.race(reader.cancel());
throw new SafeProbeFailure("response_too_large");
}
budget.remaining -= next.value.byteLength;
chunks.push(next.value);
}
} catch (error) {View on GitHub (pinned to 2b7df46e8a)
Solutions
- Point the probe at the correct (small) health/context endpoint.
- Raise the probe's response budget if larger responses are legitimately expected.
- Server-side: cap the endpoint's response size.
Example fix
// before
if (Number.isFinite(declared) && declared > budget.remaining) {
await cancelBody(response, deadline);
throw new SafeProbeFailure("response_too_large");
}
// after — log declared size for diagnosis
if (Number.isFinite(declared) && declared > budget.remaining) {
recordInspectorEvent("probe.response_too_large", { declared });
throw new SafeProbeFailure("response_too_large");
} Defensive patterns
Strategy: fallback
Validate before calling
const len = Number(response.headers.get("content-length"));
if (Number.isFinite(len) && len > MAX_BYTES) {
console.warn("Skipping probe: response too large", len);
return null;
} Type guard
function hasAcceptableLength(response: Response, max: number): boolean {
const declared = Number(response.headers.get("content-length"));
return !(Number.isFinite(declared) && declared > max);
} Try / catch
try {
const body = await readBoundedBody(response, deadline, budget);
} catch (error) {
if (error instanceof SafeProbeFailure && error.code === "response_too_large") {
return null; // probe result: too large, non-fatal
}
throw error;
} Prevention
- Probe small, bounded health/context endpoints only.
- Check content-length before reading when present.
- Set explicit response budgets per probe target.
- Treat size failures as probe findings, not app errors.
When it happens
Trigger: Probing a cloud agent-context endpoint whose response declares a content-length larger than the remaining response budget (ProbeResponseBudget.remaining).
Common situations: Endpoint returns a very large JSON/HTML document (e.g., an error page with huge payload or an unexpectedly verbose API response); misconfigured probe URL pointing at a bulk/download endpoint.
Related errors
- The MCP discovery response exceeded the 1 MiB limit.
- request_failed
- Failed to fetch latest-mac.yml (${response.status} ${respons
- invalid_utf8
- invalid_json
AI-assisted analysis of different-ai/openwork@2b7df46e8a (2026-09-01).
Data as JSON: /api/errors/fdb1eaee6faccc1c.
Report an issue: GitHub.