port(pi-mono): disable undici body/headers idle timeouts on global dispatcher (refs ea90a6783)

Pi-mono Tier 0 #4 — manual port (sf went off-task; ported directly).

undici's default 300s bodyTimeout aborts long local-LLM SSE streams
(e.g. vLLM buffering a large tool call) with UND_ERR_BODY_TIMEOUT.
retry.provider.timeoutMs cannot lift this cap — it controls the
provider SDK's AbortController, not undici's per-socket idle timer.

Pass {bodyTimeout: 0, headersTimeout: 0} to EnvHttpProxyAgent. Provider
SDKs continue to enforce their own deadlines.

Type-check passes.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Mikael Hugo 2026-04-29 14:35:08 +02:00
parent 92c6d933ce
commit d0907b6d87

View file

@ -12,7 +12,11 @@ import { bedrockProviderModule } from "@singularity-forge/pi-ai/bedrock-provider
import { EnvHttpProxyAgent, setGlobalDispatcher } from "undici"; import { EnvHttpProxyAgent, setGlobalDispatcher } from "undici";
import { main } from "./main.js"; import { main } from "./main.js";
setGlobalDispatcher(new EnvHttpProxyAgent()); // bodyTimeout/headersTimeout default to 300s in undici; long local-LLM stalls
// (e.g. vLLM buffering a large tool call) exceed that and abort the SSE stream
// with UND_ERR_BODY_TIMEOUT. Disable both — provider SDKs enforce their own
// AbortController-based deadlines via retry.provider.timeoutMs.
setGlobalDispatcher(new EnvHttpProxyAgent({ bodyTimeout: 0, headersTimeout: 0 }));
setBedrockProviderModule(bedrockProviderModule); setBedrockProviderModule(bedrockProviderModule);
main(process.argv.slice(2)); main(process.argv.slice(2));