fix(agent): skip unresolved tool names instead of failing agent build#4769
Open
logicwu0 wants to merge 1 commit into
Open
fix(agent): skip unresolved tool names instead of failing agent build#4769logicwu0 wants to merge 1 commit into
logicwu0 wants to merge 1 commit into
Conversation
1 task
When a configured tool name cannot be resolved by the ToolCallbackResolver (e.g. the model/skill references a non-existent tool), DefaultBuilder.gatherLocalTools() threw IllegalStateException and aborted the whole agent build. Skip the unresolved name with the existing warning instead, consistent with the runtime fallback in AgentToolNode. Closes alibaba#4703
71743d9 to
6ab5e17
Compare
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 #4703
Problem
When a skill/model references a tool name that the
ToolCallbackResolvercannot resolve,DefaultBuilder.gatherLocalTools()threwIllegalStateException: No ToolCallback found for tool name: xxxand aborted the entire agent build.This is easy to trigger: as reported in #4703, a skill description can make the LLM treat the skill name itself as a tool name, producing a tool name that does not exist. The framework should degrade gracefully rather than fail.
Fix
In the
toolNamesresolution loop, whenresolver.resolve(toolName)returnsnull, keep the existing warning log andcontinue(skip the unresolved name) instead of throwing.This makes the build-time behavior consistent with the runtime path in
AgentToolNode, which already skips an unresolved tool call and returns a"Tool not available"response (samePOSSIBLE_LLM_TOOL_NAME_CHANGE_WARNINGlog).Note: the
resolver == nullcase (misconfiguration) still fails fast as before — only the "resolver present but name not found" case is downgraded to warn+skip. Awarnis still emitted so genuine typos remain diagnosable.Tests
Added
DefaultBuilderToolResolutionTest(no model / API key needed):nullresolver with tool names still throws (unchanged behavior)All green;
spotless:applyrun.