continuedev/continue · error · Error

j.error

Error message

j.error

What it means

Thrown in Ollama._streamComplete when a streamed JSON line from /api/generate contains an "error" field. Ollama reports per-request errors inline in the stream (e.g. model not found, out of memory) rather than via HTTP status, so this surfaces mid-generation.

Source

Thrown at core/llm/llms/Ollama.ts:451

      body: JSON.stringify(this._getGenerateOptions(options, prompt)),
      signal,
    });

    let buffer = "";
    for await (const value of streamResponse(response)) {
      // Append the received chunk to the buffer
      buffer += value;
      // Split the buffer into individual JSON chunks
      const chunks = buffer.split("\n");
      buffer = chunks.pop() ?? "";

      for (let i = 0; i < chunks.length; i++) {
        const chunk = chunks[i];
        if (chunk.trim() !== "") {
          try {
            const j = JSON.parse(chunk) as OllamaRawResponse;
            if ("error" in j) {
              throw new Error(j.error);
            }
            j.response ??= "";
            yield j.response;
          } catch (e) {
            throw new Error(`Error parsing Ollama response: ${e} ${chunk}`);
          }
        }
      }
    }
  }

  /**
   * Reorder messages so that system messages never appear directly after tool
   * messages. Some Ollama models (Mistral, Ministral) reject the sequence
   * `tool → system` with "Unexpected role 'system' after role 'tool'".
   * This moves such system messages to just before the preceding
   * assistant+tool block.
   */

View on GitHub (pinned to 5522c6f44c)

Solutions

  1. The message contains Ollama's own error text — 'model not found' means run ollama pull <model>
  2. For OOM, use a smaller/quantized model or free GPU memory
  3. Restart the Ollama server and retry; check ollama logs for details

Example fix

# before
ollama serve   # model not pulled
# after
ollama pull llama3.1:8b && ollama serve
Defensive patterns

Strategy: try-catch

Validate before calling

const installed = await Ollama.listModels();
if (!installed.includes(modelName)) await Ollama.installModel(modelName, signal);

Type guard

function isOllamaInlineError(e: unknown): boolean {
  return e instanceof Error && /model .* not found|out of memory|Error parsing Ollama/i.test(e.message);
}

Try / catch

try { for await (const c of llm.streamComplete(prompt, signal)) yield c; }
catch (e) { if (isOllamaInlineError(e)) suggestModelPull(); else throw e; }

Prevention

When it happens

Trigger: Streaming a completion from Ollama where the server emits {"error":"..."}: pulling a model that doesn't exist locally, model load OOM, or the Ollama version rejecting request parameters.

Common situations: Config references a model tag not yet pulled (ollama pull), server has insufficient VRAM/RAM, or parameter mismatch after upgrading Ollama.

Related errors


AI-assisted analysis of continuedev/continue@5522c6f44c (2026-08-27). Data as JSON: /api/errors/c629dee10e9e206f. Report an issue: GitHub.