Skip to content

armgit / eve

Public Imported from GitHub
0

The Open Framework for Building Agents

fix(eve): drop model values for provided connection arguments before validation (#4652)

roboeve[bot]8f50d9dab921
diff --git a/.changeset/connection-provided-argument-model-value.md b/.changeset/connection-provided-argument-model-value.md
new file mode 100644
index 000000000..53ac7bb72
--- /dev/null
+++ b/.changeset/connection-provided-argument-model-value.md
@@ -0,0 +1,5 @@
+---
+"eve": patch
+---
+
+A connection tool call no longer fails with `Unrecognized key` when the model sends a key the connection supplies through `toolCall.providedArguments`. eve drops the model's value and the provided value is used, as documented.
diff --git a/packages/eve/src/execution/catalog/connection-entry.ts b/packages/eve/src/execution/catalog/connection-entry.ts
index 2bfbab087..0a78d66d2 100644
--- a/packages/eve/src/execution/catalog/connection-entry.ts
+++ b/packages/eve/src/execution/catalog/connection-entry.ts
@@ -206,8 +206,13 @@ async function checkCall(
if (tool === undefined) {
return { issues: [{ message: unknownToolMessage(connection, toolName, tools) }] };
}
+ // Provided values replace these keys at execution, so a model value for one is dropped, not rejected.
+ const provided = connection.toolCall?.providedArguments ?? {};
+ const modelInput = Object.fromEntries(
+ Object.entries(isObject(input) ? input : {}).filter(([key]) => !Object.hasOwn(provided, key)),
+ );
const result = await defineJsonSchema(tool.inputSchema as JsonObject)["~standard"].validate(
- isObject(input) ? input : {},
+ modelInput,
);
if (result.issues === undefined) return { input: result.value as JsonObject, tool };
return {
diff --git a/packages/eve/src/execution/catalog/step-catalog.test.ts b/packages/eve/src/execution/catalog/step-catalog.test.ts
index de169c753..2b8358d91 100644
--- a/packages/eve/src/execution/catalog/step-catalog.test.ts
+++ b/packages/eve/src/execution/catalog/step-catalog.test.ts
@@ -554,6 +554,33 @@ describe("buildStepCatalog", () => {
expect(linear.calls).toEqual([]);
});
+ it("accepts a key the connection provides when the model sends it anyway, since the provided value replaces it", async () => {
+ // Listed without `env`, as connection clients omit provided keys from the schemas they list.
+ const nova = fakeConnection({
+ name: "nova",
+ toolCall: { providedArguments: { env: "prod" } },
+ tools: [
+ connectionTool("loki_logs", {
+ type: "object",
+ properties: { logql: { type: "string" } },
+ required: ["logql"],
+ additionalProperties: false,
+ }),
+ ],
+ });
+ const { catalog, run } = catalogContext({ connections: [nova] });
+ const call = { input: { env: "staging", logql: '{app="api"}' }, name: "nova__loki_logs" };
+
+ expect(await validateTool(catalog, call)).toEqual({
+ value: { input: { logql: '{app="api"}' }, name: "nova__loki_logs" },
+ });
+ const resolved = catalog.resolve({ input: call, toolName: CALL_TOOL_NAME });
+ await run(() =>
+ resolved?.definition.execute?.(resolved.call.input, { messages: [], toolCallId: "call-1" }),
+ );
+ expect(nova.calls).toEqual([{ input: { logql: '{app="api"}' }, tool: "loki_logs" }]);
+ });
+
it.each([
[
"an unknown tool, with the connection's closest tools",
diff --git a/packages/eve/src/internal/testing/catalog-fixtures.ts b/packages/eve/src/internal/testing/catalog-fixtures.ts
index 38bc08462..2da6abab9 100644
--- a/packages/eve/src/internal/testing/catalog-fixtures.ts
+++ b/packages/eve/src/internal/testing/catalog-fixtures.ts
@@ -160,6 +160,7 @@ export function fakeConnection(input: {
readonly name: string;
readonly rejectsToken?: boolean;
readonly signIn?: boolean;
+ readonly toolCall?: ResolvedConnectionDefinition["toolCall"];
readonly tools: readonly ConnectionToolMetadata[];
}): FakeConnection {
const calls: FakeConnection["calls"] = [];
@@ -172,6 +173,7 @@ export function fakeConnection(input: {
protocol: "mcp",
sourceId: `connections/${input.name}.ts`,
sourceKind: "module",
+ toolCall: input.toolCall,
url: `https://${input.name}.example.com/mcp`,
};
const connection: FakeConnection = {