microsoft/autogen · error · ValueError
Invalid name: {name}. Name must be less than 64 characters.
Error message
Invalid name: {name}. Name must be less than 64 characters. What it means
Length branch of assert_valid_name in the llama.cpp client: raised when the name matches the allowed charset but is longer than 64 characters. Names validated by this module are capped at 64 chars because that is the limit the llama-cpp backend enforces.
Source
Thrown at python/packages/autogen-ext/src/autogen_ext/models/llama_cpp/_llama_cpp_completion_client.py:79
def normalize_name(name: str) -> str:
"""
LLMs sometimes ask functions while ignoring their own format requirements, this function should be used to replace invalid characters with "_".
Prefer _assert_valid_name for validating user configuration or input
"""
return re.sub(r"[^a-zA-Z0-9_-]", "_", name)[:64]
def assert_valid_name(name: str) -> str:
"""
Ensure that configured names are valid, raises ValueError if not.
For munging LLM responses use _normalize_name to ensure LLM specified names don't break the API.
"""
if not re.match(r"^[a-zA-Z0-9_-]+$", name):
raise ValueError(f"Invalid name: {name}. Only letters, numbers, '_' and '-' are allowed.")
if len(name) > 64:
raise ValueError(f"Invalid name: {name}. Name must be less than 64 characters.")
return name
def convert_tools(
tools: Sequence[Tool | ToolSchema],
) -> List[ChatCompletionTool]:
result: List[ChatCompletionTool] = []
for tool in tools:
if isinstance(tool, Tool):
tool_schema = tool.schema
else:
assert isinstance(tool, dict)
tool_schema = tool
result.append(
ChatCompletionTool(
type="function",
function=ChatCompletionToolFunction(View on GitHub (pinned to 027ecf0a37)
Solutions
- Truncate to 64 characters when constructing names
- Use _normalize_name for any LLM-supplied name — it truncates and sanitizes in one step
- Prefer short hashed slugs for long identifiers
Example fix
# before
name = f"{namespace}_{role}_{uuid4()}_executor" # >64 chars
# after
name = f"{namespace}_{role}_{uuid4().hex[:8]}_executor"[:64] Defensive patterns
Strategy: validation
Validate before calling
def truncate_name(name: str, limit: int = 64) -> str:
return name[:limit] Type guard
def is_valid_name_len(name: str) -> bool:
return len(name) <= 64 Prevention
- Apply [:64] wherever names are composed
- Use _normalize_name for LLM-generated names
- Prefer short generated slugs over descriptive long names
When it happens
Trigger: Auto-composed names (team + role + task id) exceeding 64 characters passed as message sources or tool names to LlamaCppChatCompletionClient; long function names generated by an LLM and passed through unmodified.
Common situations: Deterministic name builders in orchestration frameworks; names derived from prompts or file paths; concatenating namespaces into tool names.
Related errors
- Invalid name: {name}. Only letters, numbers, '_' and '-' are
- Invalid name: {name}. Name must be less than 64 characters.
- Missing ANTHROPIC_API_KEY environment variable.
- The model does not support function calling.
- Unsupported tool type: {type(tool)}
AI-assisted analysis of microsoft/autogen@027ecf0a37 (2026-08-15).
Data as JSON: /api/errors/34f94befaf740b57.
Report an issue: GitHub.