You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Bug]:SubAgentTool derives the same tool name for agent names that differ only by case or spacing — registration fails with a duplicate-tool error #4207
SubAgentTool.sanitizeName decides whether to append the collision-avoidance hash from a
regex evaluated on the already lower-cased name, and that regex treats whitespace as a
safe character:
The sanitization itself is lossy (case folding, whitespace/punctuation → _, collapsing _),
but the "did we lose information?" check does not see that. Two distinct agent names therefore
sanitize to the same tool name and both skip the hash:
Registering two sub-agents with such names fails hard. subAgent() goes through
Toolkit.registerAgentTool(..., allowReplace=false) → ToolRegistry.registerTool, which
throws on a duplicate name:
IllegalStateException: Tool 'call_researcher' is already registered and will not be silently replaced.
So a legitimate configuration cannot be built, and the error does not explain that two distinct
agent names were folded together.
To Reproduce (unit test, no model / network)
Agent a = mock(Agent.class);
when(a.getName()).thenReturn("Researcher");
Agent b = mock(Agent.class);
when(b.getName()).thenReturn("researcher");
String nameA = new SubAgentTool(() -> a, SubAgentConfig.defaults()).getName();
String nameB = new SubAgentTool(() -> b, SubAgentConfig.defaults()).getName();
assertEquals("call_researcher", nameA);
assertEquals("call_researcher", nameB); // collision: both are identical
The same holds for "data analyst" vs "data_analyst".
Expected behavior
Distinct agent names must not silently collapse to the same tool name. Either derive
collision-free names (append the existing deterministic hash whenever sanitization is lossy —
case folding, whitespace/punctuation replacement, or underscore collapsing), or reject the
configuration with an actionable error that names both conflicting agents. A name that is
already canonical (^[a-z0-9_-]+$, no extra spacing) should keep its stable tool name.
Activity
fix(core): keep derived sub-agent tool names collision-free across ca…