ComposioHQ/composio · error · ValueError
Provider is required for tool router. Please initialize Tool
Error message
Provider is required for tool router. Please initialize ToolRouter with a provider.
What it means
Raised by ToolRouter.create() when the ToolRouter instance was constructed without a provider (self._provider is None). The provider is mandatory because it drives session creation semantics; the error is a plain ValueError at the point the API call would be made.
Source
Thrown at python/composio/core/models/tool_router.py:1075
custom_toolkits=custom_toolkits,
default_preload=default_custom_preload,
preload_tools=preload.get("tools") if preload is not None else None,
)
if inline_custom_tools_payload:
if "custom_tools" in inline_custom_tools_payload:
experimental_payload["custom_tools"] = inline_custom_tools_payload[
"custom_tools"
]
if "custom_toolkits" in inline_custom_tools_payload:
experimental_payload["custom_toolkits"] = inline_custom_tools_payload[
"custom_toolkits"
]
if experimental_payload:
create_params["experimental"] = experimental_payload
if self._provider is None:
raise ValueError(
"Provider is required for tool router. "
"Please initialize ToolRouter with a provider."
)
# Make API call to create session
session = self._client.tool_router.session.create(**create_params)
# Build custom tools routing map from backend response
custom_tools_map: t.Optional[CustomToolsMap] = None
if custom_tools or custom_toolkits:
custom_tools_map = build_custom_tools_map_from_response(
tools=custom_tools or [],
toolkits=custom_toolkits,
experimental=session.experimental,
)
preloaded_custom_tool_slugs = get_preloaded_custom_tool_slugs(
custom_tools_map,
default_preload=default_custom_preload,View on GitHub (pinned to 64b1b85502)
Solutions
- Construct ToolRouter with a provider: ToolRouter(api_key=..., provider=provider)
- If migrating, pass the same provider you give to Composio(...)
Example fix
# before router = ToolRouter(api_key=key) session = router.create(...) # after router = ToolRouter(api_key=key, provider=provider) session = router.create(...)
Defensive patterns
Strategy: validation
Validate before calling
assert router._provider is not None or construct with provider
Prevention
- Always pass provider to ToolRouter
- Fail fast: check provider right after construction
When it happens
Trigger: ToolRouter(api_key=...) without a provider, then router.create(...) — the missing provider is only detected at create time, not at construction.
Common situations: Migrating from an older ToolRouter signature where provider was optional, or constructing ToolRouter from a partial config object that omitted the provider field.
Understand the failure class
Background: Missing required parameter errors: what 'X is required' and 'the required X param is missing' mean, and how to fix them — this error's family across 27 libraries.
Related errors
- Provider is required for tool router. Please initialize Tool
- Pass either `sandbox` or `workbench`, not both. `workbench`
- Invalid tool router session delete response
- Could not determine a home directory to store the Composio c
- Cache directory {directory} is not writable please provide a
AI-assisted analysis of ComposioHQ/composio@64b1b85502 (2026-08-28).
Data as JSON: /api/errors/b6f33d537b8701cb.
Report an issue: GitHub.