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

The ToolRouterSession.tools() method lazily builds a Tools model scoped to the session and requires an AgenticProvider/NonAgenticProvider. If the session's _provider is None (provider lost during serialization/deserialization or manual construction), a ValueError is raised before the ToolsModel is created.

Source

Thrown at python/composio/core/models/tool_router_session.py:193

            inline_custom_tools_payload=self._inline_custom_tools_payload,
        )

    def tools(self, modifiers: t.Optional["Modifiers"] = None) -> TToolCollection:
        """
        Get provider-wrapped tools for execution with your AI framework.

        Returns tools configured for this session, wrapped in the format expected
        by your AI provider (OpenAI, Anthropic, LangChain, etc.).

        When custom tools are bound to the session, execution of
        COMPOSIO_MULTI_EXECUTE_TOOL is intercepted: local tools are executed
        in-process, remote tools are sent to the backend.
        """
        from composio.core.models.tools import Tools as ToolsModel
        from composio.core.provider import AgenticProvider, NonAgenticProvider

        if self._provider is None:
            raise ValueError(
                "Provider is required for tool router. "
                "Please initialize ToolRouter with a provider."
            )

        tools_model = ToolsModel(
            client=self._client,
            provider=self._provider,
            dangerously_allow_auto_upload_download_files=self._auto_upload_download_files,
            sensitive_file_upload_protection=self._sensitive_file_upload_protection,
            file_upload_path_deny_segments=self._file_upload_path_deny_segments,
            file_upload_dirs=self._file_upload_dirs,
        )

        router_tools = tools_model.get_raw_tool_router_meta_tools(
            session_id=self.session_id,
            modifiers=modifiers,
        )
        router_tools = self._add_preloaded_custom_tools(router_tools, modifiers)

View on GitHub (pinned to 64b1b85502)

Solutions

  1. Recreate the session through the provider-configured ToolRouter (create/use) rather than constructing ToolRouterSession directly
  2. Always call .result()/.tools() on the session object returned by router.create()/router.use()

Example fix

# before
session = ToolRouterSession(client=client, session_id=sid)
tools = session.tools()

# after
router = ToolRouter(api_key=key, provider=provider)
session = router.get(sid)  # provider-carrying session
tools = session.tools()
Defensive patterns

Strategy: validation

Validate before calling

assert getattr(session, '_provider', None) is not None

Prevention

When it happens

Trigger: Calling session.tools() (often indirectly via session.result or the streaming result flow) on a session whose provider wasn't set — e.g. a session restored from stored state or created outside the normal ToolRouter path.

Common situations: Persisting a session ID and reconstructing a session object manually, mocks/fakes in tests that omit the provider.

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


AI-assisted analysis of ComposioHQ/composio@64b1b85502 (2026-08-28). Data as JSON: /api/errors/fb369b569819f303. Report an issue: GitHub.