diff --git a/src/agents/bee/runner.ts b/src/agents/bee/runner.ts index 509aae09..60b0f58a 100644 --- a/src/agents/bee/runner.ts +++ b/src/agents/bee/runner.ts @@ -180,7 +180,10 @@ export class BeeAgentRunner { prefix: "Function Name:", next: ["tool_input"], field: new ZodParserField( - z.enum(tools.map((tool) => tool.name) as [string, ...string[]]), + z.pipeline( + z.string().trim(), + z.enum(tools.map((tool) => tool.name) as [string, ...string[]]), + ), ), }, tool_input: { diff --git a/src/agents/parsers/field.test.ts b/src/agents/parsers/field.test.ts index acd9dd33..b00c2285 100644 --- a/src/agents/parsers/field.test.ts +++ b/src/agents/parsers/field.test.ts @@ -94,6 +94,16 @@ describe("Parser Fields", () => { }); describe("Zod", () => { + it("Enum", async () => { + const values = { + apple: "apple", + }; + const field = new ZodParserField(z.pipeline(z.string().trim(), z.nativeEnum(values))); + field.write(" apple\n"); + await field.end(); + expect(field.get()).toBe(values.apple); + }); + it("Number", async () => { const field = new ZodParserField(z.coerce.number().int()); expect(field.getPartial()).toBe("");