Skip to content

Commit b85e6e3

Browse files
authored
fix(tools): tool call name must be a valid python variable name (#1466)
1 parent 0bd9dd3 commit b85e6e3

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/lib/server/tools/index.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,11 @@ const toolInputSchema = toolInputBaseSchema.and(
6969

7070
export const editableToolSchema = z
7171
.object({
72-
name: z.string().min(1).max(40),
72+
name: z
73+
.string()
74+
.regex(/^[a-zA-Z_][a-zA-Z0-9_]*$/) // only allow letters, numbers, and underscores, and start with a letter or underscore
75+
.min(1)
76+
.max(40),
7377
// only allow huggingface spaces either through namespace or direct URLs
7478
baseUrl: z.union([
7579
z.string().regex(/^[^/]+\/[^/]+$/),

0 commit comments

Comments
 (0)