Skip to content

feat: configurable tool alias map for repairing miscalled tools#14085

Open
sirus20x6 wants to merge 2 commits intoanomalyco:devfrom
sirus20x6:feat/tool-alias-repair
Open

feat: configurable tool alias map for repairing miscalled tools#14085
sirus20x6 wants to merge 2 commits intoanomalyco:devfrom
sirus20x6:feat/tool-alias-repair

Conversation

@sirus20x6
Copy link

@sirus20x6 sirus20x6 commented Feb 18, 2026

Fixes #14087

Summary

LLMs frequently miscall tools — todo_write instead of todowrite, search instead of grep, etc. The existing experimental_repairToolCall handler normalizes case and separators, but common synonyms were not handled, causing the model to loop on invalid tool calls indefinitely.

Before this change:

Tool miscall loop

This PR adds:

  • Built-in alias defaults — common synonyms resolved automatically with no config needed:
    • searchgrep, findglob, catread
    • run/shellbash, todotodowrite, fetchwebfetch
  • Configurable experimental.tool_aliases — a Record<string, string> so users can define their own alias → canonical tool name mappings (overrides builtins)

The repair order is now:

  1. Lowercase exact match (existing)
  2. Strip separators + case-insensitive match (existing)
  3. Config alias lookup (new) — checks raw name, lowercased, and normalized
  4. Built-in alias defaults (new) — hardcoded common synonyms
  5. Fall back to "invalid" (existing)

Example config

{
  "experimental": {
    "tool_aliases": {
      "search": "codesearch",
      "lint": "bash"
    }
  }
}

Files changed

  • packages/opencode/src/config/config.ts — added tool_aliases to experimental schema
  • packages/opencode/src/session/llm.ts — alias resolution in experimental_repairToolCall

Test plan

  • bun run typecheck passes
  • bun run build produces binaries
  • Manual test: use a model that tends to miscall tools, verify alias resolution in logs

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
@github-actions
Copy link
Contributor

Thanks for your contribution!

This PR doesn't have a linked issue. All PRs must reference an existing issue.

Please:

  1. Open an issue describing the bug/feature (if one doesn't exist)
  2. Add Fixes #<number> or Closes #<number> to this PR description

See CONTRIBUTING.md for details.

@github-actions
Copy link
Contributor

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.

@sirus20x6
Copy link
Author

bump

@Mte90
Copy link

Mte90 commented Feb 24, 2026

@thdxr just a ping if it is possible to move on this one.
I am getting the same problems with various models...

@sirus20x6
Copy link
Author

@thdxr just a ping if it is possible to move on this one. I am getting the same problems with various models...

This seriously helps with any model with tool calling issues. It seems like a no brainer to me.

@github-actions github-actions bot mentioned this pull request Feb 27, 2026
6 tasks
@sirus20x6
Copy link
Author

any comments on this?

vbuccigrossi pushed a commit to vbuccigrossi/opencode that referenced this pull request Mar 7, 2026
…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>
@Mte90
Copy link

Mte90 commented Mar 12, 2026

@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.

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.

LLMs loop indefinitely on miscalled tool synonyms (e.g. search, find, cat)

2 participants