[BUG] Tools whose sanitized name starts with a digit crash every provider's tool conversion before the LLM call

Abierto
#9,250 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 1 día

@HhH666-ux ya está trabajando en esto.

Desde el 8/11/2026.

  • #9251 de @HhH666-ux — abierto
  • #9263 de @2Zest — abierto

Evaluación

Dificultad
2/5
Tiempo estimado
1-3 horas
Aptitud para principiantes
35/100
Tipo de issue
Error
Claridad
Bien especificado
Estado de actividad
Estancado
Stack tecnológico
python

Línea de trabajo

Start with sanitize_tool_name() in lib/crewai/src/crewai/utilities/string_utils.py, then trace how its result reaches validate_function_name() in lib/crewai/src/crewai/llms/providers/utils/common.py. Reproduce the failure using the offline example in the issue and inspect related tool conversion code in lib/crewai/src/crewai/utilities/agent_utils.py. Done means digit-leading sanitized names pass conversion while ordinary names still work; two open pull requests already address this issue.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

Bug Description

sanitize_tool_name() (lib/crewai/src/crewai/utilities/string_utils.py) lowercases, strips disallowed characters, and removes leading underscores — but it happily returns a name starting with a digit: '3D Renderer' → '3d_renderer', '2FA Verifier' → '2fa_verifier'.

convert_tools_to_openai_schema() (lib/crewai/src/crewai/utilities/agent_utils.py:292) builds every provider's tool schema from that sanitized name, and safe_tool_conversion() → validate_function_name() (lib/crewai/src/crewai/llms/providers/utils/common.py:25) then rejects it:

ValueError: OpenAI function name '3d_renderer' must start with a letter or underscore

This happens locally, before any HTTP request, on every function-calling run for such tools — openai, azure, anthropic, bedrock and gemini all funnel through safe_tool_conversion. Meanwhile OpenAI/Anthropic/Bedrock's published name specs (^[a-zA-Z0-9_-]{1,64}$-style) all allow leading digits, so the sanitizer creates a name the providers would accept but crewAI's own validator refuses.

Steps to Reproduce

Offline, no API key — the failing path is sanitize_tool_name + safe_tool_conversion:

from crewai.utilities.string_utils import sanitize_tool_name
from crewai.utilities.agent_utils import convert_tools_to_openai_schema

class T:
    name = "3D Renderer"
    description = "renders"
    args_schema = None
    parameters_verify_mode = None
    max_usage_count = None

convert_tools_to_openai_schema([T()])   # ValueError

Tools named '3D Renderer', '2024 Sales Analyzer', '2FA Verifier' all crash; a normal name is unaffected.

Expected behavior

The sanitized name should be usable by every provider's validator — e.g. prefix an underscore when the sanitized result starts with a digit ('3d_renderer' → '_3d_renderer'), consistent with how the MCP tool resolver already prefixes mcp_ to satisfy the same validation.

Screenshots/Code snippets
sanitize_tool_name("3D Renderer")      # '3d_renderer'  -> validate_function_name raises
sanitize_tool_name("2024 Sales Analyzer")  # '2024_sales_analyzer' -> raises
sanitize_tool_name("get_weather")      # 'get_weather'  -> fine
Operating System

Windows 11

Python Version

3.12

crewAI Version

main 2fba413 (1.15.x)

Lenguaje dominante
Python
Estrellas
60.6k
Forks
9.1k
Merge medio
1 d 9 h
PR fusionados (30 d)
218

Preparar el entorno

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de crewAIInc/crewAI

Todos los issues de crewAIInc/crewAI

Issues similares

Más issues de Python

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.