Skip to content

fix(agent): skip unresolved tool names instead of failing agent build#4769

Open
logicwu0 wants to merge 1 commit into
alibaba:mainfrom
logicwu0:fix/4703-skip-unresolved-tool-name
Open

fix(agent): skip unresolved tool names instead of failing agent build#4769
logicwu0 wants to merge 1 commit into
alibaba:mainfrom
logicwu0:fix/4703-skip-unresolved-tool-name

Conversation

@logicwu0

@logicwu0 logicwu0 commented Jul 2, 2026

Copy link
Copy Markdown
Contributor

Closes #4703

Problem

When a skill/model references a tool name that the ToolCallbackResolver cannot resolve, DefaultBuilder.gatherLocalTools() threw IllegalStateException: No ToolCallback found for tool name: xxx and 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 toolNames resolution loop, when resolver.resolve(toolName) returns null, keep the existing warning log and continue (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 (same POSSIBLE_LLM_TOOL_NAME_CHANGE_WARNING log).

Note: the resolver == null case (misconfiguration) still fails fast as before — only the "resolver present but name not found" case is downgraded to warn+skip. A warn is still emitted so genuine typos remain diagnosable.

Tests

Added DefaultBuilderToolResolutionTest (no model / API key needed):

  • unresolved tool name is skipped, build does not throw (fails on pre-fix code)
  • resolvable tool name is still added (regression)
  • a resolvable tool is kept even when another name is unresolved
  • null resolver with tool names still throws (unchanged behavior)

All green; spotless:apply run.

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
@logicwu0 logicwu0 force-pushed the fix/4703-skip-unresolved-tool-name branch from 71743d9 to 6ab5e17 Compare July 5, 2026 14:47
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.

[BUG] Skill技能描述一个不存在的Tool会导致框架报错 No ToolCallback found for tool name:xxxx

1 participant