{"record":{"id":"c629dee10e9e206f","repo":"continuedev/continue","slug":"j-error","errorCode":null,"errorMessage":"j.error","messagePattern":"j\\.error","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"core/llm/llms/Ollama.ts","lineNumber":451,"sourceCode":"      body: JSON.stringify(this._getGenerateOptions(options, prompt)),\n      signal,\n    });\n\n    let buffer = \"\";\n    for await (const value of streamResponse(response)) {\n      // Append the received chunk to the buffer\n      buffer += value;\n      // Split the buffer into individual JSON chunks\n      const chunks = buffer.split(\"\\n\");\n      buffer = chunks.pop() ?? \"\";\n\n      for (let i = 0; i < chunks.length; i++) {\n        const chunk = chunks[i];\n        if (chunk.trim() !== \"\") {\n          try {\n            const j = JSON.parse(chunk) as OllamaRawResponse;\n            if (\"error\" in j) {\n              throw new Error(j.error);\n            }\n            j.response ??= \"\";\n            yield j.response;\n          } catch (e) {\n            throw new Error(`Error parsing Ollama response: ${e} ${chunk}`);\n          }\n        }\n      }\n    }\n  }\n\n  /**\n   * Reorder messages so that system messages never appear directly after tool\n   * messages. Some Ollama models (Mistral, Ministral) reject the sequence\n   * `tool → system` with \"Unexpected role 'system' after role 'tool'\".\n   * This moves such system messages to just before the preceding\n   * assistant+tool block.\n   */","sourceCodeStart":433,"sourceCodeEnd":469,"githubUrl":"https://github.com/continuedev/continue/blob/5522c6f44ca0ac3528b37244818fbfa39b5af470/core/llm/llms/Ollama.ts#L433-L469","documentation":"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.","triggerScenarios":"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.","commonSituations":"Config references a model tag not yet pulled (ollama pull), server has insufficient VRAM/RAM, or parameter mismatch after upgrading Ollama.","solutions":["The message contains Ollama's own error text — 'model not found' means run ollama pull <model>","For OOM, use a smaller/quantized model or free GPU memory","Restart the Ollama server and retry; check ollama logs for details"],"exampleFix":"# before\nollama serve   # model not pulled\n# after\nollama pull llama3.1:8b && ollama serve","handlingStrategy":"try-catch","validationCode":"const installed = await Ollama.listModels();\nif (!installed.includes(modelName)) await Ollama.installModel(modelName, signal);","typeGuard":"function isOllamaInlineError(e: unknown): boolean {\n  return e instanceof Error && /model .* not found|out of memory|Error parsing Ollama/i.test(e.message);\n}","tryCatchPattern":"try { for await (const c of llm.streamComplete(prompt, signal)) yield c; }\ncatch (e) { if (isOllamaInlineError(e)) suggestModelPull(); else throw e; }","preventionTips":["Pre-pull models before starting the editor","Check ollama server logs when streams die mid-generation"],"tags":["ollama","streaming","model-not-found","inline-error"],"backgroundTag":"llm-provider-stream-error","analyzedSha":"5522c6f44ca0ac3528b37244818fbfa39b5af470","analyzedAt":"2026-08-27T11:28:54.683Z","schemaVersion":2},"datasetVersion":"2026-08-27T13:17:12.746Z"}