{"record":{"id":"3902de8a7e4878f9","repo":"ruvnet/ruflo","slug":"ollama-response-status","errorCode":"OLLAMA_${response.status}","errorMessage":"${message}","messagePattern":"\\$\\{message\\}","errorType":"exception","errorClass":"LLMProviderError","httpStatus":null,"severity":"error","filePath":"v3/@claude-flow/providers/src/ollama-provider.ts","lineNumber":399,"sourceCode":"    const errorText = await response.text();\n    let errorData: { error?: string };\n\n    try {\n      errorData = JSON.parse(errorText);\n    } catch {\n      errorData = { error: errorText };\n    }\n\n    const message = errorData.error || 'Unknown error';\n\n    if (response.status === 0 || message.includes('connection')) {\n      throw new ProviderUnavailableError('ollama', {\n        message,\n        hint: 'Ensure Ollama is running: ollama serve',\n      });\n    }\n\n    throw new LLMProviderError(\n      message,\n      `OLLAMA_${response.status}`,\n      'ollama',\n      response.status,\n      true,\n      errorData\n    );\n  }\n}\n","sourceCodeStart":381,"sourceCodeEnd":409,"githubUrl":"https://github.com/ruvnet/ruflo/blob/fa13ee4ad60ac2090b1480656eb233521790d640/v3/@claude-flow/providers/src/ollama-provider.ts#L381-L409","documentation":"OllamaProvider's fallback for non-connection errors: LLMProviderError with code OLLAMA_<status>, and unlike the cloud providers it hardcodes retryable=true for every status. The message is Ollama's JSON error field ('Unknown error' if not JSON).","triggerScenarios":"complete() when the requested model tag has not been pulled (404 \"model 'x' not found\"), malformed request bodies (400), or Ollama server errors (500) - any non-connection HTTP response.","commonSituations":"Model tag typo or missing tag ('llama3.1' vs 'llama3.1:8b'); model pulled under a different name on another machine; Ollama version too old for a newer model/feature; corrupted model store.","solutions":["Run `ollama list` and use an exact tag from it, pulling if needed: `ollama pull llama3.1:8b`","Read error.details.error - Ollama's message names the concrete cause (model missing, bad parameter, server error)","For 5xx: retry with backoff; if it persists restart the daemon or upgrade Ollama to a version that supports the model"],"exampleFix":"// before\nconfig: { model: 'llama3.1', apiUrl: 'http://localhost:11434' } // tag not pulled -> OLLAMA_404\n\n// after\n// $ ollama pull llama3.1:8b\nconfig: { model: 'llama3.1:8b', apiUrl: 'http://localhost:11434' } // matches `ollama list` output","handlingStrategy":"try-catch","validationCode":"async function ollamaHasModel(model: string, apiUrl = 'http://localhost:11434'): Promise<boolean> {\n  const r = await fetch(`${apiUrl}/api/tags`);\n  const { models } = await r.json();\n  return (models ?? []).some((m: { name: string }) => m.name === model);\n}","typeGuard":"import { LLMProviderError, isLLMProviderError } from './types.js';\nfunction isOllamaApiError(e: unknown): e is LLMProviderError {\n  return isLLMProviderError(e) && e.provider === 'ollama' && e.code.startsWith('OLLAMA_');\n}","tryCatchPattern":"try {\n  return await provider.complete(req);\n} catch (e) {\n  if (isOllamaApiError(e)) {\n    // note: this mapping marks every status retryable; still inspect it first\n    if (e.statusCode === 404) throw new Error('model not pulled locally: run ollama pull ' + req.model);\n    return retryWithBackoff(() => provider.complete(req));\n  }\n  throw e;\n}","preventionTips":["Verify model tags against `ollama list` (or GET /api/tags) before configuring the provider","Pull required tags as part of environment provisioning (ollama pull in the setup script)","Read e.details.error - Ollama names the exact cause for 400/404/500"],"tags":["http-error","ollama","local-server","model-tag"],"backgroundTag":"http-error-response","analyzedSha":"fa13ee4ad60ac2090b1480656eb233521790d640","analyzedAt":"2026-08-18T21:34:22.708Z","schemaVersion":2},"datasetVersion":"2026-08-30T08:17:16.595Z"}