Mintplex-Labs/anything-llm · error · Error

LLM processing failed

Error message

LLM processing failed: ${error.message}

What it means

The catch wrapper in executeLLMInstruction: the configured LLM provider's complete() call threw, and the error is re-raised prefixed 'LLM processing failed: <message>'. The underlying message is the real diagnosis — invalid API key, unknown model, context-length exceeded, timeout, or an unreachable local endpoint — and it is also written via logger before the throw.

Solutions

  1. Read the suffix after 'LLM processing failed:' — 401 means bad key, 404 model not found, 429 quota/rate, ECONNREFUSED means the endpoint is unreachable.
  2. Open the same workspace model in regular chat to confirm the provider works outside the flow.
  3. Shrink the input (shorter variables, shorter instruction) if the error mentions context length/tokens.
  4. For local models, make sure the provider base URL is reachable from the AnythingLLM process/container.
Defensive patterns

Strategy: retry

Validate before calling

async function llmProviderHealthy(workspace) {
  try {
    const provider = await getWorkspaceProvider(workspace);
    const r = await provider.complete([{ role: "user", content: "ping" }]);
    return Boolean(r.textResponse);
  } catch {
    return false;
  }
}

Try / catch

async function llmStepWithRetry(exec, attempts = 3) {
  for (let i = 0; i < attempts; i++) {
    try {
      return await exec();
    } catch (e) {
      if (!e.message.startsWith("LLM processing failed:" ) || i === attempts - 1) throw e;
      const cause = e.message.split("LLM processing failed:")[1];
      if (/401|403|model|context|token/i.test(cause)) throw e; // not transient
      await new Promise((r) => setTimeout(r, 2 ** i * 1000));
    }
  }
}

Prevention

When it happens

Trigger: An Agent Flow LLM Instruction block executing when the workspace's selected LLM provider fails: missing/expired provider API key, model name not available to the account, prompt plus input exceeding the model's context window, local LLM server (ollama/lmstudio) down, or provider timeout/overload (429/5xx).

Common situations: Workspace LLM key rotated but not updated; using a model string the provider renamed or deprecated; large scraped/variable content stuffed into the prompt blowing the token limit; AnythingLLM Docker container cannot reach a localhost LLM running on the host; free-tier quota exhausted mid-flow.

Related errors


AI-assisted analysis of Mintplex-Labs/anything-llm@3aec848f28 (2026-08-18). Data as JSON: /api/errors/b9aab4f8592b8254. Report an issue: GitHub.

Appendix: source

Thrown at server/utils/agentFlows/executors/llm-instruction.js:43

    let completion;
    const provider = aibitat.getProviderForConfig(aibitat.defaultProvider);
    if (provider.supportsAgentStreaming) {
      completion = await provider.stream(
        [{ role: "user", content: input }],
        [],
        null
      );
    } else {
      completion = await provider.complete([{ role: "user", content: input }]);
    }

    introspect(`Successfully received LLM response`);
    if (resultVariable) config.resultVariable = resultVariable;
    return completion.textResponse;
  } catch (error) {
    logger(`LLM processing failed: ${error.message}`, error);
    throw new Error(`LLM processing failed: ${error.message}`);
  }
}

module.exports = executeLLMInstruction;

View on GitHub (pinned to 3aec848f28)