{"record":{"id":"3a6f568f3442b408","repo":"zeroclaw-labs/zeroclaw","slug":"failed-to-parse-ollama-response-e","errorCode":null,"errorMessage":"Failed to parse Ollama response: {e}","messagePattern":"Failed to parse Ollama response: (.+?)","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/zeroclaw-providers/src/ollama.rs","lineNumber":760,"sourceCode":"                sanitized\n            );\n        }\n\n        let chat_response: ApiChatResponse = match serde_json::from_slice(&body) {\n            Ok(r) => r,\n            Err(e) => {\n                let raw = String::from_utf8_lossy(&body);\n                let sanitized = super::sanitize_api_error(&raw);\n                ::zeroclaw_log::record!(\n                    ERROR,\n                    ::zeroclaw_log::Event::new(module_path!(), ::zeroclaw_log::Action::Fail)\n                        .with_outcome(::zeroclaw_log::EventOutcome::Failure),\n                    &format!(\n                        \"Ollama response deserialization failed: {e}. body_excerpt={}\",\n                        sanitized\n                    )\n                );\n                anyhow::bail!(\"Failed to parse Ollama response: {e}\");\n            }\n        };\n\n        Ok(chat_response)\n    }\n\n    async fn send_request(\n        &self,\n        messages: Vec<Message>,\n        model: &str,\n        temperature: Option<f64>,\n        should_auth: bool,\n        tools: Option<&[serde_json::Value]>,\n    ) -> anyhow::Result<ApiChatResponse> {\n        let result = self\n            .send_request_inner(\n                &messages,\n                model,","sourceCodeStart":742,"sourceCodeEnd":778,"githubUrl":"https://github.com/zeroclaw-labs/zeroclaw/blob/88bb9c8533fc57ed7a03e36ca7c9ed2bf8336dcc/crates/zeroclaw-providers/src/ollama.rs#L742-L778","documentation":"Ollama returned a 2xx response, but the body failed to deserialize into the ChatResponse shape the provider expects (send_request_inner). The preceding WARN log records the deserialization error plus a body_excerpt, so the exact offending payload is recoverable from logs. This is schema drift between what Ollama returned and what this ZeroClaw build parses.","triggerScenarios":"An Ollama upgrade adds/renames fields the parser treats as required; a reverse proxy in front of Ollama rewrites the JSON or substitutes a 200 HTML page; base_url targets a non-Ollama server whose /api/chat response shape differs.","commonSituations":"Upgrading Ollama ahead of the ZeroClaw version's schema (or vice versa); routing Ollama through a gateway that mangles bodies; pointing base_url at an OpenAI-compat shim that answers /api/chat with the wrong shape.","solutions":["Pull the WARN log line 'Ollama response deserialization failed: ... body_excerpt=...' and inspect the actual payload.","Align versions: upgrade ZeroClaw to the release matching your Ollama version, or pin Ollama to the version the provider was built against.","Remove intermediaries so the provider talks directly to Ollama's /api/chat.","Confirm base_url is the Ollama native API root (e.g. http://localhost:11434), not an OpenAI-compatible /v1 endpoint."],"exampleFix":"# before — OpenAI-compat shim behind the same port; wrong response shape\n[providers.models.ollama.local]\nbase_url = \"http://localhost:11434/v1\"\n\n# after — native Ollama API root\n[providers.models.ollama.local]\nbase_url = \"http://localhost:11434\"","handlingStrategy":"try-catch","validationCode":"# Smoke-test the wire shape before starting long jobs\ncurl -s http://localhost:11434/api/chat -d '{\"model\":\"llama3\",\"messages\":[{\"role\":\"user\",\"content\":\"ping\"}],\"stream\":false}' | jq -e '.message.content' >/dev/null && echo shape-ok","typeGuard":null,"tryCatchPattern":"Catch the parse failure, then read the paired WARN log ('Ollama response deserialization failed: ... body_excerpt=...') to see the exact payload. Fix the shape mismatch (version drift, proxy, wrong base_url) instead of retrying — the response will fail identically.","preventionTips":["Pin the Ollama version in dev and CI","Keep base_url pointed directly at Ollama; no reverse proxy on /api/chat","Run a one-message smoke chat after upgrading either Ollama or ZeroClaw"],"tags":["ollama","json","deserialization","llm-provider","schema-drift"],"backgroundTag":"json-deserialization-failed","analyzedSha":"88bb9c8533fc57ed7a03e36ca7c9ed2bf8336dcc","analyzedAt":"2026-08-23T01:07:41.857Z","schemaVersion":2},"datasetVersion":"2026-08-23T08:06:27.607Z"}