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(core): omit absent inline custom fields

Abir Taheerb0f005ca143d
diff --git a/ts/packages/core/src/models/ToolRouter.ts b/ts/packages/core/src/models/ToolRouter.ts
index c86a04d0e..0d7e21c66 100644
--- a/ts/packages/core/src/models/ToolRouter.ts
+++ b/ts/packages/core/src/models/ToolRouter.ts
@@ -265,8 +265,8 @@ export class ToolRouter<
: undefined;
inlineCustomToolsPayload = {
- custom_tools: serializedTools,
- custom_toolkits: serializedToolkits,
+ ...(serializedTools ? { custom_tools: serializedTools } : {}),
+ ...(serializedToolkits ? { custom_toolkits: serializedToolkits } : {}),
};
}
diff --git a/ts/packages/core/test/models/toolRouter.test.ts b/ts/packages/core/test/models/toolRouter.test.ts
index d8ea676a3..9ec311f87 100644
--- a/ts/packages/core/test/models/toolRouter.test.ts
+++ b/ts/packages/core/test/models/toolRouter.test.ts
@@ -2972,10 +2972,12 @@ describe('ToolRouter', () => {
body: {
experimental: {
custom_tools: [expect.objectContaining({ slug: 'GREP' })],
- custom_toolkits: undefined,
},
},
});
+ expect(mockClient.post.mock.calls[0][1].body.experimental).not.toHaveProperty(
+ 'custom_toolkits'
+ );
expect(mockClient.toolRouter.session.retrieve).not.toHaveBeenCalled();
expect(session.customTools()).toEqual([
expect.objectContaining({