From f70eea0b42b755c10113eba7f9b6eb27eab54465 Mon Sep 17 00:00:00 2001 From: 1bcMax Date: Thu, 25 Jun 2026 22:30:22 -0700 Subject: [PATCH] fix(timeout): raise default chat timeout to env-configurable 600s Reasoning models (opus-4.8/deepseek-v4-pro) think 200-300s+; old default cut them off. Override via BLOCKRUN_CHAT_TIMEOUT env. Mirrors blockrun-llm 1.4.7. --- src/client.ts | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/src/client.ts b/src/client.ts index 7ee6f19..eeed322 100644 --- a/src/client.ts +++ b/src/client.ts @@ -141,7 +141,29 @@ import { logCost } from "./cost-log"; const DEFAULT_API_URL = "https://blockrun.ai/api"; const DEFAULT_MAX_TOKENS = 1024; -const DEFAULT_TIMEOUT = 60000; + +/** + * Default chat HTTP timeout (milliseconds). Was 60s; reasoning models + * (opus-4.8, deepseek-v4-pro) routinely take 200–300s, so 60s timed out + * non-streaming calls. Override via the BLOCKRUN_CHAT_TIMEOUT env var + * (in SECONDS) or the per-client / per-call `timeout` option (in ms). + * Mirrors blockrun-llm (Python) DEFAULT_CHAT_TIMEOUT. + */ +function resolveDefaultTimeout(): number { + const envVal = + typeof process !== "undefined" && process.env + ? process.env.BLOCKRUN_CHAT_TIMEOUT + : undefined; + if (envVal !== undefined) { + const seconds = Number(envVal); + if (Number.isFinite(seconds) && seconds > 0) { + return seconds * 1000; + } + } + return 600_000; // 600s +} + +const DEFAULT_TIMEOUT = resolveDefaultTimeout(); // SDK version for User-Agent header (client identification in server logs) const SDK_VERSION = "1.5.0";