feat: configurable tool alias map for repairing miscalled tools#14085
feat: configurable tool alias map for repairing miscalled tools#14085sirus20x6 wants to merge 2 commits intoanomalyco:devfrom
Conversation
LLMs frequently miscall tools (e.g. todo_write instead of todowrite, search instead of grep). The existing repairToolCall handler already normalizes case and separators, but common synonyms and user-specific aliases were not supported. This adds: - Built-in alias defaults (search→grep, find→glob, cat→read, etc.) - A configurable `experimental.tool_aliases` record so users can define their own alias→canonical mappings - Alias lookup runs after normalization but before falling back to the "invalid" tool error
|
Thanks for your contribution! This PR doesn't have a linked issue. All PRs must reference an existing issue. Please:
See CONTRIBUTING.md for details. |
|
The following comment was made by an LLM, it may be inaccurate: I found one potentially related PR:
The current PR (#14085) extends this by adding configurable alias mappings and built-in defaults, while #10558 focuses on repair improvements for specific model types. |
|
bump |
|
@thdxr just a ping if it is possible to move on this one. |
This seriously helps with any model with tool calling issues. It seems like a no brainer to me. |
|
any comments on this? |
…14085) - anomalyco#9126: Add experimental Ruff language server support for Python projects. Enabled via OPENCODE_EXPERIMENTAL_LSP_RUFF flag. Detects virtual environments and supports all Python file extensions. - anomalyco#14085: Configurable tool alias map for repairing miscalled tools. LLMs frequently call wrong tool names (todo_write→todowrite, search→grep). Adds experimental.tool_aliases config to map common mistakes to correct tool names. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
@nexxeln any hope for this? it is not possible to create a tool that use the internal opencode AI to have a workaround in the meantime. |
Fixes #14087
Summary
LLMs frequently miscall tools —
todo_writeinstead oftodowrite,searchinstead ofgrep, etc. The existingexperimental_repairToolCallhandler normalizes case and separators, but common synonyms were not handled, causing the model to loop on invalid tool calls indefinitely.Before this change:
This PR adds:
search→grep,find→glob,cat→readrun/shell→bash,todo→todowrite,fetch→webfetchexperimental.tool_aliases— aRecord<string, string>so users can define their own alias → canonical tool name mappings (overrides builtins)The repair order is now:
"invalid"(existing)Example config
{ "experimental": { "tool_aliases": { "search": "codesearch", "lint": "bash" } } }Files changed
packages/opencode/src/config/config.ts— addedtool_aliasesto experimental schemapackages/opencode/src/session/llm.ts— alias resolution inexperimental_repairToolCallTest plan
bun run typecheckpassesbun run buildproduces binaries