ComposioHQ/composio · error · ComposioGlobalExecuteToolFnNotSetError

executeToolFn is not set

Error message

executeToolFn is not set

What it means

Providers get their tool-execution function injected by the core SDK via _setExecuteToolFn after initialization. Calling provider.executeTool() before the core Composio instance has wired the provider (e.g. on a standalone/instantiated provider, or before tools/connection setup) leaves _globalExecuteToolFn undefined and throws ComposioGlobalExecuteToolFnNotSetError.

Source

Thrown at ts/packages/core/src/provider/BaseProvider.ts:61

  }

  /**
   * @public
   * Global function to execute a tool.
   * This function is used by providers to implement helper functions to execute tools.
   * This is a 1:1 mapping of the `execute` method in the `Tools` class.
   * @param {string} toolSlug - The slug of the tool to execute.
   * @param {ToolExecuteParams} body - The body of the tool execution.
   * @param {ExecuteToolModifiers} modifers - The modifiers of the tool execution.
   * @returns {Promise<string>} The result of the tool execution.
   */
  executeTool(
    toolSlug: string,
    body: ToolExecuteParams,
    modifers?: ExecuteToolModifiers
  ): Promise<ToolExecuteResponse> {
    if (!this._globalExecuteToolFn) {
      throw new ComposioGlobalExecuteToolFnNotSetError('executeToolFn is not set');
    }

    // For provider controlled execution, always skip version check.
    return this._globalExecuteToolFn(toolSlug, body, modifers);
  }

  /** Reject direct-only configuration when execution is bound to a session. */
  protected assertToolCallExecutionOptions(
    target: ToolCallExecutionTarget,
    options?: ExecuteToolFnOptions,
    modifiers?: ExecuteToolModifiers
  ): void {
    if (typeof target !== 'string' && (options !== undefined || modifiers !== undefined)) {
      throw new TypeError(
        'Direct execution options and modifiers cannot be used with a Tool Router session'
      );
    }
  }

View on GitHub (pinned to 64b1b85502)

Solutions

  1. Call executeTool through the Composio core (e.g. composio.tools.execute or a connected session) so the provider is wired
  2. Obtain the provider via the SDK (getProvider/provider registry) rather than instantiating it yourself, so _setExecuteToolFn is injected
  3. Ensure provider.executeTool() is only invoked after Composio initialization/connection resolves (await init before handling requests)
  4. If you must wire manually, call the internal _setExecuteToolFn with the core's execute function

Example fix

// before
const provider = new OpenAIProvider(...);
await provider.executeTool('GITHUB_STAR_REPO', { userId, body: {} }); // throws
// after
const composio = await Composio.init({ apiKey });
const tools = await composio.tools.get({ toolkits: ['github'], user: 'me' });
await composio.tools.execute('GITHUB_STAR_REPO', { userId: 'me', body: {} });
Defensive patterns

Strategy: validation

Validate before calling

if (!(provider as any)._setExecuteToolFn || provider.executeTool.length === 0) { /* not wired */ }
// practical: only call execute after Composio init resolves
await composioReady; // await Composio.init(...) and getTools before handling tool calls

Type guard

const isWiredProvider = (p: unknown): boolean =>
  Object.prototype.hasOwnProperty.call(p ?? {}, '_globalExecuteToolFn');

Try / catch

try { await provider.executeTool(slug, body); } catch (e) { if (e instanceof ComposioGlobalExecuteToolFnNotSetError) { /* re-init or route through composio.tools.execute */ } throw e; }

Prevention

When it happens

Trigger: Constructing a provider class directly (new SomeProvider(...)) and calling executeTool() on it, or calling provider.executeTool()/executeToolForTarget() before the Composio core has attached the global execute function during provider setup (e.g. before composio init or getTools/connection completes).

Common situations: Refactoring to call provider helpers outside the normal composio flow, race conditions where a tool call fires before initialization finishes, or upgrading SDK versions where wiring order changed.

Related errors


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