Skip to content

fix: Ollama with gemma4 can't see tool functions - #4

Open
futurelink wants to merge 1 commit into
iron-cage:masterfrom
futurelink:fix/ollama_tool_functions
Open

fix: Ollama with gemma4 can't see tool functions#4
futurelink wants to merge 1 commit into
iron-cage:masterfrom
futurelink:fix/ollama_tool_functions

Conversation

@futurelink

@futurelink futurelink commented Jul 20, 2026

Copy link
Copy Markdown

Ollama with gemma4 can't see tool functions passed to a chat request.

[2026-07-20T10:34:53Z INFO  ollama_agent] Using model 'gemma4:26b'

Request: Object {"messages": Array [Object {"content": String("You are careful assistant. \n* If you have not tool or function to make an operation do not guess.\n* If you have no access to a data requested - do not guess, say 'I have no access to that data'."), "role": String("system")}, Object {"content": String("Hello! What is in a tools section of this message?"), "role": String("user")}], "model": String("gemma4:26b"), "options": Object {"temperature": Number(0.0)}, "stream": Bool(false), "tools": Array [Object {"description": String("Run some Python code"), "name": String("run_python_code"), "parameters": Object {"code": String("string")}}, Object {"description": String("Get a list of files in a specific directory"), "name": String("list_files"), "parameters": Object {"properties": Object {"path": Object {"description": String("A path to list"), "type": String("string")}}, "required": Array [String("path")], "type": String("object")}}]}

Response: ChatResponse { message: ChatMessage { role: Assistant, content: "In the tools section of this message, there are two empty function declarations (`declaration`) that do not contain any specific names or descriptions.", images: None, tool_calls: None }, done: true, done_reason: Some("stop"), model: Some("gemma4:26b"), created_at: Some("2026-07-20T10:35:04.535421198Z"), total_duration: Some(10754068384), load_duration: Some(8323087277), prompt_eval_count: Some(95), prompt_eval_duration: Some(141105000), eval_count: Some(294), eval_duration: Some(2287956000) }

Solution: wrap ToolDefinition into standard 'function' object. After making the change a response was:

esponse: ChatResponse { message: ChatMessage { role: Assistant, content: "The \"tools section\" of this message contains definitions for two specific functions that I can use to perform tasks:\n\n1.  **`run_python_code`**: This tool allows me to execute Python code to perform calculations, process data, or solve complex problems.\n2.  **`list_files`**: This tool allows me to view the contents of a specific directory by providing a file path.", images: None, tool_calls: None }, done: true, done_reason: Some("stop"), model: Some("gemma4:26b"), created_at: Some("2026-07-20T10:37:58.23567988Z"), total_duration: Some(2470828054), load_duration: Some(253039555), prompt_eval_count: Some(151), prompt_eval_duration: Some(77845000), eval_count: Some(286), eval_duration: Some(2062304000) }

…uest.

Solution: wrap ToolDefinition into standard 'function' object.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant