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
If a user registers tools FOO and LOCAL_FOO, the prefixed slug for FOO (LOCAL_FOO) collides with the original slug of LOCAL_FOO in the routing maps. Reject slugs starting with LOCAL_ at creation time since the prefix is reserved for internal routing. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Dhawal Upadhyay committed
Mar 10, 2026 at 18:50 UTC
b4a62f6999214fe11462ee5f52c48b43a6e438bd
2 files changed
+17
ts/packages/core/src/models/CustomTool.ts
+5
@@ -95,6 +95,11 @@ export function CustomTool<T extends z.ZodType>(
95
if (!slug) {
96
throw new Error('CustomTool: slug is required');
97
}
98
+ if (slug.toUpperCase().startsWith(LOCAL_TOOL_PREFIX)) {
99
+ throw new Error(
100
+ `CustomTool: slug must not start with "${LOCAL_TOOL_PREFIX}" — this prefix is reserved for internal routing.`
101
+ );
102
+ }
103
if (!name) {
104
throw new Error('CustomTool: name is required');
105
}
ts/packages/core/test/models/customTool.test.ts
+12
@@ -82,6 +82,18 @@ describe('CustomTool', () => {
82
expect(() => CustomTool({ ...baseOptions, slug: '' })).toThrow('slug is required');
83
});
84
85
+ it('should throw if slug starts with LOCAL_ prefix', () => {
86
+ expect(() => CustomTool({ ...baseOptions, slug: 'LOCAL_MY_TOOL' })).toThrow(
87
+ 'must not start with "LOCAL_"'
88
+ );
89
+ });
90
+
91
+ it('should throw if slug starts with local_ prefix (case-insensitive)', () => {
92
+ expect(() => CustomTool({ ...baseOptions, slug: 'local_something' })).toThrow(
93
+ 'must not start with "LOCAL_"'
94
+ );
95
+ });
96
+
97
it('should throw if name is missing', () => {
98
expect(() => CustomTool({ ...baseOptions, name: '' })).toThrow('name is required');
99
});