{"record":{"id":"09cab25d4f0f9dc2","repo":"continuedev/continue","slug":"res-error","errorCode":null,"errorMessage":"res.error","messagePattern":"res\\.error","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"core/llm/llms/Ollama.ts","lineNumber":541,"sourceCode":"    }\n    const headers: Record<string, string> = {\n      \"Content-Type\": \"application/json\",\n    };\n\n    if (this.apiKey) {\n      headers.Authorization = `Bearer ${this.apiKey}`;\n    }\n    const response = await this.fetch(this.getEndpoint(\"api/chat\"), {\n      method: \"POST\",\n      headers: headers,\n      body: JSON.stringify(chatOptions),\n      signal,\n    });\n    let isThinking: boolean = false;\n\n    function convertChatMessage(res: OllamaChatResponse): ChatMessage[] {\n      if (\"error\" in res) {\n        throw new Error(res.error);\n      }\n\n      if (\"type\" in res) {\n        const { content } = res;\n\n        if (content === \"<think>\") {\n          isThinking = true;\n        }\n\n        if (isThinking && content) {\n          // TODO better support for streaming thinking chunks, or remove this and depend on redux <think/> parsing logic\n          const thinkingMessage: ThinkingChatMessage = {\n            role: \"thinking\",\n            content: content,\n          };\n\n          if (thinkingMessage) {\n            // could cause issues with termination if chunk doesn't match this exactly","sourceCodeStart":523,"sourceCodeEnd":559,"githubUrl":"https://github.com/continuedev/continue/blob/5522c6f44ca0ac3528b37244818fbfa39b5af470/core/llm/llms/Ollama.ts#L523-L559","documentation":"Thrown by the convertChatMessage helper inside Ollama._streamChat when a streamed /api/chat JSON object contains an \"error\" field. Like the generate path, Ollama reports chat errors inline in the stream rather than via HTTP status codes.","triggerScenarios":"Chat streaming with a model that fails to load, an invalid model name, or unsupported request options in the /api/chat payload — Ollama emits {\"error\":\"...\"} as the first stream line.","commonSituations":"Switching models in config without pulling them, Ollama upgraded with breaking option changes, or GPU OOM when loading a large chat model.","solutions":["Use the message text to identify the underlying cause; typically 'model ... not found' → ollama pull <model>","For load failures, reduce model size or check VRAM with nvidia-smi","Check `journalctl`/terminal output of ollama serve for the server-side error"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"const ok = await fetch(`${ollamaHost}/api/tags`).then(r => r.ok);\nif (ok) { const names = await Ollama.listModels(); if (!names.includes(model)) await Ollama.installModel(model, signal); }","typeGuard":"function isOllamaChatInlineError(e: unknown): boolean { return e instanceof Error && /model .* not found|Error parsing Ollama/i.test(e.message); }","tryCatchPattern":"try { for await (const m of llm.streamChat(messages, signal)) handle(m); }\ncatch (e) { if (isOllamaChatInlineError(e)) showModelHint(); else throw e; }","preventionTips":["Ensure chat models are pulled before streaming","Monitor VRAM when loading large models"],"tags":["ollama","chat","streaming","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"}