crewAIInc/crewAI · error · ValueError

Project name '{name}' would generate class name '{class_name

Error message

Project name '{name}' would generate class name '{class_name}' which cannot start with a digit

What it means

Raised at the top of ContextualQueryTool._run when the agent_id argument is empty. agent_id is a required positional parameter identifying which Contextual AI agent to query; an empty string or None fails fast before any datastore-readiness polling or retrieval call is made.

Source

Thrown at lib/cli/src/crewai_cli/create_crew.py:103

    reserved_names = get_reserved_script_names()
    if folder_name in reserved_names:
        raise ValueError(
            f"Project name '{name}' would generate folder name '{folder_name}' which is reserved. "
            f"Reserved names are: {', '.join(sorted(reserved_names))}. "
            "Please choose a different name."
        )

    class_name = name.replace("_", " ").replace("-", " ").title().replace(" ", "")

    class_name = re.sub(r"[^a-zA-Z0-9_]", "", class_name)

    if not class_name:
        raise ValueError(
            f"Project name '{name}' contains no valid characters for a Python class name"
        )

    if class_name[0].isdigit():
        raise ValueError(
            f"Project name '{name}' would generate class name '{class_name}' which cannot start with a digit"
        )

    original_name_clean = re.sub(
        r"[^a-zA-Z0-9_]", "", name.replace("_", "").replace("-", "").lower()
    )
    if (
        keyword.iskeyword(original_name_clean)
        or keyword.iskeyword(class_name)
        or class_name in ("True", "False", "None")
    ):
        raise ValueError(
            f"Project name '{name}' would generate class name '{class_name}' which is a reserved Python keyword"
        )

    if not class_name.isidentifier():
        raise ValueError(
            f"Project name '{name}' would generate invalid Python class name '{class_name}'"

View on GitHub (pinned to 754d7323be)

Solutions

  1. Capture the agent id from agent = client.agents.create(...) / the create tool's output and pass it: tool._run(query='q', agent_id=agent_id).
  2. If an LLM supplies arguments, describe agent_id as required in the tool schema/prompt so it is never blank.
  3. Guard upstream: if not agent_id: raise/fetch it before calling.

Example fix

# before
result = tool._run(query='what changed?', agent_id='')  # ValueError
# after
result = tool._run(query='what changed?', agent_id=agent_id)  # e.g. from create output
Defensive patterns

Strategy: validation

Validate before calling

if not agent_id or not agent_id.strip():
    raise ValueError("agent_id is empty; create an agent first and pass its id")
result = tool._run(query=query, agent_id=agent_id)

Prevention

When it happens

Trigger: Calling the tool with agent_id='' or agent_id=None — typically an LLM emitting a blank parameter, or wiring a variable that was never populated.

Common situations: Agent-created flow where the agent ID from ContextualCreateAgentTool was not captured/passed through, template prompts that leave agent_id blank, or string formatting bugs producing empty values.

Related errors


AI-assisted analysis of crewAIInc/crewAI@754d7323be (2026-08-15). Data as JSON: /api/errors/e55df9b372fb17c3. Report an issue: GitHub.