feat(macros): reject an empty #[tool_router] - #1233
Open
DaleSeo wants to merge 1 commit into
Open
Conversation
DaleSeo
force-pushed
the
DaleSeo/tool_router-builds-an-empty-router-without-compl
branch
from
September 1, 2026 12:37
d595603 to
da16056
Compare
DaleSeo
force-pushed
the
DaleSeo/tool_router-builds-an-empty-router-without-compl
branch
from
September 1, 2026 12:39
da16056 to
a106576
Compare
#[tool_router] collects no tools#[tool_router]
DaleSeo
marked this pull request as ready for review
September 1, 2026 23:49
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #1174.
Motivation and Context
An
implannotated with#[tool_router]that had no directly visible#[tool]functions compiled without any diagnostics and produced a router with zero tools. The server advertised an empty catalogue, and the problem only showed up on the other side of the connection, when a model found no tools.#[tool_router]now rejects an impl with no#[tool]functions instead of quietly building a router that serves nothing. Use#[tool_router(allow_empty)]to opt out.How Has This Been Tested?
Add tests
Breaking Changes
There is no API change, but an impl block annotated with
#[tool_router]no longer compiles if it doesn't contain any#[tool]functions. This is intended because an impl with no tools is almost always a mistake.Types of changes
Checklist