{"record":{"id":"f488b898c06ff7c6","repo":"ComposioHQ/composio","slug":"executetoolfn-is-not-set","errorCode":null,"errorMessage":"executeToolFn is not set","messagePattern":"executeToolFn is not set","errorType":"exception","errorClass":"ComposioGlobalExecuteToolFnNotSetError","httpStatus":null,"severity":"error","filePath":"ts/packages/core/src/provider/BaseProvider.ts","lineNumber":61,"sourceCode":"  }\n\n  /**\n   * @public\n   * Global function to execute a tool.\n   * This function is used by providers to implement helper functions to execute tools.\n   * This is a 1:1 mapping of the `execute` method in the `Tools` class.\n   * @param {string} toolSlug - The slug of the tool to execute.\n   * @param {ToolExecuteParams} body - The body of the tool execution.\n   * @param {ExecuteToolModifiers} modifers - The modifiers of the tool execution.\n   * @returns {Promise<string>} The result of the tool execution.\n   */\n  executeTool(\n    toolSlug: string,\n    body: ToolExecuteParams,\n    modifers?: ExecuteToolModifiers\n  ): Promise<ToolExecuteResponse> {\n    if (!this._globalExecuteToolFn) {\n      throw new ComposioGlobalExecuteToolFnNotSetError('executeToolFn is not set');\n    }\n\n    // For provider controlled execution, always skip version check.\n    return this._globalExecuteToolFn(toolSlug, body, modifers);\n  }\n\n  /** Reject direct-only configuration when execution is bound to a session. */\n  protected assertToolCallExecutionOptions(\n    target: ToolCallExecutionTarget,\n    options?: ExecuteToolFnOptions,\n    modifiers?: ExecuteToolModifiers\n  ): void {\n    if (typeof target !== 'string' && (options !== undefined || modifiers !== undefined)) {\n      throw new TypeError(\n        'Direct execution options and modifiers cannot be used with a Tool Router session'\n      );\n    }\n  }","sourceCodeStart":43,"sourceCodeEnd":79,"githubUrl":"https://github.com/ComposioHQ/composio/blob/64b1b85502b1beeb2379e6c9e8bf1104504fa637/ts/packages/core/src/provider/BaseProvider.ts#L43-L79","documentation":"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.","triggerScenarios":"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).","commonSituations":"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.","solutions":["Call executeTool through the Composio core (e.g. composio.tools.execute or a connected session) so the provider is wired","Obtain the provider via the SDK (getProvider/provider registry) rather than instantiating it yourself, so _setExecuteToolFn is injected","Ensure provider.executeTool() is only invoked after Composio initialization/connection resolves (await init before handling requests)","If you must wire manually, call the internal _setExecuteToolFn with the core's execute function"],"exampleFix":"// before\nconst provider = new OpenAIProvider(...);\nawait provider.executeTool('GITHUB_STAR_REPO', { userId, body: {} }); // throws\n// after\nconst composio = await Composio.init({ apiKey });\nconst tools = await composio.tools.get({ toolkits: ['github'], user: 'me' });\nawait composio.tools.execute('GITHUB_STAR_REPO', { userId: 'me', body: {} });","handlingStrategy":"validation","validationCode":"if (!(provider as any)._setExecuteToolFn || provider.executeTool.length === 0) { /* not wired */ }\n// practical: only call execute after Composio init resolves\nawait composioReady; // await Composio.init(...) and getTools before handling tool calls","typeGuard":"const isWiredProvider = (p: unknown): boolean =>\n  Object.prototype.hasOwnProperty.call(p ?? {}, '_globalExecuteToolFn');","tryCatchPattern":"try { await provider.executeTool(slug, body); } catch (e) { if (e instanceof ComposioGlobalExecuteToolFnNotSetError) { /* re-init or route through composio.tools.execute */ } throw e; }","preventionTips":["Never instantiate provider classes directly; obtain them from the SDK","Await Composio.init and tool registration before serving requests","Centralize tool execution through composio.tools.execute rather than provider.executeTool"],"tags":["provider","initialization","execute-tool","typescript"],"backgroundTag":"component-not-initialized","analyzedSha":"64b1b85502b1beeb2379e6c9e8bf1104504fa637","analyzedAt":"2026-08-28T15:39:33.623Z","schemaVersion":2},"datasetVersion":"2026-08-28T16:17:29.566Z"}