Skip to content

Fix prefix collisions in bare tool call names - #7667

Open
imharjot wants to merge 1 commit into
oobabooga:mainfrom
imharjot:fix/bare-tool-name-prefixes
Open

imharjot wants to merge 1 commit into
oobabooga:mainfrom
imharjot:fix/bare-tool-name-prefixes

Conversation

@imharjot

@imharjot imharjot commented Oct 4, 2026

Copy link
Copy Markdown

A bare search_web{"query":"weather"} call is renamed to search when the registered tools are ['search', 'search_web']. This can select the wrong executor in chat or return the wrong function name through the API.

Capture the exact name already matched by the regex instead of selecting it again with startswith. Keep the nonempty-name guard so an empty tool list still produces no calls. JSON extraction and the returned content prefix are unchanged.

Fixes #7666

Tests

  • python -m unittest discover -s tests -v: 10 standard-library tests passed on Python 3.12.15 and 3.13.16. Four regressions fail on unchanged source; six controls pass, including eleven other-format subcases.
  • Real local tool loading and execution: unchanged source runs search; the fix runs search_web with the same arguments.
  • Full modules compilation, repository-configured pycodestyle, additional ruff check, and git diff --check: passed.

No dependency changes. A full model/UI/API server was not run; the public parser and local tool loading/execution were exercised without mocking them.

Checklist:

This branch has not been deployed

No deployments
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.

Bare tool calls select a shorter registered function name

1 participant