ComposioHQ/composio · error · ValidationError
{context}: slug "{tool_slug}" is too long. With prefix "{pre
Error message
{context}: slug "{tool_slug}" is too long. With prefix "{prefix}", the final slug would be {final_length} characters (max {MAX_SLUG_LENGTH}). Shorten the slug to at most {available} characters. What it means
Raised when a custom tool's slug, after Composio prepends the LOCAL_ + TOOLKIT_ routing prefix, would exceed MAX_SLUG_LENGTH. The final routed name must fit the length cap, so the user slug alone must be short enough.
Source
Thrown at python/composio/core/models/custom_tool.py:125
def _compute_final_slug_length(tool_slug: str, toolkit_slug: t.Optional[str]) -> int:
"""Compute the final slug length: LOCAL_[TOOLKIT_]SLUG."""
length = len(LOCAL_TOOL_PREFIX) + len(tool_slug)
if toolkit_slug:
length += len(toolkit_slug) + 1 # +1 for underscore separator
return length
def _validate_slug_length(
tool_slug: str, toolkit_slug: t.Optional[str], context: str
) -> None:
"""Validate that the final slug won't exceed the max length."""
final_length = _compute_final_slug_length(tool_slug, toolkit_slug)
if final_length > MAX_SLUG_LENGTH:
prefix = LOCAL_TOOL_PREFIX + (
f"{toolkit_slug.upper()}_" if toolkit_slug else ""
)
available = MAX_SLUG_LENGTH - len(prefix)
raise ValidationError(
f'{context}: slug "{tool_slug}" is too long. '
f'With prefix "{prefix}", the final slug would be {final_length} '
f"characters (max {MAX_SLUG_LENGTH}). "
f"Shorten the slug to at most {available} characters."
)
def _build_final_slug(tool_slug: str, toolkit_slug: t.Optional[str] = None) -> str:
"""Build the final slug: LOCAL_[TOOLKIT_]SLUG."""
upper = tool_slug.upper()
if toolkit_slug:
return f"{LOCAL_TOOL_PREFIX}{toolkit_slug.upper()}_{upper}"
return f"{LOCAL_TOOL_PREFIX}{upper}"
def _get_input_json_schema(model: t.Type[BaseModel]) -> t.Dict[str, t.Any]:
"""Convert a Pydantic model class to a JSON Schema dict suitable for the backend."""
full_schema = model.model_json_schema()View on GitHub (pinned to 64b1b85502)
Solutions
- Shorten the tool slug to the reported `available` character count (the error message tells you the exact budget)
- Shorten the toolkit slug too — it reduces the prefix length and frees characters for the tool slug
- When generating slugs programmatically, truncate to a safe bound before tool creation
Example fix
# before @tool(slug="perform_advanced_semantic_search_across_all_connected_user_documents") # after @tool(slug="semantic_doc_search")
Defensive patterns
Strategy: validation
Validate before calling
from composio.core.models.custom_tool import MAX_SLUG_LENGTH, LOCAL_TOOL_PREFIX
def fits(slug: str, toolkit_slug: str = "") -> bool:
prefix = LOCAL_TOOL_PREFIX + (f"{toolkit_slug.upper()}_" if toolkit_slug else "")
return len(prefix) + len(slug) <= MAX_SLUG_LENGTH
def clip(slug: str, toolkit_slug: str = "") -> str:
prefix = LOCAL_TOOL_PREFIX + (f"{toolkit_slug.upper()}_" if toolkit_slug else "")
return slug[: MAX_SLUG_LENGTH - len(prefix)] Type guard
def slug_fits(slug: str, toolkit_slug: str) -> bool:
prefix = "LOCAL_" + (toolkit_slug.upper() + "_" if toolkit_slug else "")
return len(prefix + slug) <= 64 # verify MAX_SLUG_LENGTH for your version Try / catch
try:
Tool(slug=slug, ...)
except ValidationError:
Tool(slug=slug[:40], ...) Prevention
- Keep tool slugs short (< 40 chars) and toolkit slugs concise
- Truncate auto-generated slugs before registration
- Read the available budget from the error message when it fires
When it happens
Trigger: Creating a tool with a very long slug (and/or a long toolkit slug) such that len('LOCAL_<TOOLKIT>_<slug>') > MAX_SLUG_LENGTH, via the @tool decorator, Tool(), or toolkit.tool(...).
Common situations: Auto-generating slugs from verbose function or docstring titles; long toolkit names eating the budget; machine-generated descriptive slugs from LLM pipelines.
Related errors
- {context}: slug is required
- {context}: slug must only contain alphanumeric characters, u
- Could not determine a home directory to store the Composio c
- Cache directory {directory} is not writable please provide a
- module {__name__!r} has no attribute {name!r}
AI-assisted analysis of ComposioHQ/composio@64b1b85502 (2026-08-28).
Data as JSON: /api/errors/fab26328430d0491.
Report an issue: GitHub.