From 17afd5a59dd507212836403c8482f1a4599b74e3 Mon Sep 17 00:00:00 2001 From: 1bcMax Date: Thu, 25 Jun 2026 22:47:53 -0700 Subject: [PATCH] fix(timeout): wire 600s default into OpenAI + Anthropic compat wrappers Follow-up to #6, which added the env-configurable 600s DEFAULT_TIMEOUT but only wired it into the native LLMClient path. The OpenAI/Anthropic drop-in wrappers hardcoded 60000ms (openai-compat passed truthy 60000 into LLMClient; anthropic-compat used it directly), so README drop-in users still timed out at 60s on reasoning calls. Export DEFAULT_TIMEOUT from client.ts; both wrappers now fall through to it. Fix stale default:60000 doc comments. --- src/anthropic-compat.ts | 3 ++- src/client.ts | 2 +- src/openai-compat.ts | 4 ++-- src/types.ts | 6 +++--- 4 files changed, 8 insertions(+), 7 deletions(-) diff --git a/src/anthropic-compat.ts b/src/anthropic-compat.ts index 8858520..1f4703b 100644 --- a/src/anthropic-compat.ts +++ b/src/anthropic-compat.ts @@ -7,6 +7,7 @@ import { } from './x402.js'; import { getOrCreateWallet } from './wallet.js'; import { validatePrivateKey, validateApiUrl, validateResourceUrl } from './validation.js'; +import { DEFAULT_TIMEOUT } from './client.js'; // ====================================================================== // Types @@ -41,7 +42,7 @@ export class AnthropicClient { const apiUrl = options.apiUrl ?? 'https://blockrun.ai/api'; validateApiUrl(apiUrl); this._apiUrl = apiUrl.replace(/\/$/, ''); - this._timeout = options.timeout ?? 60000; + this._timeout = options.timeout ?? DEFAULT_TIMEOUT; } private async _getClient(): Promise { diff --git a/src/client.ts b/src/client.ts index eeed322..027ead1 100644 --- a/src/client.ts +++ b/src/client.ts @@ -163,7 +163,7 @@ function resolveDefaultTimeout(): number { return 600_000; // 600s } -const DEFAULT_TIMEOUT = resolveDefaultTimeout(); +export const DEFAULT_TIMEOUT = resolveDefaultTimeout(); // SDK version for User-Agent header (client identification in server logs) const SDK_VERSION = "1.5.0"; diff --git a/src/openai-compat.ts b/src/openai-compat.ts index f7a4537..4b99a05 100644 --- a/src/openai-compat.ts +++ b/src/openai-compat.ts @@ -19,7 +19,7 @@ * }); */ -import { LLMClient } from "./client"; +import { LLMClient, DEFAULT_TIMEOUT } from "./client"; import type { ChatMessage, ChatResponse, ResponseFormat, Tool, ToolCall, ToolChoice } from "./types"; // OpenAI-compatible types @@ -272,7 +272,7 @@ export class OpenAI { constructor(options: OpenAIClientOptions = {}) { const privateKey = options.walletKey || options.privateKey; const apiUrl = options.baseURL || "https://blockrun.ai/api"; - const timeout = options.timeout || 60000; + const timeout = options.timeout ?? DEFAULT_TIMEOUT; this.client = new LLMClient({ privateKey: privateKey as `0x${string}`, diff --git a/src/types.ts b/src/types.ts index e3482c9..663fe51 100644 --- a/src/types.ts +++ b/src/types.ts @@ -287,7 +287,7 @@ export interface LLMClientOptions { privateKey?: `0x${string}` | string; /** API endpoint URL (default: https://blockrun.ai/api) */ apiUrl?: string; - /** Request timeout in milliseconds (default: 60000) */ + /** Request timeout in milliseconds (default: 600000 / 600s; override via BLOCKRUN_CHAT_TIMEOUT env, in seconds) */ timeout?: number; } @@ -953,7 +953,7 @@ export interface PhoneClientOptions { privateKey?: `0x${string}` | string; /** API endpoint URL (default: https://blockrun.ai/api) */ apiUrl?: string; - /** Request timeout in milliseconds (default: 60000) */ + /** Request timeout in milliseconds (default: 600000 / 600s; override via BLOCKRUN_CHAT_TIMEOUT env, in seconds) */ timeout?: number; } @@ -1032,7 +1032,7 @@ export interface PortraitClientOptions { privateKey?: `0x${string}` | string; /** API endpoint URL (default: https://blockrun.ai/api) */ apiUrl?: string; - /** Request timeout in milliseconds (default: 60000) */ + /** Request timeout in milliseconds (default: 600000 / 600s; override via BLOCKRUN_CHAT_TIMEOUT env, in seconds) */ timeout?: number; }