@devries-cameron20 / composio Mirror · read-only / commits / 88a106aac
Fork 0

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, 16:00 UTC

Revert "test(cli): cover custom toolkit cache retry"

This reverts commit d4b96d9c83cbabb48fccd499424cf4f0c96801c4.

shams haroon committed Aug 20, 2026 at 15:46 UTC 88a106aacc879360b23bc5896a8d3eb6103bdd18
3 files changed +33 -120
ts/packages/cli/src/commands/tools/commands/tools.search.cmd.ts
+4 -8
@@ -376,7 +376,7 @@ const runToolsSearch = (params: {
376 orgId: resolvedProject.orgId,
377 projectId: resolvedProject.projectId,
378 });
379 - let cacheRefreshSucceeded = false;
379 + let cacheRefreshAttempted = false;
380 if (resolvedProject.projectType === 'CONSUMER') {
381 const cachedToolkits = yield* getFreshConsumerConnectedToolkitsFromCache({
382 orgId: resolvedProject.orgId,
@@ -392,15 +392,11 @@ const runToolsSearch = (params: {
392 forceRefresh || Option.isNone(cachedToolkits) || requestedCustomToolkitMissing;
393
394 if (shouldRefresh) {
395 + cacheRefreshAttempted = true;
396 yield* refreshConsumerConnectedToolkitsCache({
397 orgId: resolvedProject.orgId,
398 consumerUserId: resolvedUserId.value,
399 }).pipe(
399 - Effect.tap(() =>
400 - Effect.sync(() => {
401 - cacheRefreshSucceeded = true;
402 - })
403 - ),
400 Effect.catchAll(() => invalidateConsumerConnectedToolkitsCache().pipe(Effect.ignore))
401 );
402 }
@@ -446,7 +442,7 @@ const runToolsSearch = (params: {
442 toolRouterSessionId: sessionId,
443 }
444 : undefined,
449 - cacheRefreshSucceeded,
445 + cacheRefreshAttempted,
446 };
447 });
448
@@ -464,7 +460,7 @@ const runToolsSearch = (params: {
460 const customToolkitFilters = (toolkitList ?? []).filter(isRemoteCustomToolSlug);
461 const shouldRetryAfterCustomToolkitMiss =
462 customToolkitFilters.length > 0 &&
467 - !firstSearchResult.cacheRefreshSucceeded &&
463 + !firstSearchResult.cacheRefreshAttempted &&
464 customToolkitFilters.some(
465 toolkit => !searchResponseIncludesToolkit(firstSearchResult.searchResponse, toolkit)
466 );
ts/packages/cli/src/services/tool-input-validation.ts
+28 -29
@@ -40,28 +40,6 @@ const toolDefinitionPath = (path: Path.Path, cacheDir: string, slug: string) =>
40 const ensureToolDefinitionsDir = (fs: FileSystem.FileSystem, path: Path.Path, cacheDir: string) =>
41 fs.makeDirectory(path.join(cacheDir, TOOL_DEFINITIONS_DIR), { recursive: true });
42
43 -const writeCachedToolInputDefinition = (params: {
44 - readonly fs: FileSystem.FileSystem;
45 - readonly schemaPath: string;
46 - readonly schema: Record<string, unknown>;
47 - readonly version: string | null;
48 -}) =>
49 - Effect.gen(function* () {
50 - yield* params.fs.writeFileString(
51 - params.schemaPath,
52 - serializeCachedToolDefinition({
53 - version: params.version,
54 - inputSchema: params.schema,
55 - })
56 - );
57 -
58 - return {
59 - schemaPath: params.schemaPath,
60 - schema: params.schema,
61 - version: params.version,
62 - };
63 - });
64 -
43 const parseSchemaFile = (raw: string, schemaPath: string) =>
44 decodeJsonObject(raw).pipe(
45 Effect.mapError(
@@ -176,12 +154,19 @@ export const cacheToolInputDefinition = (params: {
154 const schemaPath = toolDefinitionPath(path, cacheDir, params.slug);
155
156 yield* ensureToolDefinitionsDir(fs, path, cacheDir);
179 - return yield* writeCachedToolInputDefinition({
180 - fs,
157 + yield* fs.writeFileString(
158 + schemaPath,
159 + serializeCachedToolDefinition({
160 + version: params.version ?? null,
161 + inputSchema: params.schema,
162 + })
163 + );
164 +
165 + return {
166 schemaPath,
167 schema: params.schema,
168 version: params.version ?? null,
184 - });
169 + };
170 });
171
172 export const invalidateToolInputDefinition = (slug: string) =>
@@ -240,12 +225,18 @@ const fetchAndCacheToolInputDefinition = (
225 yield* ensureToolDefinitionsDir(fs, path, cacheDir);
226
227 if (localDefinition) {
243 - return yield* writeCachedToolInputDefinition({
244 - fs,
228 + yield* fs.writeFileString(
229 + schemaPath,
230 + serializeCachedToolDefinition({
231 + version: localDefinition.version,
232 + inputSchema: localDefinition.schema,
233 + })
234 + );
235 + return {
236 schemaPath,
237 schema: localDefinition.schema,
238 version: localDefinition.version,
248 - });
239 + };
240 }
241
242 const [tool, latestVersion] = yield* Effect.all(
@@ -273,7 +264,15 @@ const fetchAndCacheToolInputDefinition = (
264 resolvedVersion: version,
265 cachePath: schemaPath,
266 });
276 - return yield* writeCachedToolInputDefinition({ fs, schemaPath, schema, version });
267 + yield* fs.writeFileString(
268 + schemaPath,
269 + serializeCachedToolDefinition({
270 + version,
271 + inputSchema: schema,
272 + })
273 + );
274 +
275 + return { schemaPath, schema, version };
276 });
277
278 export const getOrFetchToolInputDefinition = (
ts/packages/cli/test/src/commands/tools/tools.search.cmd.test.ts
+1 -83
@@ -1,13 +1,10 @@
1 import { describe, expect, layer } from '@effect/vitest';
2 +import { ConfigProvider, Effect } from 'effect';
3 import type {
4 SessionCreateParams,
5 SessionSearchParams,
5 - SessionSearchResponse,
6 } from '@composio/client/resources/tool-router';
7 -import { ConfigProvider, Effect, Option } from 'effect';
8 -import { afterEach, vi } from 'vitest';
7 import { extendConfigProvider } from 'src/services/config';
10 -import * as consumerShortTermCache from 'src/services/consumer-short-term-cache';
8 import { cli, TestLive, MockConsole } from 'test/__utils__';
9 import type { TestLiveInput } from 'test/__utils__/services/test-layer';
10 import type { Tools } from 'src/models/tools';
@@ -101,10 +98,6 @@ const extractFirstJsonObject = (output: string): Record<string, unknown> | null
98 };
99
100 describe('CLI: composio search', () => {
104 - afterEach(() => {
105 - vi.restoreAllMocks();
106 - });
107 -
101 layer(TestLive(testLiveOptions))('[Given] a blank query [Then] typed validation fails', it => {
102 it.scoped('returns the structured missing-query error', () =>
103 Effect.gen(function* () {
@@ -206,81 +199,6 @@ describe('CLI: composio search', () => {
199 }
200 );
201
209 - layer(TestLive(testLiveOptions))(
210 - '[Given] a fresh cache and a custom toolkit miss [Then] search refreshes and retries once',
211 - it => {
212 - it.scoped('refreshes only after the requested custom toolkit is absent', () =>
213 - Effect.gen(function* () {
214 - const customSlug = 'CUSTOM_DEEPWIKI_READ_WIKI_CONTENTS';
215 - let searchCalls = 0;
216 - const refreshSpy = vi
217 - .spyOn(consumerShortTermCache, 'refreshConsumerConnectedToolkitsCache')
218 - .mockReturnValue(Effect.void);
219 - vi.spyOn(consumerShortTermCache, 'getFreshConsumerConnectedToolkitsFromCache').mockReturnValue(
220 - Effect.succeed(Option.some(['CUSTOM_DEEPWIKI']))
221 - );
222 -
223 - const live = TestLive({
224 - ...testLiveOptions,
225 - toolRouter: {
226 - search: async (_sessionId, params) => {
227 - searchCalls += 1;
228 - const found = searchCalls === 2;
229 - const toolSchemas: SessionSearchResponse['tool_schemas'] = found
230 - ? {
231 - [customSlug]: {
232 - tool_slug: customSlug,
233 - toolkit: 'CUSTOM_DEEPWIKI',
234 - description: 'Read wiki contents',
235 - hasFullSchema: true,
236 - input_schema: { type: 'object', properties: {} },
237 - output_schema: { type: 'object', properties: {} },
238 - },
239 - }
240 - : {};
241 - return {
242 - success: true,
243 - error: null,
244 - results: [
245 - {
246 - index: 1,
247 - use_case: params.queries[0]?.use_case ?? '',
248 - primary_tool_slugs: found ? [customSlug] : [],
249 - related_tool_slugs: [],
250 - toolkits: found ? ['CUSTOM_DEEPWIKI'] : [],
251 - },
252 - ],
253 - tool_schemas: toolSchemas,
254 - toolkit_connection_statuses: [],
255 - next_steps_guidance: [],
256 - session: {
257 - id: 'trs_test_session',
258 - generate_id: false,
259 - instructions: 'Reuse this session id for follow-up calls.',
260 - },
261 - time_info: {
262 - current_time_utc: '2026-01-01T00:00:00.000Z',
263 - current_time_utc_epoch_seconds: 1767225600,
264 - message: 'UTC time',
265 - },
266 - };
267 - },
268 - },
269 - });
270 -
271 - yield* cli(['search', 'read wiki contents', '--toolkits', 'CUSTOM_DEEPWIKI']).pipe(
272 - Effect.provide(live)
273 - );
274 -
275 - expect(searchCalls).toBe(2);
276 - expect(refreshSpy).toHaveBeenCalledOnce();
277 - const output = (yield* MockConsole.getLines({ stripAnsi: true })).join('\n');
278 - expect(output).toContain(customSlug);
279 - })
280 - );
281 - }
282 - );
283 -
202 layer(TestLive(testLiveOptions))(
203 '[Given] multiple queries [Then] the CLI returns a batched JSON response',
204 it => {