Feature Request: Add tool_choice config per model/provider for Ollama tool calling

Resolved 💬 2 comments Opened Feb 3, 2026 by phantomgreen75 Closed Mar 5, 2026

Summary

When using Ollama models (Mistral, Llama) via openai-completions API, tool calling fails because OpenClaw doesn't send the tool_choice parameter.

Problem

  • Ollama's OpenAI-compatible endpoint supports tool calling via /v1/chat/completions
  • When tool_choice: "required" or "auto" is passed, models reliably use tools
  • Without tool_choice, models like Mistral 7B default to generating text instead of calling tools
  • OpenClaw's buildParams() in pi-ai only sends tool_choice when explicitly passed via options
  • Sub-agents don't pass this parameter

Proof

# With tool_choice - WORKS ✅
curl http://localhost:11434/v1/chat/completions -d '{
  "model": "mistral:instruct",
  "tool_choice": "required",
  "tools": [{...}]
}'
# Returns: {"tool_calls": [...]}

# Without tool_choice via OpenClaw - FAILS ❌
# Returns: text explaining how to get weather (hallucination)

Proposed Solution

Add tool_choice config option:

  1. Per-model in models.providers.*.models[].compat.toolChoice
  2. Or per-provider in models.providers.*.compat.toolChoice

Example config:

{
  "models": {
    "providers": {
      "ollama": {
        "models": [{
          "id": "mistral:instruct",
          "compat": {
            "toolChoice": "auto"
          }
        }]
      }
    }
  }
}

Environment

  • OpenClaw version: 2026.2.1
  • Ollama version: latest
  • Models tested: mistral:instruct, llama3.1:8b-instruct-q8_0
  • Hardware: RTX 4090, 128GB RAM

Workaround

Currently using Opus for tool-heavy tasks, local Mistral only for text-only tasks (summarization, code review).

Notes

  • Llama 3.1 8B appears to use tools without tool_choice — may be model-dependent
  • Mistral 7B specifically needs tool_choice to reliably invoke tools

View original on GitHub ↗

This issue has 2 comments on GitHub. Read the full discussion on GitHub ↗