@devries-cameron20 / composio-1 / commits / 7ed76f97f
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.

fix(cli): resolve custom schemas through tool router

shams haroon committed Aug 20, 2026 at 16:16 UTC 7ed76f97fcfe449f744bdb6d27c245d51ca8dda1
2 files changed +124 -1
ts/packages/cli/src/commands/tools/commands/tools.search.cmd.ts
+39 -1
@@ -388,8 +388,46 @@ const runToolsSearch = (params: {
388 cause,
389 }),
390 });
391 + const customToolSlugsMissingSchemas = Object.entries(searchResponse.tool_schemas)
392 + .filter(
393 + ([slug, schema]) =>
394 + isRemoteCustomToolSlug(slug) && !schema.input_schema
395 + )
396 + .map(([slug]) => slug);
397 + const hydratedSearchResponse =
398 + customToolSlugsMissingSchemas.length === 0
399 + ? searchResponse
400 + : yield* Effect.tryPromise({
401 + try: async () => {
402 + const schemaResponse = await client.toolRouter.session.executeMeta(sessionId, {
403 + slug: 'COMPOSIO_GET_TOOL_SCHEMAS',
404 + arguments: { tool_slugs: customToolSlugsMissingSchemas },
405 + });
406 + if (schemaResponse.error) {
407 + throw new Error(schemaResponse.error);
408 + }
409 +
410 + const resolvedSchemas = schemaResponse.data.tool_schemas;
411 + if (!resolvedSchemas || typeof resolvedSchemas !== 'object') {
412 + throw new Error('Tool Router returned no tool schemas.');
413 + }
414 +
415 + return {
416 + ...searchResponse,
417 + tool_schemas: {
418 + ...searchResponse.tool_schemas,
419 + ...(resolvedSchemas as Record<string, SearchToolSchema>),
420 + },
421 + };
422 + },
423 + catch: cause =>
424 + new ToolsSearchRequestError({
425 + message: 'Failed to fetch custom tool schemas.',
426 + cause,
427 + }),
428 + });
429 return {
392 - searchResponse,
430 + searchResponse: hydratedSearchResponse,
431 projectScope: {
432 orgId: resolvedProject.orgId,
433 projectId: resolvedProject.projectId,
ts/packages/cli/test/src/commands/tools/tools.search.cmd.test.ts
+85
@@ -199,6 +199,91 @@ describe('CLI: composio search', () => {
199 }
200 );
201
202 + layer(TestLive(testLiveOptions))(
203 + '[Given] a remote custom tool schema reference [Then] search resolves it with the Tool Router meta-tool',
204 + it => {
205 + it.scoped('does not use the legacy tools endpoint for schema references', () =>
206 + Effect.gen(function* () {
207 + const customSlug = 'CUSTOM_DEEPWIKI_READ_WIKI_CONTENTS';
208 + let schemaRequestSlugs: unknown;
209 + const live = TestLive({
210 + ...testLiveOptions,
211 + toolRouter: {
212 + search: async (_sessionId, params) => ({
213 + success: true,
214 + error: null,
215 + results: [
216 + {
217 + index: 1,
218 + use_case: params.queries[0]?.use_case ?? '',
219 + primary_tool_slugs: [customSlug],
220 + related_tool_slugs: [],
221 + toolkits: ['CUSTOM_DEEPWIKI'],
222 + },
223 + ],
224 + tool_schemas: {
225 + [customSlug]: {
226 + tool_slug: customSlug,
227 + toolkit: 'CUSTOM_DEEPWIKI',
228 + description: 'Read wiki contents',
229 + hasFullSchema: false,
230 + schemaRef: {
231 + tool: 'COMPOSIO_GET_TOOL_SCHEMAS',
232 + args: { tool_slugs: [customSlug] },
233 + },
234 + },
235 + },
236 + toolkit_connection_statuses: [],
237 + next_steps_guidance: [],
238 + session: {
239 + id: 'trs_test_session',
240 + generate_id: false,
241 + instructions: 'Reuse this session id for follow-up calls.',
242 + },
243 + time_info: {
244 + current_time_utc: '2026-01-01T00:00:00.000Z',
245 + current_time_utc_epoch_seconds: 1767225600,
246 + message: 'UTC time',
247 + },
248 + }),
249 + executeMeta: async (_sessionId, params) => {
250 + schemaRequestSlugs = params.arguments?.tool_slugs;
251 + return {
252 + data: {
253 + success: true,
254 + tool_schemas: {
255 + [customSlug]: {
256 + tool_slug: customSlug,
257 + toolkit: 'CUSTOM_DEEPWIKI',
258 + description: 'Read wiki contents',
259 + input_schema: {
260 + type: 'object',
261 + properties: { repo: { type: 'string' } },
262 + required: ['repo'],
263 + },
264 + },
265 + },
266 + },
267 + error: null,
268 + log_id: 'log_test',
269 + };
270 + },
271 + },
272 + });
273 +
274 + yield* cli(['search', 'read wiki contents']).pipe(Effect.provide(live));
275 + const output = (yield* MockConsole.getLines({ stripAnsi: true })).join('\n');
276 +
277 + expect(output).toContain(customSlug);
278 + expect(schemaRequestSlugs).toEqual([customSlug]);
279 + expect(output).toContain(
280 + `~/.composio/tool_definitions/${customSlug}.json`
281 + );
282 + })
283 + );
284 + }
285 + );
286 +
287 layer(TestLive(testLiveOptions))(
288 '[Given] multiple queries [Then] the CLI returns a batched JSON response',
289 it => {