Mintplex-Labs/anything-llm · warning · Error
OMLX:cacheContextWindows - ${res.statusText}
Error message
OMLX:cacheContextWindows - ${res.statusText} What it means
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.
Source
Thrown at server/utils/AiProviders/omlx/index.js:90
try {
// Skip if we already have cached context windows and we're not forcing a refresh
if (Object.keys(OMLXLLM.modelContextWindows).length > 0 && !force) return;
const endpoint = new URL(
parseOMLXBasePath(process.env.OMLX_LLM_BASE_PATH)
);
endpoint.pathname += "/models";
await fetch(endpoint.toString(), {
headers: {
"Content-Type": "application/json",
...(process.env.OMLX_LLM_API_KEY
? { Authorization: `Bearer ${process.env.OMLX_LLM_API_KEY}` }
: {}),
},
})
.then((res) => {
if (!res.ok)
throw new Error(`OMLX:cacheContextWindows - ${res.statusText}`);
return res.json();
})
.then(({ data: models }) => {
models.forEach((model) => {
// A model can omit max_model_len - cache the 16k fallback for it
// so it is not later mistaken for a large-context model.
if (!model?.max_model_len)
return (OMLXLLM.modelContextWindows[model.id] = 16000);
OMLXLLM.modelContextWindows[model.id] = Number(model.max_model_len);
});
})
.catch((e) => {
OMLXLLM.#slog(`Error caching context windows`, e);
return;
});
OMLXLLM.#slog(`Context windows cached for all models!`);
} catch (e) {View on GitHub (pinned to 526360e320)
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.
Example fix
// before
.then((res) => {
if (!res.ok) throw new Error(`OMLX:cacheContextWindows - ${res.statusText}`);
return res.json();
})
// after - include status code for actionable logs
.then((res) => {
if (!res.ok) throw new Error(`OMLX:cacheContextWindows - HTTP ${res.status} ${res.statusText}`);
return res.json();
}) Defensive patterns
Strategy: validation
Validate before calling
const probeOmlxModels = async (basePath, apiKey) => {
const res = await fetch(`${basePath.replace(/\/$/, '')}/v1/models`, {
headers: apiKey ? { Authorization: `Bearer ${apiKey}` } : {},
});
if (!res.ok) throw new Error(`oMLX /models unhealthy: HTTP ${res.status}`);
return res.json();
};
await probeOmlxModels(process.env.OMLX_LLM_BASE_PATH, process.env.OMLX_LLM_API_KEY); Prevention
- 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.
When it happens
Trigger: 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).
Common situations: 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.
Related errors
- Model capabilities for ${this.model} could not be retrieved
- ${e.message}
- No OMLX API Base Path was set.
- OMLX must have a valid model set.
- OpenRouter Failed to embed: ${error}
AI-assisted analysis of Mintplex-Labs/anything-llm@526360e320 (2026-08-13).
Data as JSON: /api/errors/617e88e8d0d0fc7a.
Report an issue: GitHub.