{"record":{"id":"54e8a6c28fb028fa","repo":"rohitg00/agentmemory","slug":"openai-api-request-timed-out-after-this-timeoutm","errorCode":null,"errorMessage":"OpenAI API request timed out after ${this.timeoutMs}ms — set OPENAI_TIMEOUT_MS (or AGENTMEMORY_LLM_TIMEOUT_MS) to raise the bound or check the provider status.","messagePattern":"OpenAI API request timed out after (.+?)ms — set OPENAI_TIMEOUT_MS \\(or AGENTMEMORY_LLM_TIMEOUT_MS\\) to raise the bound or check the provider status\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"src/providers/openai.ts","lineNumber":119,"sourceCode":"    // provider (minimax, openrouter, gemini, openrouter-embed, etc.).\n    // OPENAI_TIMEOUT_MS keeps its v0.9.17 meaning (OpenAI-scoped alias,\n    // takes precedence); when unset we fall through to\n    // AGENTMEMORY_LLM_TIMEOUT_MS and finally the 60s default. See #446.\n    let response: Response;\n    try {\n      response = await fetchWithTimeout(\n        url,\n        {\n          method: \"POST\",\n          headers: buildAuthHeaders(this.apiKey, this.isAzure),\n          body: JSON.stringify(body),\n        },\n        this.timeoutMs,\n      );\n    } catch (err) {\n      const aborted = err instanceof Error && err.name === \"AbortError\";\n      if (aborted) {\n        throw new Error(\n          `OpenAI API request timed out after ${this.timeoutMs}ms — set OPENAI_TIMEOUT_MS (or AGENTMEMORY_LLM_TIMEOUT_MS) to raise the bound or check the provider status.`,\n        );\n      }\n      throw err;\n    }\n\n    if (!response.ok) {\n      const text = await response.text();\n      throw new Error(`OpenAI API error (${response.status}): ${text}`);\n    }\n\n    const data = (await response.json()) as {\n      choices?: Array<{\n        message?: { content?: string; reasoning?: string; reasoning_content?: string };\n      }>;\n    };\n    const message = data.choices?.[0]?.message;\n    const content = message?.content;","sourceCodeStart":101,"sourceCodeEnd":137,"githubUrl":"https://github.com/rohitg00/agentmemory/blob/e04ba88819c365c9acf9d6661ea802143e728bd6/src/providers/openai.ts#L101-L137","documentation":"OpenAIProvider.call wraps its fetch with an AbortController timeout of this.timeoutMs. When the request is aborted (err.name === 'AbortError'), it rethrows this descriptive error naming the timeout and the env vars (OPENAI_TIMEOUT_MS or AGENTMEMORY_LLM_TIMEOUT_MS) that raise the bound. It means the OpenAI endpoint did not respond within the configured window — the error message explicitly suggests raising the timeout or checking provider status.","triggerScenarios":"compress() or summarize() calls OpenAIProvider.call(); fetch exceeds timeoutMs (default from OPENAI_TIMEOUT_MS / AGENTMEMORY_LLM_TIMEOUT_MS) and the abort fires; the thrown error's name is exactly 'AbortError'.","commonSituations":"Long reasoning models (o-series, DeepSeek-style compatible endpoints) taking >60s on big prompts; slow corporate proxies; OpenAI incident/degradation; default timeout too low for very large compress jobs; regionally blocked connections that hang instead of failing fast.","solutions":["Set OPENAI_TIMEOUT_MS (or AGENTMEMORY_LLM_TIMEOUT_MS) to a larger value, e.g. 120000","Check OpenAI status page for ongoing incidents","Reduce prompt size / chunk large inputs to shorten response time","Verify network path (proxy/VPN) isn't stalling the connection","Use a fallback provider (createFallbackProvider) so slow OpenAI calls fail over"],"exampleFix":"// before\n# default timeout too small for long reasoning responses\nnpm start\n\n// after\nexport AGENTMEMORY_LLM_TIMEOUT_MS=180000\nnpm start","handlingStrategy":"retry","validationCode":"const timeout = Number(process.env.OPENAI_TIMEOUT_MS ?? process.env.AGENTMEMORY_LLM_TIMEOUT_MS ?? 60000);\nif (!Number.isFinite(timeout) || timeout < 5000) throw new Error('Set OPENAI_TIMEOUT_MS to a sane value');","typeGuard":null,"tryCatchPattern":"try {\n  return await provider.call(prompt);\n} catch (e) {\n  if ((e as Error).message.includes('timed out after')) {\n    return retryWithBackoff(() => provider.call(prompt), 2);\n  }\n  throw e;\n}","preventionTips":["Set OPENAI_TIMEOUT_MS (or AGENTMEMORY_LLM_TIMEOUT_MS) generously for reasoning-heavy models","Prefer fallback providers so a slow OpenAI call doesn't stall the pipeline","Watch OpenAI status during incidents; degrade gracefully instead of blocking","Keep prompts bounded; chunk large transcripts before compress/summarize"],"tags":["network","timeout","openai","abort"],"backgroundTag":"request-timeout","analyzedSha":"e04ba88819c365c9acf9d6661ea802143e728bd6","analyzedAt":"2026-08-30T01:07:40.754Z","schemaVersion":2},"datasetVersion":"2026-08-30T03:17:51.788Z"}