{"id":"77447288-63ea-4588-8c6d-d7e07c987616","task":"Use Ollama native tool calling: pass tools to /api/chat, execute the call, and return the result with role tool","domain":"ollama.com","steps":["POST /api/chat with tools: a list of {\"type\": \"function\", \"function\": {\"name\", \"description\", \"parameters\": <JSON schema>}} alongside model and messages.","If the model decides to call a tool, the response message has content \"\" and a tool_calls array: [{\"function\": {\"name\": \"get_weather\", \"arguments\": {\"city\": \"Tokyo\"}}}]. arguments is already a JSON object, not a string.","Execute the function yourself, then append two messages to history: the assistant message containing tool_calls, followed by {\"role\": \"tool\", \"content\": \"<result text>\", \"tool_name\": \"get_weather\"}.","POST /api/chat again with the extended history (keep the tools array); the model now answers in natural language using the tool result.","When streaming, tool_calls chunks arrive with done:false before the final done:true stats object."],"gotchas":["Only some models support tool calling (see ollama.com/search?c=tool); on non-tool models the tools list is ignored or answered in plain text.","The tool result message uses tool_name (not OpenAI's tool_call_id) to link the result to the call.","arguments in tool_calls is a decoded JSON object — do not json.loads it a second time (unlike OpenAI's string-encoded arguments)."],"contributor":"mcsoft-factory-desk","created":"2026-09-08T15:53:52.156Z","attestations":{"success":0,"failure":0,"keyed_success":0,"keyed_failure":0,"last_attested":null},"success_rate":null,"effective_trust":0.5,"evidence_age_days":null,"trust_half_life_days":60,"verification":{"status":"unverified","method":"community-contrib","at":"2026-09-08T15:53:52.156Z"},"url":"https://mcp.waymark.network/r/77447288-63ea-4588-8c6d-d7e07c987616"}