Only Qwen3 models have tool usage capabilities with Open Code CLI!
Root Cause: Tool/function calling requires specific model training. Qwen3 family has built-in function calling capabilities, while Mistral Nemo and Granite models lack this training.
Working models:
- ✅ qwen3:8b-16k - TESTED & CONFIRMED working
- ✅ qwen3:8b - Likely works (same family, needs testing)
- ✅ qwen3:4b - Likely works (same family, needs testing)
Non-working models (analysis only):
- ❌ granite3.1-moe:latest - Plans but doesn't execute
- ❌ mistral-nemo:12b-instruct-2407-q4_K_M - Excellent analysis but no file creation
Some Ollama models understand tasks but do not execute file creation commands.
Symptoms:
- Model generates task descriptions/plans
- Model shows understanding of the request
- No actual file is created
- Terminal shows planning output but no action
This is NOT a bug - it's a model capability limitation!
# Check Open Code CLI version
opencode --version
# Verify Ollama is running
curl http://localhost:11434/v1/models
# Check available models
ollama listTry these progressively more explicit prompts:
Test A: Original prompt
opencode
> Create a todo.md file with 3 sample tasksTest B: Explicit mode directive
opencode
> /mode build
> Create a todo.md file with 3 sample tasksTest C: Tool-specific instruction
opencode
> Use the write tool to create a file called todo.md with 3 tasksTest D: Simple file write
opencode
> Write a file called hello.txt with the text "Hello World"Test E: Code generation (sometimes works better)
opencode
> Create a hello.py file that prints "Hello World"Open Code CLI may require specific configuration for agent/tool usage. Check:
# Look for Open Code CLI config
cat ~/.opencode/config.json
# Check if there's a workspace-specific config
cat .opencode/config.jsonTo isolate whether this is an Ollama-specific issue:
# Test with Claude (if you have API key configured)
opencode --model claude-sonnet-4
> Create a todo.md file with 3 sample tasksIf Claude works but Ollama doesn't, this is a local model tool usage issue.
For ANY task requiring file creation or modification, use Qwen3 models:
# Recommended: qwen3:8b-16k (tested and confirmed working)
opencode --model ollama/qwen3:8b-16k
> Create a todo.md file with 3 sample tasks
# ✅ This works!Alternative Qwen3 models (likely also work):
# Standard context (faster than 16k)
opencode --model ollama/qwen3:8b
> Add type hints to utils/helpers.py
# Small/fast variant
opencode --model ollama/qwen3:4b
> Create a simple hello.py fileQwen3 models use this format to call file tools:
{
"name": "write",
"arguments": {
"content": "# Todo List\n\n- Task 1\n- Task 2",
"filePath": "/absolute/path/to/file.md"
}
}Qwen3 models enter verbose "thinking mode" before execution:
- Accept it - Think mode doesn't prevent file creation
- Benefit - Provides detailed reasoning about the task
- Workaround - Use
/mode buildto minimize thinking (may not fully suppress)
opencode --model ollama/qwen3:8b-16k
> /mode build
> Create a todo.md file with 3 tasks
# Still shows some thinking, but completes successfullyImportant: Custom system prompts or Modelfiles will NOT add tool usage to models lacking this capability:
# ❌ This will NOT work - Mistral Nemo lacks tool training
ollama create opencode-mistral -f custom-modelfile.txt
opencode --model ollama/opencode-mistral
> Create a file
# Still won't create files - model lacks function calling abilityTool usage requires specific training data and model architecture changes, not just prompt engineering.
Use for:
- ✅ File creation and modification
- ✅ Code generation
- ✅ Refactoring with file changes
- ✅ Multi-file operations
- ✅ Code review (read-only)
- ✅ Analysis and planning
Example workflows:
# File creation
opencode --model ollama/qwen3:8b-16k
> Create a Python class for user authentication
# Refactoring
> Refactor UserService to use dependency injection
# Multi-file changes
> Add type hints to all files in src/utils/Use for:
- ✅ Code review (read-only)
- ✅ Analysis and suggestions
- ✅ Architecture planning
- ✅ Documentation review
- ❌ CANNOT create or modify files
Example workflows:
# Code review (works great)
opencode --model ollama/mistral-nemo:12b-instruct-2407-q4_K_M
> /mode review
> Analyze the security of src/auth/ directory
# Planning (works great)
> /mode plan
> Analyze the codebase architecture and suggest improvements
# Implementation (FAILS - no file creation)
> /mode build
> Implement the suggested improvements
# ❌ Will analyze but NOT create filesUse different models for different phases:
# Phase 1: Analysis with Mistral Nemo (best quality)
opencode --model ollama/mistral-nemo:12b-instruct-2407-q4_K_M
> /mode review
> Review src/auth/ for security issues
# ✅ Get excellent analysis and recommendations
# Phase 2: Implementation with Qwen3 (tool usage)
opencode --model ollama/qwen3:8b-16k
> /mode build
> Implement the security fixes recommended above
# ✅ Actually creates/modifies filesCause: Using Mistral Nemo or Granite for file operations
Solution: Switch to Qwen3 model
# Instead of this:
opencode --model ollama/mistral-nemo:12b-instruct-2407-q4_K_M
> Create a file
# Use this:
opencode --model ollama/qwen3:8b-16k
> Create a fileCause: Qwen3 models have built-in thinking behavior
Solutions:
- Accept it - File still gets created successfully
- Use
/mode build- May reduce (but not eliminate) thinking - Consider the benefit - Think mode provides useful reasoning
- Use smaller model - qwen3:8b or qwen3:4b may be faster
Cause: Mistral Nemo has best quality but no tool usage
Solution: Hybrid approach
# Get analysis from Mistral Nemo
opencode --model ollama/mistral-nemo:12b-instruct-2407-q4_K_M
> /mode plan
> Design the authentication system
# Implement with Qwen3
opencode --model ollama/qwen3:8b-16k
> /mode build
> Implement the authentication system designed aboveNeed to create/modify files?
├─ YES → Use Qwen3 models
│ ├─ Multi-file/complex → qwen3:8b-16k (16k context)
│ ├─ Standard tasks → qwen3:8b (8k context, faster)
│ └─ Simple/quick → qwen3:4b (fastest)
│
└─ NO (analysis only) → Any model
├─ Best quality → mistral-nemo:12b-instruct-2407-q4_K_M
├─ Fast analysis → granite3.1-moe
└─ Extended context → qwen3:8b-16k
File creation (Qwen3 required):
opencode --model ollama/qwen3:8b-16k
> Create/modify/refactor [description]Code review (any model):
opencode --model ollama/mistral-nemo:12b-instruct-2407-q4_K_M
> /mode review
> Review [file/directory]Hybrid workflow:
# Step 1: Analyze
opencode --model ollama/mistral-nemo:12b-instruct-2407-q4_K_M
> /mode plan
> [analysis task]
# Step 2: Implement
opencode --model ollama/qwen3:8b-16k
> /mode build
> [implementation task]2025-11-18:
- ✅ RESOLVED: Confirmed Qwen3 models have tool usage capabilities
- ✅ TESTED: qwen3:8b-16k successfully creates files
- ❌ CONFIRMED: granite3.1-moe and mistral-nemo:12b-instruct-2407-q4_K_M lack tool usage
- 📝 DOCUMENTED: Root cause is model training, not Open Code CLI issue
- 📝 PUBLISHED: Workarounds and hybrid workflow strategies