The Open Framework for Building Agents
fix(eve): preserve optional tool fields at the model provider boundary (#3729)
Vanessa Teo32cd5b92de05
diff --git a/.changeset/optional-tool-fields.md b/.changeset/optional-tool-fields.mdnew file mode 100644index 000000000..0cffd23b9--- /dev/null+++ b/.changeset/optional-tool-fields.md@@ -0,0 +1,5 @@+---+"eve": patch+---++Preserve optional function-tool inputs by explicitly disabling provider strict mode. This prevents OpenAI Responses from implicitly requiring optional fields in authored and connection tool schemas.diff --git a/docs/tools/overview.mdx b/docs/tools/overview.mdxindex e1770750a..88bdbf709 100644--- a/docs/tools/overview.mdx+++ b/docs/tools/overview.mdx@@ -39,6 +39,8 @@ eve validates the model's input against `inputSchema` before `execute` runs:- eve treats `format` as an annotation and does not reject input for it.- When eve cannot evaluate a JSON Schema locally, for example because of an unknown `type` name or a `$ref` it cannot resolve, the model still receives the schema and eve passes the input to `execute` unvalidated.+Optional input fields remain optional for authored tools and connection tools. eve explicitly disables provider strict mode for function tools so providers such as OpenAI Responses do not implicitly require every property. Local input validation still follows the tool's schema.+### Hide a tool from delegated agentsSet `availableInSubagents: false` when a tool should be callable only in a top-level root session:diff --git a/packages/eve/src/harness/tools-schema.integration.test.ts b/packages/eve/src/harness/tools-schema.integration.test.tsnew file mode 100644index 000000000..79bffdb1b--- /dev/null+++ b/packages/eve/src/harness/tools-schema.integration.test.ts@@ -0,0 +1,117 @@+import { asSchema, generateText } from "ai";+import { describe, expect, it, vi } from "vitest";+import { z } from "zod";++import { createOpenAI } from "#compiled/@ai-sdk/openai/index.js";+import { buildToolSet } from "#harness/tools.js";+import { toInputSchema } from "#tools/schema.js";++const inputSchema = {+ type: "object",+ properties: {+ query: { type: "string" },+ customView: { type: "string", minLength: 1 },+ filters: {+ type: "object",+ properties: {+ team: { type: "string" },+ state: { type: "string" },+ },+ required: ["team"],+ additionalProperties: false,+ },+ },+ required: ["query"],+ additionalProperties: false,+} as const;++interface RecordedRequest {+ readonly tools: Array<{+ readonly name: string;+ readonly strict?: boolean;+ readonly parameters: unknown;+ }>;+}++describe("tool schemas at the model provider boundary", () => {+ it.each([+ {+ name: "MCP JSON Schema",+ schema: () => toInputSchema(inputSchema),+ },+ {+ name: "authored Zod schema",+ schema: () =>+ z.object({+ query: z.string(),+ customView: z.string().min(1).optional(),+ filters: z.object({ team: z.string(), state: z.string().optional() }).optional(),+ }),+ },+ ])("preserves optional fields in $name through OpenAI Responses", async ({ schema }) => {+ const requests: RecordedRequest[] = [];+ const model = createOpenAI({+ apiKey: "test-key",+ fetch: async (_url, init) => {+ requests.push(JSON.parse(String(init?.body)));+ return Response.json({+ id: "resp_1",+ created_at: 0,+ model: "gpt-5.4",+ status: "completed",+ output: [+ {+ type: "function_call",+ id: "fc_1",+ call_id: "call_1",+ name: "linear__list_issues",+ arguments: JSON.stringify({ query: "sandbox error" }),+ },+ ],+ usage: { input_tokens: 1, output_tokens: 1, total_tokens: 2 },+ });+ },+ }).responses("gpt-5.4");+ const execute = vi.fn(async (_input: unknown) => ({ issues: [] }));+ const tools = buildToolSet({+ tools: new Map([+ [+ "linear__list_issues",+ {+ name: "linear__list_issues",+ description: "Search issues by query or saved custom view.",+ inputSchema: schema(),+ execute,+ },+ ],+ ]),+ });++ await generateText({+ model,+ tools,+ prompt: "Find issues about sandbox errors.",+ maxRetries: 0,+ });++ expect(requests).toHaveLength(1);+ expect(requests[0]?.tools).toEqual([+ expect.objectContaining({+ name: "linear__list_issues",+ strict: false,+ parameters: inputSchema,+ }),+ ]);+ expect(execute).toHaveBeenCalledOnce();+ expect(execute.mock.calls[0]?.[0]).toEqual({ query: "sandbox error" });++ const validation = asSchema(tools.linear__list_issues!.inputSchema).validate!;+ for (const input of [+ {},+ { query: "sandbox error", customView: "" },+ { query: "error", filters: {} },+ ]) {+ expect(await validation(input)).toMatchObject({ success: false });+ }+ });+});diff --git a/packages/eve/src/harness/tools.ts b/packages/eve/src/harness/tools.tsindex 67a0e953b..86e0cb87d 100644--- a/packages/eve/src/harness/tools.ts+++ b/packages/eve/src/harness/tools.ts@@ -76,6 +76,7 @@ export function buildToolSet(input: {description: definition.description,execute: wrapToolExecute(definition, backgroundBatch),inputSchema: toModelSchema(definition.inputSchema, "input"),+ strict: false,...(definition.execution === "background"? {onInputAvailable: ({