[PR #10558] fix: improve tool name repair for local/Ollama models #13482

Open
opened 2026-02-16 18:18:20 -05:00 by yindo · 0 comments
Owner

Original Pull Request: https://github.com/anomalyco/opencode/pull/10558

State: open
Merged: No


Summary

Improves the experimental_repairToolCall function to better handle tool name mismatches from local models (especially via Ollama).

Problem: Open source models generate tool calls with incorrect names:

  • Wrong case: Write instead of write
  • Different naming conventions: readfile, read_file, ReadFile instead of read
  • Prefixed names: repo_browser.read_file, file_system.write
  • Hallucinated names: Execute, shell_command, run_command

Solution: Multi-stage tool name repair:

  1. Case-insensitive exact match
  2. Comprehensive alias lookup (100+ common variations)
  3. Prefix stripping (repo_browser., file_system., etc.)
  4. Fuzzy matching (starts-with / contains)

Test Plan

  • TypeScript compiles (bun run typecheck)
  • Manual testing with Ollama models (Qwen2.5-Coder, Qwen3, Devstral)

Related Issues

Fixes #234 - Tool Calling Issues with Open Source Models in OpenCode
Related: #1034, #3029

**Original Pull Request:** https://github.com/anomalyco/opencode/pull/10558 **State:** open **Merged:** No --- ## Summary Improves the experimental_repairToolCall function to better handle tool name mismatches from local models (especially via Ollama). **Problem**: Open source models generate tool calls with incorrect names: - Wrong case: Write instead of write - Different naming conventions: readfile, read_file, ReadFile instead of read - Prefixed names: repo_browser.read_file, file_system.write - Hallucinated names: Execute, shell_command, run_command **Solution**: Multi-stage tool name repair: 1. Case-insensitive exact match 2. Comprehensive alias lookup (100+ common variations) 3. Prefix stripping (repo_browser., file_system., etc.) 4. Fuzzy matching (starts-with / contains) ## Test Plan - [x] TypeScript compiles (bun run typecheck) - [ ] Manual testing with Ollama models (Qwen2.5-Coder, Qwen3, Devstral) ## Related Issues Fixes #234 - Tool Calling Issues with Open Source Models in OpenCode Related: #1034, #3029
yindo added the pull-request label 2026-02-16 18:18:20 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#13482