{"record":{"id":"617e88e8d0d0fc7a","repo":"Mintplex-Labs/anything-llm","slug":"omlx-cachecontextwindows-res-statustext","errorCode":null,"errorMessage":"OMLX:cacheContextWindows - ${res.statusText}","messagePattern":"OMLX:cacheContextWindows - (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"warning","filePath":"server/utils/AiProviders/omlx/index.js","lineNumber":90,"sourceCode":"    try {\n      // Skip if we already have cached context windows and we're not forcing a refresh\n      if (Object.keys(OMLXLLM.modelContextWindows).length > 0 && !force) return;\n\n      const endpoint = new URL(\n        parseOMLXBasePath(process.env.OMLX_LLM_BASE_PATH)\n      );\n      endpoint.pathname += \"/models\";\n      await fetch(endpoint.toString(), {\n        headers: {\n          \"Content-Type\": \"application/json\",\n          ...(process.env.OMLX_LLM_API_KEY\n            ? { Authorization: `Bearer ${process.env.OMLX_LLM_API_KEY}` }\n            : {}),\n        },\n      })\n        .then((res) => {\n          if (!res.ok)\n            throw new Error(`OMLX:cacheContextWindows - ${res.statusText}`);\n          return res.json();\n        })\n        .then(({ data: models }) => {\n          models.forEach((model) => {\n            // A model can omit max_model_len - cache the 16k fallback for it\n            // so it is not later mistaken for a large-context model.\n            if (!model?.max_model_len)\n              return (OMLXLLM.modelContextWindows[model.id] = 16000);\n            OMLXLLM.modelContextWindows[model.id] = Number(model.max_model_len);\n          });\n        })\n        .catch((e) => {\n          OMLXLLM.#slog(`Error caching context windows`, e);\n          return;\n        });\n\n      OMLXLLM.#slog(`Context windows cached for all models!`);\n    } catch (e) {","sourceCodeStart":72,"sourceCodeEnd":108,"githubUrl":"https://github.com/Mintplex-Labs/anything-llm/blob/526360e320da9d1b36074be5ed64fe76e5bbfbbd/server/utils/AiProviders/omlx/index.js#L72-L108","documentation":"Thrown inside the static cacheContextWindows fetch chain when the oMLX /v1/models endpoint returns a non-2xx HTTP status (res.statusText). It is immediately caught by the following .catch, which logs 'Error caching context windows' and swallows it — callers never observe this throw; it appears only in server logs. The effect is that modelContextWindows stays empty and promptWindowLimit falls back to defaults.","triggerScenarios":"oMLX /v1/models returns 401 (bad/missing OMLX_LLM_API_KEY), 404 (wrong base path / endpoint moved), 500, or a transient HTTP error during constructor-time cacheContextWindows(true).","commonSituations":"Wrong or expired OMLX_LLM_API_KEY; oMLX server partially up (inference works but /models errors); base path pointing at a non-oMLX server; network blip at startup; oMLX version with a changed /models schema.","solutions":["curl the oMLX /v1/models endpoint with the same API key to see the real status.","Correct OMLX_LLM_BASE_PATH and OMLX_LLM_API_KEY in .env.","Restart the server so cacheContextWindows re-runs after the fix.","Optionally set OMLX_LLM_TOKEN_LIMIT manually so context sizing does not depend on the cache."],"exampleFix":"// before\n.then((res) => {\n  if (!res.ok) throw new Error(`OMLX:cacheContextWindows - ${res.statusText}`);\n  return res.json();\n})\n\n// after - include status code for actionable logs\n.then((res) => {\n  if (!res.ok) throw new Error(`OMLX:cacheContextWindows - HTTP ${res.status} ${res.statusText}`);\n  return res.json();\n})","handlingStrategy":"validation","validationCode":"const probeOmlxModels = async (basePath, apiKey) => {\n  const res = await fetch(`${basePath.replace(/\\/$/, '')}/v1/models`, {\n    headers: apiKey ? { Authorization: `Bearer ${apiKey}` } : {},\n  });\n  if (!res.ok) throw new Error(`oMLX /models unhealthy: HTTP ${res.status}`);\n  return res.json();\n};\nawait probeOmlxModels(process.env.OMLX_LLM_BASE_PATH, process.env.OMLX_LLM_API_KEY);","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Verify OMLX_LLM_BASE_PATH and OMLX_LLM_API_KEY by curling /v1/models at setup.","Restart the server after fixing credentials so cacheContextWindows re-runs.","Set OMLX_LLM_TOKEN_LIMIT manually as a fallback so context sizing is not cache-dependent."],"tags":["omlx","configuration","network","logging"],"backgroundTag":null,"analyzedSha":"526360e320da9d1b36074be5ed64fe76e5bbfbbd","analyzedAt":"2026-08-13T01:45:47.170Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}