{"record":{"id":"ad8a4374777472c6","repo":"zed-industries/zed","slug":"llama-cpp-does-not-support-custom-tool-calls","errorCode":null,"errorMessage":"llama.cpp does not support custom tool calls","messagePattern":"llama\\.cpp does not support custom tool calls","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/language_models/src/provider/llama_cpp.rs","lineNumber":749,"sourceCode":"                            llama_cpp::MessagePart::Image {\n                                image_url: llama_cpp::ImageUrl {\n                                    url: image.to_base64_url(),\n                                    detail: None,\n                                },\n                            },\n                            message.role,\n                            &mut messages,\n                            if supports_thinking && message.role == Role::Assistant {\n                                reasoning_content.take()\n                            } else {\n                                None\n                            },\n                        );\n                    }\n                }\n                MessageContent::ToolUse(tool_use) => {\n                    let input = tool_use.input.as_json().ok_or_else(|| {\n                        anyhow::anyhow!(\"llama.cpp does not support custom tool calls\")\n                    })?;\n                    let tool_call = llama_cpp::ToolCall {\n                        id: tool_use.id.to_string(),\n                        content: llama_cpp::ToolCallContent::Function {\n                            function: llama_cpp::FunctionContent {\n                                name: tool_use.name.to_string(),\n                                arguments: serde_json::to_string(input).unwrap_or_default(),\n                            },\n                        },\n                    };\n\n                    if let Some(llama_cpp::ChatMessage::Assistant {\n                        tool_calls,\n                        reasoning_content: message_reasoning_content,\n                        ..\n                    }) = messages.last_mut()\n                    {\n                        append_reasoning_content(","sourceCodeStart":731,"sourceCodeEnd":767,"githubUrl":"https://github.com/zed-industries/zed/blob/5a9b9558db01a6b906cec2fb70a797affdc58cdd/crates/language_models/src/provider/llama_cpp.rs#L731-L767","documentation":"Guard in build_llama_cpp_request: a MessageContent::ToolUse carrying custom tool input cannot be expressed in llama.cpp's message schema, so request building fails instead of emitting a tool call the local server would reject.","triggerScenarios":"Thrown at crates/language_models/src/provider/llama_cpp.rs:751 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Disable custom tools for llama.cpp models","Use a llama.cpp model/server variant that supports the needed tool format"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"5a9b9558db01a6b906cec2fb70a797affdc58cdd","analyzedAt":"2026-08-20T19:29:52.058Z","contentChangedAt":"2026-08-20T19:29:52.058Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}