different-ai/openwork · error · AgentContextDiagnosticsTransportError
agent_context_diagnostics_request_timed_out
agent_context_diagnostics_request_timed_out
Error message
Agent context diagnostics request timed out.
What it means
readBoundedResponseText checks the AbortSignal before each chunk read of the diagnostics response body. If the signal is already aborted when a read iteration starts, it throws the AgentContextDiagnosticsTransportError with code agent_context_diagnostics_request_timed_out. The overall 30s deadline (AbortController in requestAgentContextDiagnosticsPayload) fires the abort that leads here.
Source
Thrown at apps/app/src/app/lib/agent-context-diagnostics-transport.ts:76
) {
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;
bytesRead += chunk.value.byteLength;
if (bytesRead > AGENT_CONTEXT_DIAGNOSTICS_RESPONSE_MAX_BYTES) {
void reader.cancel().catch(() => undefined);
throw responseTooLargeError();
}
chunks.push(chunk.value);
}
} catch (error) {
if (signal.aborted) throw timeoutError();
throw error;
} finally {
signal.removeEventListener("abort", cancelOnAbort);
reader.releaseLock();
}
const bytes = new Uint8Array(bytesRead);View on GitHub (pinned to 2b7df46e8a)
Solutions
- Investigate why the diagnostics endpoint is slow/stalling (server logs, network)
- Reduce the diagnostics payload size so the body completes within 30s
- Increase the caller-provided timeoutMs within the allowed max of 30000 ms if the endpoint legitimately needs longer
- Retry the request once network/server load has settled
Example fix
null
Defensive patterns
Strategy: try-catch
Validate before calling
null
Type guard
null
Try / catch
try {
const { payload } = await requestAgentContextDiagnosticsPayload({ fetchImpl, url, init });
} catch (e) {
if (e instanceof AgentContextDiagnosticsTransportError && e.code === "agent_context_diagnostics_request_timed_out") {
// retry or show a timeout notice; the server took >30s to finish the body
} else throw e;
} Prevention
- Keep diagnostics endpoints fast; precompute heavy data
- Keep payload small so streaming finishes well inside 30s
- Pass an explicit timeoutMs up to 30000 when the endpoint is known to be slower
- Retry once on the timed_out code before failing the UX
When it happens
Trigger: The diagnostics HTTP response body is being streamed and the 30s timeout (AGENT_CONTEXT_DIAGNOSTICS_REQUEST_TIMEOUT_MS) elapses mid-body; on the next loop iteration signal.aborted is true and the timeout error is thrown before attempting the read.
Common situations: Slow or hanging diagnostics endpoint that starts responding but trickles the body past the deadline; large responses on a slow network; server that sends headers then stalls the body.
Understand the failure class
Background: Request timed out: what client-side request timeouts mean across libraries (Request timed out, TIMED_OUT, APITimeoutError) — this error's family across 39 libraries.
- Timeouts: ETIMEDOUT, deadlines, and hung requests — what actually expires when a request times out.
Related errors
- Request timed out.
- Timed out waiting for server health
- Connection lost
- source_fetch_failed
- MCP_SHUTDOWN_FAILED
AI-assisted analysis of different-ai/openwork@2b7df46e8a (2026-09-01).
Data as JSON: /api/errors/d7b2bc689ded6bda.
Report an issue: GitHub.