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): reject LOCAL_ prefix in CustomTool slugs to prevent routing collision

Dhawal Upadhyayb4a62f699921
diff --git a/ts/packages/core/src/models/CustomTool.ts b/ts/packages/core/src/models/CustomTool.ts
index f2f8fe4d6..5016afa3f 100644
--- a/ts/packages/core/src/models/CustomTool.ts
+++ b/ts/packages/core/src/models/CustomTool.ts
@@ -95,6 +95,11 @@ export function CustomTool<T extends z.ZodType>(
if (!slug) {
throw new Error('CustomTool: slug is required');
}
+ if (slug.toUpperCase().startsWith(LOCAL_TOOL_PREFIX)) {
+ throw new Error(
+ `CustomTool: slug must not start with "${LOCAL_TOOL_PREFIX}" — this prefix is reserved for internal routing.`
+ );
+ }
if (!name) {
throw new Error('CustomTool: name is required');
}
diff --git a/ts/packages/core/test/models/customTool.test.ts b/ts/packages/core/test/models/customTool.test.ts
index 255a7d8ec..5b56c4266 100644
--- a/ts/packages/core/test/models/customTool.test.ts
+++ b/ts/packages/core/test/models/customTool.test.ts
@@ -82,6 +82,18 @@ describe('CustomTool', () => {
expect(() => CustomTool({ ...baseOptions, slug: '' })).toThrow('slug is required');
});
+ it('should throw if slug starts with LOCAL_ prefix', () => {
+ expect(() => CustomTool({ ...baseOptions, slug: 'LOCAL_MY_TOOL' })).toThrow(
+ 'must not start with "LOCAL_"'
+ );
+ });
+
+ it('should throw if slug starts with local_ prefix (case-insensitive)', () => {
+ expect(() => CustomTool({ ...baseOptions, slug: 'local_something' })).toThrow(
+ 'must not start with "LOCAL_"'
+ );
+ });
+
it('should throw if name is missing', () => {
expect(() => CustomTool({ ...baseOptions, name: '' })).toThrow('name is required');
});