Skip to content

fix: improve tool name repair for local/Ollama models#10558

Open
nickihm wants to merge 1 commit intoanomalyco:devfrom
nickihm:fix/ollama-tool-name-repair
Open

fix: improve tool name repair for local/Ollama models#10558
nickihm wants to merge 1 commit intoanomalyco:devfrom
nickihm:fix/ollama-tool-name-repair

Conversation

@nickihm
Copy link

@nickihm nickihm commented Jan 25, 2026

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

Addresses issue anomalyco#234 where open source models (especially via Ollama)
generate tool calls with incorrect names like:
- Wrong case: "Write" instead of "write"
- Different naming conventions: "readfile", "read_file" instead of "read"
- Prefixed names: "repo_browser.read_file"
- Hallucinated tool names: "Execute", "shell_command"

Changes:
- Add comprehensive TOOL_ALIASES map covering common variations
- Implement multi-stage repair: case-insensitive match, alias lookup,
  prefix stripping, and fuzzy matching
- Keep backward compatibility with existing repair behavior

Tested with Qwen3, Devstral, and Qwen2.5-Coder models via Ollama.

Fixes anomalyco#234
@github-actions
Copy link
Contributor

The following comment was made by an LLM, it may be inaccurate:

No duplicate PRs found

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.

Tool Calling Issues with Open Source Models in OpenCode

1 participant