different-ai/openwork · error · AgentContextDiagnosticsTransportError
agent_context_diagnostics_response_too_large
agent_context_diagnostics_response_too_large
Error message
Agent context diagnostics response exceeded the 1 MiB limit.
What it means
readBoundedResponseText first inspects the declared Content-Length header. If it is a valid integer exceeding AGENT_CONTEXT_DIAGNOSTICS_RESPONSE_MAX_BYTES (1 MiB), it cancels the body and throws responseTooLargeError() without reading anything. This pre-read guard avoids downloading a body known in advance to be too big.
Source
Thrown at apps/app/src/app/lib/agent-context-diagnostics-transport.ts:60
function cancelUnlockedBody(response: Response): void {
if (!response.body || response.body.locked) return;
void response.body.cancel().catch(() => undefined);
}
async function readBoundedResponseText(
response: Response,
signal: AbortSignal,
): Promise<string> {
const declaredLength = response.headers.get("content-length")?.trim() ?? "";
if (/^\d+$/.test(declaredLength)) {
const declaredBytes = Number(declaredLength);
if (
!Number.isSafeInteger(declaredBytes)
|| declaredBytes > AGENT_CONTEXT_DIAGNOSTICS_RESPONSE_MAX_BYTES
) {
cancelUnlockedBody(response);
throw responseTooLargeError();
}
}
if (!response.body) return "";
const reader = response.body.getReader();
const chunks: Uint8Array[] = [];
let bytesRead = 0;
const cancelOnAbort = () => {
void reader.cancel().catch(() => undefined);
};
signal.addEventListener("abort", cancelOnAbort, { once: true });
try {
while (true) {
if (signal.aborted) throw timeoutError();
const chunk = await reader.read();
if (chunk.done) break;View on GitHub (pinned to 2b7df46e8a)
Solutions
- Fix the diagnostics endpoint to cap/truncate its JSON payload to under 1 MiB
- Verify the client URL points at the real agent-context diagnostics endpoint, not another route
- Check for proxies/middleware that inflate the response (error pages, injected content)
- If the payload is legitimately larger, the endpoint must paginate or summarize rather than grow the response
Example fix
// before: endpoint serializes full context return Response.json(fullContext); // after: cap the payload server-side return Response.json(truncateContext(fullContext, 1_000_000));
Defensive patterns
Strategy: try-catch
Validate before calling
const contentLength = Number(response.headers.get("content-length") ?? "");
if (Number.isSafeInteger(contentLength) && contentLength > 1024 * 1024) {
throw new Error("Diagnostics response would exceed the 1 MiB limit");
} Type guard
null
Try / catch
try {
const { payload } = await requestAgentContextDiagnosticsPayload({ fetchImpl, url, init });
} catch (e) {
if (e instanceof AgentContextDiagnosticsTransportError && e.code === "agent_context_diagnostics_response_too_large") {
// endpoint returned >1MiB; request a truncated/paginated payload
} else throw e;
} Prevention
- Cap the diagnostics payload server-side below 1 MiB
- Confirm you are calling the real diagnostics endpoint, not a debug route
- Check status/content-type so error pages aren't mistaken for diagnostics JSON
- Paginate or summarize large context data instead of one big response
When it happens
Trigger: The diagnostics endpoint responds with a Content-Length header whose numeric value is greater than 1048576 bytes — e.g. a server that isn't the bounded diagnostics endpoint or that failed to truncate its payload.
Common situations: Pointing the diagnostics client at a wrong/debug endpoint that returns huge payloads; a server bug that serializes the full agent context unbounded; a proxy injecting large HTML error pages with explicit Content-Length.
Related errors
- request_failed
- Failed to fetch latest-mac.yml (${response.status} ${respons
- response_too_large
- plugin_ref_not_found
- invalid_payload
AI-assisted analysis of different-ai/openwork@2b7df46e8a (2026-09-01).
Data as JSON: /api/errors/8b91521bca7173b5.
Report an issue: GitHub.