From 0d2bf098bab2f059d6b75016708f23de35e77fda Mon Sep 17 00:00:00 2001 From: Davanum Srinivas Date: Sat, 14 Mar 2026 23:04:29 -0400 Subject: [PATCH] Agent: forward ingress clientTools to embedded runs Pass ingress-supplied `clientTools` into embedded runner executions so the embedded path sees the same tool definitions and preflight validation as direct gateway requests. Add a focused regression test covering the embedded-run path that previously dropped the ingress tool configuration. --- src/agents/pi-embedded-runner/run.ts | 1 + src/commands/agent.test.ts | 20 +++++++++++++++++++- 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/src/agents/pi-embedded-runner/run.ts b/src/agents/pi-embedded-runner/run.ts index bf0413d93b3..be6bf9757e3 100644 --- a/src/agents/pi-embedded-runner/run.ts +++ b/src/agents/pi-embedded-runner/run.ts @@ -961,6 +961,7 @@ export async function runEmbeddedPiAgent( prompt, images: params.images, disableTools: params.disableTools, + clientTools: params.clientTools, onPreflightPassed: params.onPreflightPassed, provider, modelId, diff --git a/src/commands/agent.test.ts b/src/commands/agent.test.ts index 1f098420ace..76e47908e71 100644 --- a/src/commands/agent.test.ts +++ b/src/commands/agent.test.ts @@ -464,11 +464,29 @@ describe("agentCommand", () => { const store = path.join(home, "sessions.json"); mockConfig(home, store); const onPreflightPassed = vi.fn(); + const clientTools = [ + { + type: "function", + function: { + name: "web_search", + description: "test client tool", + parameters: { type: "object", additionalProperties: false, properties: {} }, + }, + }, + ]; await agentCommandFromIngress( - { message: "hi", to: "+1555", senderIsOwner: false, onPreflightPassed }, + { + message: "hi", + to: "+1555", + senderIsOwner: false, + allowModelOverride: false, + clientTools, + onPreflightPassed, + }, runtime, ); const ingressCall = vi.mocked(runEmbeddedPiAgent).mock.calls.at(-1)?.[0]; + expect(ingressCall?.clientTools).toBe(clientTools); expect(ingressCall?.onPreflightPassed).toBe(onPreflightPassed); }); });