The Open Framework for Building Agents
fix(eve): stop streaming input for provider tools like web_search (#4610)
roboeve[bot]15177c6fe25d
diff --git a/.changeset/gateway-web-search-input-part.md b/.changeset/gateway-web-search-input-part.mdnew file mode 100644index 000000000..4f1555620--- /dev/null+++ b/.changeset/gateway-web-search-input-part.md@@ -0,0 +1,5 @@+---+"eve": patch+---++Fix a second, never-settling `web_search` part under AI Gateway. eve no longer streams input for provider tools such as `web_search`, so each search shows up once, under the call id it runs and settles with.diff --git a/packages/eve/src/harness/emission.test.ts b/packages/eve/src/harness/emission.test.tsindex 923f1d310..e3508a970 100644--- a/packages/eve/src/harness/emission.test.ts+++ b/packages/eve/src/harness/emission.test.ts@@ -174,6 +174,61 @@ describe("emitStreamContent action requests", () => {expect(emit).not.toHaveBeenCalled();});+ it("does not stream input for a provider tool whose input start is unflagged", async () => {+ const events: Parameters<HarnessEmitFn>[0][] = [];+ const emit: HarnessEmitFn = async (event) => {+ events.push(event);+ };++ // AI Gateway streams the model's input under one id, then runs the search under another.+ await emitStreamContent(+ emit,+ EMISSION_STATE,+ streamOf([+ { id: "call-model", toolName: "web_search", type: "tool-input-start" },+ { delta: '{"query":"eve"}', id: "call-model", type: "tool-input-delta" },+ { id: "call-model", type: "tool-input-end" },+ {+ input: { query: "eve" },+ providerExecuted: true,+ toolCallId: "call-gateway",+ toolName: "web_search",+ type: "tool-call",+ },+ {+ input: { query: "eve" },+ output: { results: [] },+ providerExecuted: true,+ toolCallId: "call-gateway",+ toolName: "web_search",+ type: "tool-result",+ },+ { finishReason: "stop", type: "finish-step" },+ ] as TextStreamPart<ToolSet>[]),+ {+ excludedActionToolNames: new Set(),+ tools: new Map([+ [+ "web_search",+ {+ behavior: { availability: [], handling: { kind: "provider-tool", provider: "exa" } },+ description: "Search the web.",+ inputSchema: jsonSchema({ type: "object" }),+ name: "web_search",+ },+ ],+ ]),+ },+ );++ expect(events.filter((event) => event.type === "action.input.appended")).toEqual([]);+ expect(+ events+ .filter((event) => event.type === "actions.requested")+ .flatMap((event) => event.data.actions.map((action) => action.callId)),+ ).toEqual(["call-gateway"]);+ });+it("cancels a pending provider action batch when the stream aborts", async () => {vi.useFakeTimers();const emit = createEmitStub();diff --git a/packages/eve/src/harness/emission.ts b/packages/eve/src/harness/emission.tsindex 5d20492eb..41874d127 100644--- a/packages/eve/src/harness/emission.ts+++ b/packages/eve/src/harness/emission.ts@@ -364,6 +364,8 @@ async function consumeStreamContent(if (options === undefined ||part.providerExecuted === true ||+ // AI Gateway streams a provider tool's input unflagged, under an id its call never uses.+ options.tools.get(part.toolName)?.behavior?.handling?.kind === "provider-tool" ||options.excludedActionToolNames.has(part.toolName)) {streamingActionInputs.delete(part.id);