Repository navigation
fix(core): keep derived sub-agent tool names collision-free across case and spacing - #4208
Merged
Merged
Conversation
…se and spacing SubAgentTool.sanitizeName decides whether to append a collision-avoidance hash from a regex over the already lower-cased name that treats whitespace as a safe character. Two distinct agent names can therefore sanitize to the same tool name without either receiving a hash: "Researcher" and "researcher" both become "call_researcher", and "data analyst" and "data_analyst" both become "call_data_analyst". Toolkit registration is fail-fast on duplicate tool names, so a legitimate configuration with such sub-agents fails to build with a duplicate-tool error. A derived name is collision-free only when sanitizing it lost nothing, i.e. the original name already equals its sanitized form. Base the hash decision on that equality instead of the "safe characters" regex, so case folding, whitespace or punctuation replacement, and underscore collapsing all trigger the hash, while an already-canonical lowercase name keeps its stable tool name.
jujn
approved these changes
Nov 18, 2026
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.
Summary
SubAgentTool.sanitizeNameskipped its collision-avoidance hash based on a regex over thealready lower-cased name that treated whitespace as safe. Because sanitization is lossy
(case folding, whitespace/punctuation →
_, underscore collapsing),"Researcher"/"researcher"and"data analyst"/"data_analyst"collapsed to the same tool name with nohash on either side, and fail-fast
Toolkitregistration then threw a duplicate-tool error.(
originalName.equals(safePart)), so any lossy transform appends the existing deterministichash. Already-canonical names keep their stable tool name.
Behavior note
Names that are not already canonical (uppercase, spaces, punctuation) now gain the hash suffix
even without a colliding sibling, because
sanitizeNamehas no sibling context. Users who needan exact tool name can pin it with
SubAgentTool/SubAgentConfig.toolName. Open to switching toregistration-time collision detection instead if preferred.
Test plan
SubAgentToolNameCollisionTest: case-only and space/underscore names must not collide;canonical
researcherstayscall_researcher; derived names remain OpenAI-compatible.SubAgent*suite: 29 tests, 0 failures. Spotless passes.Closes #4207