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 21, 12:15 UTC
fix(cli): share the tool-version lookup with the executor
The memoized `get_latest_version` is keyed on slug, org, and project. The command's version check passed the resolved project while the executor's schema lookup passed nothing, so the two never shared a key and `composio execute` still issued both requests. Hand the executor the project scope the command resolved. Claude-Session: https://claude.ai/code/session_01MTb47vexN35pLGsSZwBmrJ
jkomyno committed
Sep 14, 2026 at 20:59 UTC
7c0788584bc26b820887fb4670256661293b934f
3 files changed
+60
-1
ts/packages/cli/src/commands/tools/commands/tools.execute.cmd.ts
+4
@@ -1172,6 +1172,10 @@ const resolveExecuteContext = (params: RunToolsExecuteParams) =>
1172
userId: resolvedUserId.value,
1173
arguments: args,
1174
client,
1175
+ projectScope: {
1176
+ orgId: resolvedProject.orgId,
1177
+ projectId: resolvedProject.projectId,
1178
+ },
1179
connectedAccounts:
1180
toolkitSlug && selectedConnectedAccountId
1181
? {
ts/packages/cli/src/services/tools-executor.ts
+10
-1
@@ -36,6 +36,15 @@ export interface ToolExecuteParams {
36
readonly arguments: Record<string, unknown>;
37
readonly client?: Composio;
38
readonly connectedAccounts?: Record<string, string>;
39
+ /**
40
+ * The org/project the command resolved. The executor's tool-schema lookup
41
+ * keys its memoized `get_latest_version` on this, so it has to match what
42
+ * the command's own version check passed or the two never share a request.
43
+ */
44
+ readonly projectScope?: {
45
+ readonly orgId?: string;
46
+ readonly projectId?: string;
47
+ };
48
readonly cacheScope?: {
49
readonly orgId: string;
50
readonly projectId: string;
@@ -201,7 +210,7 @@ export const ToolsExecutorLive = Layer.effect(
210
const path = yield* Path.Path;
211
const normalizedArguments = isMetaToolSlug(slug)
212
? params.arguments
204
- : yield* getOrFetchToolInputDefinition(slug).pipe(
213
+ : yield* getOrFetchToolInputDefinition(slug, params.projectScope).pipe(
214
Effect.catch(() => Effect.succeed(null)),
215
Effect.flatMap(definition => {
216
if (!definition) {
ts/packages/cli/test/src/commands/tools/tools.execute.cmd.test.ts
+46
@@ -8,6 +8,7 @@ import { extendConfigProvider } from 'src/services/config';
8
import { ComposioNoActiveConnectionError } from 'src/services/composio-error-overrides';
9
import { setupCacheDir } from 'src/effects/setup-cache-dir';
10
import { getOrFetchToolInputDefinition } from 'src/services/tool-input-validation';
11
+import { clearInProcessMemos } from 'src/utils/memoize-in-process';
12
import * as consumerShortTermCache from 'src/services/consumer-short-term-cache';
13
import * as composioClients from 'src/services/composio-clients';
14
import * as redactModule from 'src/ui/redact';
@@ -264,6 +265,24 @@ describe('CLI: composio execute', () => {
265
baseConfigProvider: testConfigProvider,
266
fixture: 'global-test-user-id',
267
stdin: { isTTY: true, data: '' },
268
+ toolkitsData: {
269
+ tools: [
270
+ {
271
+ name: 'Send Email',
272
+ slug: 'GMAIL_SEND_EMAIL',
273
+ description: 'Send an email',
274
+ tags: ['email'],
275
+ available_versions: ['20260115_00'],
276
+ input_parameters: {
277
+ type: 'object',
278
+ properties: {
279
+ recipient: { type: 'string' },
280
+ },
281
+ },
282
+ output_parameters: { type: 'object', properties: {} },
283
+ },
284
+ ],
285
+ } satisfies TestLiveInput['toolkitsData'],
286
connectedAccountsData: {
287
items: [
288
{
@@ -345,6 +364,33 @@ describe('CLI: composio execute', () => {
364
});
365
})
366
);
367
+
368
+ it.effect('asks for the latest tool version once per execute on a schema cache hit', () =>
369
+ Effect.gen(function* () {
370
+ const latestVersion = vi
371
+ .spyOn(composioClients, 'getLatestToolVersion')
372
+ .mockImplementation(({ toolSlug }) =>
373
+ Effect.succeed({ tool_slug: toolSlug, version: '20260115_00' })
374
+ );
375
+ // Warm the on-disk schema cache, then forget the memoized version so
376
+ // the next run has to ask the server again.
377
+ yield* getOrFetchToolInputDefinition('GMAIL_SEND_EMAIL');
378
+ clearInProcessMemos();
379
+ latestVersion.mockClear();
380
+
381
+ yield* cli([
382
+ 'execute',
383
+ 'GMAIL_SEND_EMAIL',
384
+ '--skip-connection-check',
385
+ '-d',
386
+ '{"recipient":"a"}',
387
+ ]);
388
+
389
+ // The command's own version check and the executor's schema lookup
390
+ // both run on this path; they must share one request.
391
+ expect(latestVersion).toHaveBeenCalledTimes(1);
392
+ })
393
+ );
394
});
395
396
layer(