Skip to content

armgit / eve

Public Imported from GitHub
0

The Open Framework for Building Agents

fix(eve): avoid agent router propertyNames (#3525)

Casey Gowrie8a21c0cc9f6a
diff --git a/.changeset/avoid-router-property-names.md b/.changeset/avoid-router-property-names.md
new file mode 100644
index 000000000..622048065
--- /dev/null
+++ b/.changeset/avoid-router-property-names.md
@@ -0,0 +1,5 @@
+---
+"eve": patch
+---
+
+`agentRouter()` now advertises model-supplied output schemas as permissive objects, avoiding unsupported JSON Schema `propertyNames` warnings on OpenAI models while preserving downstream object validation.
diff --git a/docs/tools/workflows.mdx b/docs/tools/workflows.mdx
index 81a22e4ef..b105ec900 100644
--- a/docs/tools/workflows.mdx
+++ b/docs/tools/workflows.mdx
@@ -421,7 +421,9 @@ import { agentRouter } from "eve/tools/agent-router";
export default agentRouter();
```
-Its input is `{ message: string, outputSchema?: object }`. `agentRouter()` ignores entries without a non-empty description. With two or more described targets, it sends the message and effective descriptions to JEV, then invokes the selected name through `ctx.agent()`. It invokes a sole target without evaluation and forwards an optional `outputSchema`. In a top-level root session, the candidates include the root-copy `agent`; delegated root copies and declared subagent contexts include only their declared targets.
+Its input is `{ message: string, outputSchema?: object }`. `agentRouter()` ignores entries without a non-empty description. With two or more described targets, it sends the message and effective descriptions to JEV, then invokes the selected name through `ctx.agent()`. It invokes a sole target without evaluation and forwards an optional `outputSchema` unchanged. In a top-level root session, the candidates include the root-copy `agent`; delegated root copies and declared subagent contexts include only their declared targets.
+
+When an authored tool accepts a JSON Schema supplied by the model, represent that input with a permissive object such as `z.looseObject({})`. Avoid `z.record(z.string(), z.json())`: its generated JSON Schema uses `propertyNames`, which OpenAI does not support. Validate the supplied value at the point where your tool consumes it.
This pattern controls specialist selection, not whether the parent model delegates at all. Route before the parent model runs if every incoming request must go through JEV.
diff --git a/packages/eve/src/execution/tools/agent-router.ts b/packages/eve/src/execution/tools/agent-router.ts
index d3926f1a7..c9e8fb203 100644
--- a/packages/eve/src/execution/tools/agent-router.ts
+++ b/packages/eve/src/execution/tools/agent-router.ts
@@ -13,8 +13,11 @@ export interface AgentRouterInput {
export const AGENT_ROUTER_INPUT_SCHEMA: z.ZodType<AgentRouterInput> = z.strictObject({
message: z.string().min(1).describe("The complete task to send to the selected agent."),
- outputSchema: z
- .record(z.string(), z.json())
- .describe("Optional JSON Schema the selected agent's output must match.")
- .optional(),
+ outputSchema: (
+ z
+ .looseObject({})
+ .describe(
+ "Only provide a non-empty JSON Schema when the caller explicitly requests structured output; otherwise omit this field. The selected agent must match a provided schema, and that structured output becomes the tool result.",
+ ) as z.ZodType<JsonObject>
+ ).optional(),
});
diff --git a/packages/eve/src/execution/tools/subagent/invoke-agent.test.ts b/packages/eve/src/execution/tools/subagent/invoke-agent.test.ts
index 90858f994..803d37271 100644
--- a/packages/eve/src/execution/tools/subagent/invoke-agent.test.ts
+++ b/packages/eve/src/execution/tools/subagent/invoke-agent.test.ts
@@ -53,6 +53,16 @@ describe("agent invocation input", () => {
"agent() requires a non-empty agent name as its first argument.",
);
});
+
+ it.each([null, [], "object"])("rejects a non-object output schema (%j)", (outputSchema) => {
+ expect(() =>
+ validateAgentInput({
+ message: "Review",
+ outputSchema: outputSchema as never,
+ target: "reviewer",
+ }),
+ ).toThrow("agent() `outputSchema` must be a JSON Schema object.");
+ });
});
describe("background agent invocation routing", () => {
diff --git a/packages/eve/src/execution/tools/subagent/invoke-agent.ts b/packages/eve/src/execution/tools/subagent/invoke-agent.ts
index 026b34fff..32973a3f9 100644
--- a/packages/eve/src/execution/tools/subagent/invoke-agent.ts
+++ b/packages/eve/src/execution/tools/subagent/invoke-agent.ts
@@ -186,4 +186,12 @@ export function validateAgentInput(input: InternalAgentInput): void {
if (typeof input.message !== "string" || input.message.trim() === "") {
throw new TypeError("agent() requires a non-empty `message`.");
}
+ if (
+ input.outputSchema !== undefined &&
+ (typeof input.outputSchema !== "object" ||
+ input.outputSchema === null ||
+ Array.isArray(input.outputSchema))
+ ) {
+ throw new TypeError("agent() `outputSchema` must be a JSON Schema object.");
+ }
}
diff --git a/packages/eve/src/tools/provided/agent-router.test.ts b/packages/eve/src/tools/provided/agent-router.test.ts
index ce1e12110..c22f6c546 100644
--- a/packages/eve/src/tools/provided/agent-router.test.ts
+++ b/packages/eve/src/tools/provided/agent-router.test.ts
@@ -1,8 +1,12 @@
import { beforeEach, describe, expect, it, vi } from "vitest";
import { agentRouter } from "#tools/provided/agent-router.js";
-import { executeAgentRouterTool } from "#execution/tools/agent-router.js";
+import {
+ AGENT_ROUTER_INPUT_SCHEMA,
+ executeAgentRouterTool,
+} from "#execution/tools/agent-router.js";
import { evaluate } from "#ai/evaluate.js";
+import { serializeInputSchema } from "#tools/schema.js";
import type { WorkflowToolContext } from "#tools/workflow-definition.js";
vi.mock("#ai/evaluate.js", () => ({ evaluate: vi.fn() }));
@@ -18,6 +22,25 @@ describe("agentRouter", () => {
expect(definition.execute).toBe(executeAgentRouterTool);
});
+ it("advertises arbitrary output schemas without propertyNames", () => {
+ const serialized = serializeInputSchema(AGENT_ROUTER_INPUT_SCHEMA);
+
+ expect(serialized).toMatchObject({
+ properties: { outputSchema: { type: "object" } },
+ });
+ expect(JSON.stringify(serialized)).not.toContain('"propertyNames"');
+ expect(() =>
+ AGENT_ROUTER_INPUT_SCHEMA.parse({
+ message: "Return a structured result",
+ outputSchema: {
+ $defs: { answer: { type: "string" } },
+ properties: { answer: { $ref: "#/$defs/answer" } },
+ type: "object",
+ },
+ }),
+ ).not.toThrow();
+ });
+
it("routes through all workflow agent descriptions", async () => {
vi.mocked(evaluate).mockResolvedValue({
answers: { route: { choice: "operator", type: "choice" } },