Resolve sanitized tool-name collisions consistently
Summary
Add deterministic collision resolution for sanitized tool names. Apply the resolved names consistently when tools are advertised and when tools are dispatched.
Rationale
sanitize_tool_name can map different original names to the same sanitized name. Existing collision paths include ASCII case normalization and over-length truncation. The non-ASCII fallback added in #7625 also uses a truncated hash, so it can collide in principle.
Current consumers can expose duplicate names or overwrite an earlier tool when a dispatch map uses a sanitized name as its key.
Affected areas
lib/crewai/src/crewai/utilities/string_utils.pyget_tool_names- Tool dispatch-map construction in
lib/crewai/src/crewai/utilities/tool_utils.py - Related native function-calling schema generation and regression tests
Required changes
- Define one deterministic collision-resolution step for a collection of tools.
- Preserve the current sanitized name when it is unique.
- Add stable, deterministic suffixes for colliding names.
- Keep every resolved name within the 64-character provider limit.
- Use the same resolved names for advertised tool names and dispatch-map keys.
- Do not rely only on increasing the hash length or on
convert_tools_to_openai_schemaduplicate handling.
Acceptance criteria
- Distinct tools that sanitize to the same base name receive distinct resolved names.
- Resolution is stable for the same tool collection and ordering.
- Resolved names satisfy provider naming and length constraints.
get_tool_names, generated schemas, and tool execution dispatch use matching resolved names.- Tests cover case-normalization collisions, truncation collisions, and dispatch of each colliding tool.
Backlinks
- Pull request: https://github.com/crewAIInc/crewAI/pull/7625
- Review comment: https://github.com/crewAIInc/crewAI/pull/7625#discussion_r4053180631
- Requested by: @CodeWithMoin
I would like to work on this issue if it is still unassigned.
Proposed approach:
- centralize collision resolution for a tool collection while preserving the current sanitized name when it is unique;
- resolve collisions deterministically using a stable suffix derived from the original name and bounded to the provider limit;
- use the resolved names consistently in advertised schemas, get_tool_names, dispatch maps, and native function-calling conversion;
- add regression tests for case-folding, truncation, non-ASCII/hash collisions, stable ordering, length limits, and dispatch of each colliding tool.
I will first reproduce the collision paths on current main, then submit a focused PR after confirming the proposed naming contract with maintainers. Could you assign this issue to me if this approach matches the project direction?
Got This 1
Pending Repair
Here is a proposed fix for deterministic tool name collision handling in lib/crewai/src/crewai/utilities/tool_utils.py:
def resolve_tool_name_collisions(tools):
"""
Ensures sanitized tool names are unique and deterministic while staying
under the 64-character limit.
"""
seen_names = set()
resolved_tools = []
for tool in tools:
base_name = sanitize_tool_name(tool.name)
candidate = base_name
suffix_counter = 1
while candidate in seen_names:
suffix = f"_{suffix_counter}"
max_base_len = 64 - len(suffix)
candidate = f"{base_name[:max_base_len]}{suffix}"
suffix_counter += 1
seen_names.add(candidate)
tool.sanitized_name = candidate
resolved_tools.append(tool)
return resolved_tools
This issue is stale because it has been open for 30 days with no activity. Remove stale label or comment or this will be closed in 5 days.
This issue was closed because it has been stalled for 5 days with no activity.
I’m still interested in taking this follow-up. It was closed automatically for inactivity before I got to it; could a maintainer please reopen it? I’ll keep the implementation scoped to one deterministic collection-level resolver used consistently by schema generation, get_tool_names, and dispatch-map construction, with regression tests for case-normalization, truncation, and execution of each colliding tool.