ComposioHQ/composio · error · Error

A provider is required when using custom tools with session.

Error message

A provider is required when using custom tools with session.tools(). Pass a provider in the Composio constructor.

What it means

session.tools() needs to wrap tool results through a provider adapter, but the Composio client was constructed without a provider. When custom tools are in play, the SDK requires a provider (passed to the Composio constructor) to call wrapTools, so it throws instead of returning incorrectly wrapped tools.

Source

Thrown at ts/packages/core/src/models/ToolRouterSession.ts:230

        if (toolSlug === COMPOSIO_MULTI_EXECUTE_TOOL) {
          return this.routeMultiExecute(input, ToolsModel, rawTools, modifiers);
        }
        const customTool = findCustomTool(this.customToolsMap, toolSlug);
        if (customTool) {
          return executeCustomTool(customTool, input, this.sessionContext!);
        }
        assertUnambiguousCustomToolSlug(this.customToolsMap, toolSlug);
        return this.executeBackendSessionTool(
          ToolsModel,
          toolSlug,
          input,
          modifiers,
          rawToolBySlug.get(toolSlug.toUpperCase())
        );
      };

      if (!this.config?.provider) {
        throw new Error(
          'A provider is required when using custom tools with session.tools(). ' +
            'Pass a provider in the Composio constructor.'
        );
      }
      return this.config.provider.wrapTools(sessionTools, routingExecuteFn) as ReturnType<
        TProvider['wrapTools']
      >;
    }

    // Standard path (no local tools)
    const wrappedTools = modifiers?.modifySchema
      ? ToolsModel.wrapToolsForToolRouter(this.sessionId, sessionTools, modifiers, rawTools)
      : ToolsModel.wrapToolsForToolRouter(this.sessionId, sessionTools, modifiers);
    return wrappedTools as ReturnType<TProvider['wrapTools']>;
  }

  private async applySchemaModifier(
    tools: Tool[],

View on GitHub (pinned to 64b1b85502)

Solutions

  1. Pass a provider when constructing Composio: new Composio({ apiKey, provider: new OpenAIProvider(...) })
  2. Ensure the same provider-configured client instance is used to create/retrieve the session
  3. If you never use custom tools, remove them so the provider branch isn't required

Example fix

// before
const composio = new Composio({ apiKey });
// after
const composio = new Composio({ apiKey, provider: new OpenAIProvider({ apiKey: openaiKey }) });
Defensive patterns

Strategy: validation

Validate before calling

const hasProvider = (c: Composio) => Boolean((c as any).config?.provider);
if (!hasProvider(composio)) throw new Error('provider required for session.tools() with custom tools');

Type guard

const supportsCustomToolSessions = (c: Composio): boolean => Boolean((c as any).config?.provider);

Try / catch

try { const t = await session.tools(); } catch (e) { if (/provider is required/.test(String(e?.message))) { throw new Error('Re-create Composio with a provider'); } throw e; }

Prevention

When it happens

Trigger: Creating `new Composio({ apiKey })` with no provider, binding custom tools to a session, then calling session.tools() — the code path hits the `if (!this.config?.provider)` check before provider.wrapTools.

Common situations: Using the SDK purely as an API client then later adding custom tools; provider passed to a different Composio instance than the one used for the session; examples copied from provider-less quickstarts extended with custom tools.

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/b8e69ba561c4cb29. Report an issue: GitHub.