Skip to content

Composio powers 1000+ toolkits, tool search, context management, authentication, and a sandboxed workbench to help you build AI agents that turn intent into action.

Fix: Provider not found error in non-agentic providers (#2202)

Musthaq Ahamad2937634a3f5a
diff --git a/ts/packages/core/src/composio.ts b/ts/packages/core/src/composio.ts
index 32b327cea..45dc7a0d0 100644
--- a/ts/packages/core/src/composio.ts
+++ b/ts/packages/core/src/composio.ts
@@ -199,6 +199,11 @@ export class Composio<
logger.debug(`Initializing Composio w API Key: [REDACTED] and baseURL: ${baseURLParsed}`);
}
+ /**
+ * Set the default provider, if not provided by the user.
+ */
+ this.provider = (config?.provider ?? new OpenAIProvider()) as TProvider;
+
/**
* Keep a reference to the config object.
* This is useful for creating a builder pattern, debugging and logging.
@@ -210,13 +215,9 @@ export class Composio<
toolkitVersions: getToolkitVersionsFromEnv(config?.toolkitVersions),
allowTracking: config?.allowTracking ?? true,
autoUploadDownloadFiles: config?.autoUploadDownloadFiles ?? true,
+ provider: config?.provider ?? this.provider,
};
- /**
- * Set the default provider, if not provided by the user.
- */
- this.provider = (config?.provider ?? new OpenAIProvider()) as TProvider;
-
const defaultHeaders = getDefaultHeaders(this.config.defaultHeaders, this.provider);
/**
diff --git a/ts/packages/core/src/models/Tools.ts b/ts/packages/core/src/models/Tools.ts
index dec14a295..aadd55f06 100644
--- a/ts/packages/core/src/models/Tools.ts
+++ b/ts/packages/core/src/models/Tools.ts
@@ -36,7 +36,7 @@ import {
} from '../types/modifiers.types';
import { BaseComposioProvider } from '../provider/BaseProvider';
import logger from '../utils/logger';
-import { ExecuteToolFn } from '../types/provider.types';
+import { ExecuteToolFn, GlobalExecuteToolFn } from '../types/provider.types';
import {
ComposioCustomToolsNotInitializedError,
ComposioInvalidModifierError,
@@ -81,20 +81,7 @@ export class Tools<
// Bind the execute method to ensure correct 'this' context
this.execute = this.execute.bind(this);
// Set the execute method for the provider.
- // Non-agentic providers (e.g., OpenAI/Anthropic tool calling) should default to skipping the
- // "latest" version guard so agent responses never fail due to missing toolkit versions.
- const providerExecuteToolFn = this.provider._isAgentic
- ? this.execute
- : (slug: string, body: ToolExecuteParams, modifiers?: ExecuteToolModifiers) =>
- this.execute(
- slug,
- {
- ...body,
- dangerouslySkipVersionCheck: body.dangerouslySkipVersionCheck ?? true,
- },
- modifiers
- );
- this.provider._setExecuteToolFn(providerExecuteToolFn);
+ this.provider._setExecuteToolFn(this.createExecuteFnForProviders());
// Bind methods that use customTools to ensure correct 'this' context
this.getRawComposioToolBySlug = this.getRawComposioToolBySlug.bind(this);
this.getRawComposioTools = this.getRawComposioTools.bind(this);
@@ -597,6 +584,22 @@ export class Tools<
return this.provider.wrapTools(tools, executeToolFn) as TToolCollection;
}
}
+ /**
+ * @internal
+ * Creates a global execute tool function.
+ * This function is used by providers to execute tools.
+ * It skips the version check for provider controlled execution.
+ * @returns {GlobalExecuteToolFn} The global execute tool function
+ */
+ private createExecuteFnForProviders(): GlobalExecuteToolFn {
+ return async (slug: string, body: ToolExecuteParams, modifiers?: ExecuteToolModifiers) => {
+ return await this.execute(
+ slug,
+ { ...body, dangerouslySkipVersionCheck: body.dangerouslySkipVersionCheck ?? true },
+ modifiers
+ );
+ };
+ }
/**
* @internal
@@ -615,7 +618,7 @@ export class Tools<
{
userId,
arguments: input,
- // dangerously skip version check for agentic and non agentic tool execution via providers
+ // dangerously skip version check for agentic tool execution via providers
// this can be safe because most agentic flows users fetch latest version and then execute the tool
dangerouslySkipVersionCheck: true,
},
diff --git a/ts/packages/core/src/provider/BaseProvider.ts b/ts/packages/core/src/provider/BaseProvider.ts
index c0cbe1bcb..703619f8c 100644
--- a/ts/packages/core/src/provider/BaseProvider.ts
+++ b/ts/packages/core/src/provider/BaseProvider.ts
@@ -40,7 +40,7 @@ abstract class BaseProvider<TMcpResponse> {
/**
* @public
* Global function to execute a tool.
- * This function is used by providerds to implement helper functions to execute tools.
+ * 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.
@@ -55,6 +55,8 @@ abstract class BaseProvider<TMcpResponse> {
if (!this._globalExecuteToolFn) {
throw new ComposioGlobalExecuteToolFnNotSetError('executeToolFn is not set');
}
+
+ // For provider controlled execution, always skip version check.
return this._globalExecuteToolFn(toolSlug, body, modifers);
}
diff --git a/ts/packages/core/test/tools/fileModifiers.test.ts b/ts/packages/core/test/tools/fileModifiers.test.ts
index c9e3de815..0efa2d3b1 100644
--- a/ts/packages/core/test/tools/fileModifiers.test.ts
+++ b/ts/packages/core/test/tools/fileModifiers.test.ts
@@ -1,15 +1,12 @@
import { describe, it, expect, vi, beforeEach } from 'vitest';
import { FileToolModifier } from '../../src/utils/modifiers/FileToolModifier';
import ComposioClient from '@composio/client';
-import { Tool, ToolExecuteResponse } from '../../src/types/tool.types';
+import { Tool } from '../../src/types/tool.types';
import { ComposioFileUploadError } from '../../src/errors/FileModifierErrors';
import * as fileUtils from '../../src/utils/fileUtils';
import { Tools } from '../../src/models/Tools';
-import { BaseComposioProvider } from '../../src/provider/BaseProvider';
import { createTestContext, setupTest, mockToolExecution } from '../utils/toolExecuteUtils';
import { mockClient } from '../utils/mocks/client.mock';
-import { toolMocks } from '../utils/mocks/data.mock';
-import { ToolExecuteResponse as ComposioToolExecuteResponse } from '@composio/client/resources/tools';
// Mock the fileUtils module
vi.mock('../../src/utils/fileUtils', () => ({
diff --git a/ts/packages/core/test/utils/mocks/provider.mock.ts b/ts/packages/core/test/utils/mocks/provider.mock.ts
index 740049d6a..5489b0f66 100644
--- a/ts/packages/core/test/utils/mocks/provider.mock.ts
+++ b/ts/packages/core/test/utils/mocks/provider.mock.ts
@@ -3,6 +3,7 @@ import { BaseAgenticProvider } from '../../../src/provider/BaseProvider';
export class MockProvider extends BaseAgenticProvider<unknown, unknown, unknown> {
readonly name = 'MockProvider';
+ readonly _isAgentic = true;
wrapTool = vi.fn();
wrapTools = vi.fn();