Composio powers 1000+ toolkits, tool search, context management, authentication, and a sandboxed workbench to help you build AI agents that turn intent into action.
Mirrored from https://github.com/Camo67/composio.git
Synced Nov 22, 18:15 UTC
Fix: Provider not found error in non-agentic providers (#2202)
Musthaq Ahamad committed
Nov 24, 2025 at 15:33 UTC
2937634a3f5a337a75989267939bd9f922f9e619
5 files changed
+30
-26
ts/packages/core/src/composio.ts
+6
-5
@@ -199,6 +199,11 @@ export class Composio<
199
logger.debug(`Initializing Composio w API Key: [REDACTED] and baseURL: ${baseURLParsed}`);
200
}
201
202
+ /**
203
+ * Set the default provider, if not provided by the user.
204
+ */
205
+ this.provider = (config?.provider ?? new OpenAIProvider()) as TProvider;
206
+
207
/**
208
* Keep a reference to the config object.
209
* This is useful for creating a builder pattern, debugging and logging.
@@ -210,13 +215,9 @@ export class Composio<
215
toolkitVersions: getToolkitVersionsFromEnv(config?.toolkitVersions),
216
allowTracking: config?.allowTracking ?? true,
217
autoUploadDownloadFiles: config?.autoUploadDownloadFiles ?? true,
218
+ provider: config?.provider ?? this.provider,
219
};
220
215
- /**
216
- * Set the default provider, if not provided by the user.
217
- */
218
- this.provider = (config?.provider ?? new OpenAIProvider()) as TProvider;
219
-
221
const defaultHeaders = getDefaultHeaders(this.config.defaultHeaders, this.provider);
222
223
/**
ts/packages/core/src/models/Tools.ts
+19
-16
@@ -36,7 +36,7 @@ import {
36
} from '../types/modifiers.types';
37
import { BaseComposioProvider } from '../provider/BaseProvider';
38
import logger from '../utils/logger';
39
-import { ExecuteToolFn } from '../types/provider.types';
39
+import { ExecuteToolFn, GlobalExecuteToolFn } from '../types/provider.types';
40
import {
41
ComposioCustomToolsNotInitializedError,
42
ComposioInvalidModifierError,
@@ -81,20 +81,7 @@ export class Tools<
81
// Bind the execute method to ensure correct 'this' context
82
this.execute = this.execute.bind(this);
83
// Set the execute method for the provider.
84
- // Non-agentic providers (e.g., OpenAI/Anthropic tool calling) should default to skipping the
85
- // "latest" version guard so agent responses never fail due to missing toolkit versions.
86
- const providerExecuteToolFn = this.provider._isAgentic
87
- ? this.execute
88
- : (slug: string, body: ToolExecuteParams, modifiers?: ExecuteToolModifiers) =>
89
- this.execute(
90
- slug,
91
- {
92
- ...body,
93
- dangerouslySkipVersionCheck: body.dangerouslySkipVersionCheck ?? true,
94
- },
95
- modifiers
96
- );
97
- this.provider._setExecuteToolFn(providerExecuteToolFn);
84
+ this.provider._setExecuteToolFn(this.createExecuteFnForProviders());
85
// Bind methods that use customTools to ensure correct 'this' context
86
this.getRawComposioToolBySlug = this.getRawComposioToolBySlug.bind(this);
87
this.getRawComposioTools = this.getRawComposioTools.bind(this);
@@ -597,6 +584,22 @@ export class Tools<
584
return this.provider.wrapTools(tools, executeToolFn) as TToolCollection;
585
}
586
}
587
+ /**
588
+ * @internal
589
+ * Creates a global execute tool function.
590
+ * This function is used by providers to execute tools.
591
+ * It skips the version check for provider controlled execution.
592
+ * @returns {GlobalExecuteToolFn} The global execute tool function
593
+ */
594
+ private createExecuteFnForProviders(): GlobalExecuteToolFn {
595
+ return async (slug: string, body: ToolExecuteParams, modifiers?: ExecuteToolModifiers) => {
596
+ return await this.execute(
597
+ slug,
598
+ { ...body, dangerouslySkipVersionCheck: body.dangerouslySkipVersionCheck ?? true },
599
+ modifiers
600
+ );
601
+ };
602
+ }
603
604
/**
605
* @internal
@@ -615,7 +618,7 @@ export class Tools<
618
{
619
userId,
620
arguments: input,
618
- // dangerously skip version check for agentic and non agentic tool execution via providers
621
+ // dangerously skip version check for agentic tool execution via providers
622
// this can be safe because most agentic flows users fetch latest version and then execute the tool
623
dangerouslySkipVersionCheck: true,
624
},
ts/packages/core/src/provider/BaseProvider.ts
+3
-1
@@ -40,7 +40,7 @@ abstract class BaseProvider<TMcpResponse> {
40
/**
41
* @public
42
* Global function to execute a tool.
43
- * This function is used by providerds to implement helper functions to execute tools.
43
+ * This function is used by providers to implement helper functions to execute tools.
44
* This is a 1:1 mapping of the `execute` method in the `Tools` class.
45
* @param {string} toolSlug - The slug of the tool to execute.
46
* @param {ToolExecuteParams} body - The body of the tool execution.
@@ -55,6 +55,8 @@ abstract class BaseProvider<TMcpResponse> {
55
if (!this._globalExecuteToolFn) {
56
throw new ComposioGlobalExecuteToolFnNotSetError('executeToolFn is not set');
57
}
58
+
59
+ // For provider controlled execution, always skip version check.
60
return this._globalExecuteToolFn(toolSlug, body, modifers);
61
}
62
ts/packages/core/test/tools/fileModifiers.test.ts
+1
-4
@@ -1,15 +1,12 @@
1
import { describe, it, expect, vi, beforeEach } from 'vitest';
2
import { FileToolModifier } from '../../src/utils/modifiers/FileToolModifier';
3
import ComposioClient from '@composio/client';
4
-import { Tool, ToolExecuteResponse } from '../../src/types/tool.types';
4
+import { Tool } from '../../src/types/tool.types';
5
import { ComposioFileUploadError } from '../../src/errors/FileModifierErrors';
6
import * as fileUtils from '../../src/utils/fileUtils';
7
import { Tools } from '../../src/models/Tools';
8
-import { BaseComposioProvider } from '../../src/provider/BaseProvider';
8
import { createTestContext, setupTest, mockToolExecution } from '../utils/toolExecuteUtils';
9
import { mockClient } from '../utils/mocks/client.mock';
11
-import { toolMocks } from '../utils/mocks/data.mock';
12
-import { ToolExecuteResponse as ComposioToolExecuteResponse } from '@composio/client/resources/tools';
10
11
// Mock the fileUtils module
12
vi.mock('../../src/utils/fileUtils', () => ({
ts/packages/core/test/utils/mocks/provider.mock.ts
+1
@@ -3,6 +3,7 @@ import { BaseAgenticProvider } from '../../../src/provider/BaseProvider';
3
4
export class MockProvider extends BaseAgenticProvider<unknown, unknown, unknown> {
5
readonly name = 'MockProvider';
6
+ readonly _isAgentic = true;
7
8
wrapTool = vi.fn();
9
wrapTools = vi.fn();