π OpenHands: AI-Driven Development
fix(canvas): call agent-server runtime directly instead of /api/cloud-proxy (405 on verification confirm & compact-context) (#17511)
Juan Pedro Michelini Jorge2db9c3b555d6
diff --git a/__tests__/api/agent-server-conversation-service-condense.test.ts b/__tests__/api/agent-server-conversation-service-condense.test.tsindex 926996ea5f..179cc2db34 100644--- a/__tests__/api/agent-server-conversation-service-condense.test.ts+++ b/__tests__/api/agent-server-conversation-service-condense.test.ts@@ -62,7 +62,7 @@ describe("AgentServerConversationService.condenseConversation", () => {__resetActiveStoreForTests();});- it("routes cloud conversations to the runtime condense endpoint with the session key", async () => {+ it("routes cloud conversations straight to the runtime via ConversationClient", async () => {setRegisteredBackends([cloudBackend]);setActiveSelection({ backendId: cloudBackend.id });@@ -72,23 +72,22 @@ describe("AgentServerConversationService.condenseConversation", () => {"sess-key",);- expect(callCloudProxy).toHaveBeenCalledWith(+ // Cloud now calls the runtime host directly (CORS allowlisted), not+ // the /api/cloud-proxy envelope.+ expect(callCloudProxy).not.toHaveBeenCalled();+ expect(ConversationClient).toHaveBeenCalledWith(expect.objectContaining({- backend: cloudBackend,- method: "POST",- hostOverride: buildHttpBaseUrl(RUNTIME_URL),- path: "/api/conversations/conv-1/condense",- authMode: "session-api-key",- sessionApiKey: "sess-key",+ host: buildHttpBaseUrl(RUNTIME_URL),+ apiKey: "sess-key",}),);- expect(mockCondenseConversation).not.toHaveBeenCalled();+ expect(mockCondenseConversation).toHaveBeenCalledWith("conv-1");});- it("throws when a cloud conversation has no runtime URL to proxy to", async () => {- // getEffectiveLocalBackend only resolves when the ACTIVE backend is- // local, so a cloud conversation without a conversation_url has no- // ConversationClient fallback: the proxy path is the only route.+ it("throws when a cloud conversation has no runtime URL to call", async () => {+ // Symmetric with every other cloud runtime call: a missing conversation+ // URL on a cloud backend is a caller bug, surfaced with a specific+ // message rather than the generic NoBackendAvailableError.setRegisteredBackends([cloudBackend, localBackend]);setActiveSelection({ backendId: cloudBackend.id });@@ -98,7 +97,7 @@ describe("AgentServerConversationService.condenseConversation", () => {null,"sess-key",),- ).rejects.toThrow("No backend is configured");+ ).rejects.toThrow(/requires a conversation URL on cloud backends/);expect(callCloudProxy).not.toHaveBeenCalled();expect(mockCondenseConversation).not.toHaveBeenCalled();});diff --git a/__tests__/api/agent-server-conversation-service.test.ts b/__tests__/api/agent-server-conversation-service.test.tsindex d8271f4993..89403346e3 100644--- a/__tests__/api/agent-server-conversation-service.test.ts+++ b/__tests__/api/agent-server-conversation-service.test.ts@@ -1329,7 +1329,7 @@ describe("AgentServerConversationService", () => {it("sends a cloud message with runtime credentials supplied by the caller", async () => {setRegisteredBackends([cloudBackend]);setActiveSelection({ backendId: cloudBackend.id });- const proxyRequests = captureRequests(["post"], {});+ mockSendEvent.mockResolvedValue(undefined);const result = await AgentServerConversationService.sendMessage("conv-cloud",@@ -1342,17 +1342,17 @@ describe("AgentServerConversationService", () => {);// Runtime credentials supplied by the caller: no batch-get is issued,- // only the single cloud-proxy POST to the runtime.- expect(proxyRequests).toHaveLength(1);- const [request] = proxyRequests;- expect(request.url).toBe("http://localhost:54928/api/cloud-proxy");- expect(request.body).toMatchObject({- host: "http://runtime.example",- method: "POST",- path: "/api/conversations/conv-cloud/events",- headers: { "X-Session-API-Key": "session-key" },- body: { ...message, run: true },+ // and the message goes straight to the runtime via ConversationClient+ // (no /api/cloud-proxy envelope).+ expect(mockSendEvent).toHaveBeenCalledWith("conv-cloud", message, {+ run: true,});+ expect(ConversationClient).toHaveBeenCalledWith(+ expect.objectContaining({+ host: "http://runtime.example",+ apiKey: "session-key",+ }),+ );expect(result).toEqual(message);});@@ -1360,6 +1360,7 @@ describe("AgentServerConversationService", () => {setRegisteredBackends([cloudBackend]);setActiveSelection({ backendId: cloudBackend.id });const requests: RecordedRequest[] = [];+ mockSendEvent.mockResolvedValue(undefined);server.use(http.get("https://app.all-hands.dev/api/v1/app-conversations",@@ -1380,27 +1381,23 @@ describe("AgentServerConversationService", () => {]);},),- http.post("*/api/cloud-proxy", async ({ request }) => {- requests.push({- method: request.method,- url: request.url,- headers: Object.fromEntries(request.headers.entries()),- body: await readJsonBody(request),- });- return HttpResponse.json({});- }),);await AgentServerConversationService.sendMessage("conv-cloud", message);+ // The batch-get still resolves runtime credentials from the App API...const batchGet = requests.find((req) => req.method === "GET");- const proxyPost = requests.find(- (req) => req.url === "http://localhost:54928/api/cloud-proxy",- );expect(batchGet?.url).toContain("ids=conv-cloud");- expect(proxyPost?.body).toMatchObject({- host: "http://runtime.example",- headers: { "X-Session-API-Key": "fetched-key" },+ // ...but the send now targets the runtime host directly with the+ // fetched session key (no /api/cloud-proxy POST).+ expect(ConversationClient).toHaveBeenCalledWith(+ expect.objectContaining({+ host: "http://runtime.example",+ apiKey: "fetched-key",+ }),+ );+ expect(mockSendEvent).toHaveBeenCalledWith("conv-cloud", message, {+ run: true,});});@@ -2517,6 +2514,7 @@ describe("AgentServerConversationService", () => {setRegisteredBackends([cloudBackend]);setActiveSelection({ backendId: cloudBackend.id });const requests: RecordedRequest[] = [];+ mockSendEvent.mockResolvedValue(undefined);server.use(http.get("https://app.all-hands.dev/api/v1/app-conversations",@@ -2537,15 +2535,6 @@ describe("AgentServerConversationService", () => {]);},),- http.post("*/api/cloud-proxy", async ({ request }) => {- requests.push({- method: request.method,- url: request.url,- headers: Object.fromEntries(request.headers.entries()),- body: await readJsonBody(request),- });- return HttpResponse.json({});- }),);await AgentServerConversationService.sendMessage(@@ -2554,14 +2543,19 @@ describe("AgentServerConversationService", () => {runtime,);+ // The missing credential is refreshed from the App API...const batchGets = requests.filter((req) => req.method === "GET");- const proxyPost = requests.find(- (req) => req.url === "http://localhost:54928/api/cloud-proxy",- );expect(batchGets).toHaveLength(1);- expect(proxyPost?.body).toMatchObject({- host: "http://fetched-runtime.example",- headers: { "X-Session-API-Key": "fetched-key" },+ // ...then the send targets the fetched runtime host directly with+ // the fetched session key (no /api/cloud-proxy envelope).+ expect(ConversationClient).toHaveBeenCalledWith(+ expect.objectContaining({+ host: "http://fetched-runtime.example",+ apiKey: "fetched-key",+ }),+ );+ expect(mockSendEvent).toHaveBeenCalledWith("conv-cloud", message, {+ run: true,});},);diff --git a/__tests__/api/agent-server-git-service.test.ts b/__tests__/api/agent-server-git-service.test.tsindex fa5dc5dd1c..7bf1650d84 100644--- a/__tests__/api/agent-server-git-service.test.ts+++ b/__tests__/api/agent-server-git-service.test.ts@@ -1,5 +1,4 @@import { RemoteWorkspace } from "@openhands/typescript-client/workspace/remote-workspace";-import { AxiosError } from "axios";import { describe, test, expect, vi, beforeEach, afterEach } from "vitest";import {__resetActiveStoreForTests,@@ -8,7 +7,6 @@ import {} from "#/api/backend-registry/active-store";import { callCloudProxy } from "#/api/cloud/proxy";import type { Backend } from "#/api/backend-registry/types";-import { buildHttpBaseUrl } from "#/utils/websocket-url";import AgentServerGitService from "../../src/api/git-service/agent-server-git-service.api";const { mockGitChanges, mockGitDiff, mockClientGet } = vi.hoisted(() => ({@@ -389,9 +387,9 @@ describe("AgentServerGitService", () => {});describe("getGitCommits", () => {- test("reaches the runtime through the generic cloud-proxy envelope", async () => {+ test("reaches the runtime directly via the SDK HttpClient", async () => {// Arrange- vi.mocked(callCloudProxy).mockResolvedValue({+ mockClientGet.mockResolvedValue({commits: [],has_more: false,});@@ -403,23 +401,21 @@ describe("AgentServerGitService", () => {"workspace/project",);- // Assert β session-api-key envelope to the conversation's runtime- // host, with the git path normalized to an absolute runtime path.- expect(callCloudProxy).toHaveBeenCalledWith({- backend: cloudBackend,- method: "GET",- hostOverride: buildHttpBaseUrl(runtimeConversationUrl),- path: "/api/git/commits?path=%2Fworkspace%2Fproject&limit=50",- authMode: "session-api-key",- sessionApiKey: "session-key",+ // Assert β direct call to the conversation's runtime host (CORS+ // allowlisted for the Canvas origin), with the git path normalized+ // to an absolute runtime path. No /api/cloud-proxy envelope.+ expect(callCloudProxy).not.toHaveBeenCalled();+ expect(mockClientGet).toHaveBeenCalledWith("/api/git/commits", {+ params: { path: "/workspace/project", limit: "50" },});});test("resolves null when the runtime predates the endpoint (404)", async () => {- // Arrange β the proxy hop surfaces upstream failures as AxiosErrors.- vi.mocked(callCloudProxy).mockRejectedValue(- Object.assign(new AxiosError("Not Found"), {- response: { status: 404 },+ // Arrange β the SDK HttpClient throws a raw HttpError carrying status.+ mockClientGet.mockRejectedValue(+ Object.assign(new Error("Not Found"), {+ name: "HttpError",+ status: 404,}),);@@ -433,23 +429,31 @@ describe("AgentServerGitService", () => {// Assertexpect(page).toBeNull();});++ test("throws when no conversation URL is provided on cloud backends", async () => {+ await expect(+ AgentServerGitService.getGitCommits(null, "session-key", "ws/p"),+ ).rejects.toThrow(/requires a conversation URL on cloud backends/);+ expect(callCloudProxy).not.toHaveBeenCalled();+ expect(RemoteWorkspace).not.toHaveBeenCalled();+ });});- test("does not touch the runtime workspace SDK on cloud backends", async () => {- // Arrange- vi.mocked(callCloudProxy).mockResolvedValue([]);+ test("does not touch the cloud proxy for runtime git reads", async () => {+ // Arrange β getGitCommits now reads commits straight from the runtime.+ mockClientGet.mockResolvedValue({ commits: [], has_more: false });// Act- await AgentServerGitService.getGitChanges(- "conv-1",+ await AgentServerGitService.getGitCommits(runtimeConversationUrl,"session-key","workspace/project",);- // Assert β the conversation's runtime URL must no longer be dialed- // from the browser; the cloud API makes the runtime hop server-side.- expect(RemoteWorkspace).not.toHaveBeenCalled();+ // Assert β runtime git reads go direct; only the App-API changes/diff+ // listing still uses callCloudProxy.+ expect(callCloudProxy).not.toHaveBeenCalled();+ expect(RemoteWorkspace).toHaveBeenCalledTimes(1);});});});diff --git a/__tests__/api/bash-service.test.ts b/__tests__/api/bash-service.test.tsindex 5bd86f294a..f391a4c5df 100644--- a/__tests__/api/bash-service.test.ts+++ b/__tests__/api/bash-service.test.ts@@ -137,10 +137,8 @@ describe("BashService.listOutputs β cloud backend", () => {setActiveSelection({ backendId: cloudBackend.id, orgId: null });});- it("routes through callCloudProxy with hostOverride and session-api-key", async () => {- vi.mocked(callCloudProxy).mockResolvedValueOnce({- items: [OUTPUT_1, OUTPUT_2],- });+ it("calls the runtime directly via BashClient with the session key", async () => {+ searchEventsMock.mockResolvedValueOnce({ items: [OUTPUT_1, OUTPUT_2] });const outputs = await BashService.listOutputs(CONVERSATION_URL,@@ -148,21 +146,15 @@ describe("BashService.listOutputs β cloud backend", () => {BASH_CMD_ID,);- expect(BashClient).not.toHaveBeenCalled();- const proxyCall = vi.mocked(callCloudProxy).mock.calls[0][0];- expect(proxyCall.method).toBe("GET");- expect(proxyCall.path).toMatch(/^\/api\/bash\/bash_events\/search\?/);- expect(proxyCall.hostOverride).toBe("https://runtime.example.com");- expect(proxyCall.authMode).toBe("session-api-key");- expect(proxyCall.sessionApiKey).toBe(SESSION_KEY);-- const searchUrl = new URL(- `http://x.example.com${proxyCall.path as string}`,- );- expect(searchUrl.searchParams.get("kind__eq")).toBe("BashOutput");- expect(searchUrl.searchParams.get("command_id__eq")).toBe(BASH_CMD_ID);- expect(searchUrl.searchParams.get("sort_order")).toBe("TIMESTAMP");-+ // Cloud now hits the runtime host directly (CORS allowlisted), not+ // the /api/cloud-proxy envelope.+ expect(callCloudProxy).not.toHaveBeenCalled();+ expect(BashClient).toHaveBeenCalledTimes(1);+ expect(searchEventsMock).toHaveBeenCalledWith({+ kind__eq: "BashOutput",+ command_id__eq: BASH_CMD_ID,+ sort_order: "TIMESTAMP",+ });expect(outputs).toEqual([OUTPUT_1, OUTPUT_2]);});@@ -171,5 +163,6 @@ describe("BashService.listOutputs β cloud backend", () => {BashService.listOutputs(null, SESSION_KEY, BASH_CMD_ID),).rejects.toThrow(/requires a conversation URL/);expect(callCloudProxy).not.toHaveBeenCalled();+ expect(BashClient).not.toHaveBeenCalled();});});diff --git a/__tests__/api/event-service.test.ts b/__tests__/api/event-service.test.tsindex f672907655..24287aecc5 100644--- a/__tests__/api/event-service.test.ts+++ b/__tests__/api/event-service.test.ts@@ -1,4 +1,5 @@import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";+import { ConversationClient } from "@openhands/typescript-client/clients";import {__resetActiveStoreForTests,setActiveSelection,@@ -8,6 +9,20 @@ import EventService from "#/api/event-service/event-service.api";import { callCloudProxy } from "#/api/cloud/proxy";import type { Backend } from "#/api/backend-registry/types";+const { respondToConfirmationMock, getEventCountMock } = vi.hoisted(() => ({+ respondToConfirmationMock: vi.fn(),+ getEventCountMock: vi.fn(),+}));++vi.mock("@openhands/typescript-client/clients", () => ({+ ConversationClient: vi.fn(function ConversationClientMock() {+ return {+ respondToConfirmation: respondToConfirmationMock,+ getEventCount: getEventCountMock,+ };+ }),+}));+vi.mock("#/api/cloud/proxy", () => ({callCloudProxy: vi.fn(),}));@@ -30,6 +45,9 @@ beforeEach(() => {items: [],next_page_id: null,});+ vi.mocked(ConversationClient).mockClear();+ respondToConfirmationMock.mockReset();+ getEventCountMock.mockReset();});afterEach(() => {@@ -97,9 +115,7 @@ describe("EventService.searchEvents β cloud branch", () => {});it("rethrows when a limit-only request (no filter params) fails", async () => {- vi.mocked(callCloudProxy).mockRejectedValueOnce(- new Error("Network error"),- );+ vi.mocked(callCloudProxy).mockRejectedValueOnce(new Error("Network error"));await expect(EventService.searchEvents("conv-1", null, null, { limit: 50 }),@@ -123,3 +139,39 @@ describe("EventService.searchEvents β cloud branch", () => {expect(result.next_page_id).toBeNull();});});++describe("EventService.respondToConfirmation β cloud branch", () => {+ it("calls the runtime directly via ConversationClient, not the cloud proxy", async () => {+ respondToConfirmationMock.mockResolvedValue({ success: true });++ await EventService.respondToConfirmation(+ "conv-1",+ "https://abc123.prod-runtime.all-hands.dev/api/conversations/conv-1",+ { accept: true },+ "session-key",+ );++ expect(callCloudProxy).not.toHaveBeenCalled();+ expect(ConversationClient).toHaveBeenCalledTimes(1);+ expect(respondToConfirmationMock).toHaveBeenCalledWith("conv-1", {+ accept: true,+ });+ });+});++describe("EventService.getEventCount β cloud branch", () => {+ it("calls the runtime directly via ConversationClient, not the cloud proxy", async () => {+ getEventCountMock.mockResolvedValue(42);++ const count = await EventService.getEventCount(+ "conv-1",+ "https://abc123.prod-runtime.all-hands.dev/api/conversations/conv-1",+ "session-key",+ );++ expect(callCloudProxy).not.toHaveBeenCalled();+ expect(ConversationClient).toHaveBeenCalledTimes(1);+ expect(getEventCountMock).toHaveBeenCalledWith("conv-1");+ expect(count).toBe(42);+ });+});diff --git a/__tests__/api/runtime-service/agent-server-runtime-service.test.ts b/__tests__/api/runtime-service/agent-server-runtime-service.test.tsindex e37bdb3b65..d064c46ea1 100644--- a/__tests__/api/runtime-service/agent-server-runtime-service.test.ts+++ b/__tests__/api/runtime-service/agent-server-runtime-service.test.ts@@ -8,6 +8,7 @@ import {} from "#/api/backend-registry/active-store";import AgentServerRuntimeService from "#/api/runtime-service/agent-server-runtime-service";import { callCloudProxy } from "#/api/cloud/proxy";+import { getAgentServerClientOptions } from "#/api/agent-server-client-options";import type { Backend } from "#/api/backend-registry/types";// βββ SDK client mocks βββββββββββββββββββββββββββββββββββββββββββββββββββββββ@@ -72,6 +73,12 @@ beforeEach(() => {executeCommandMock.mockReset();downloadFileMock.mockReset();vi.mocked(callCloudProxy).mockReset();+ vi.mocked(getAgentServerClientOptions).mockReset();+ vi.mocked(getAgentServerClientOptions).mockReturnValue({+ host: "http://local-agent.example.com",+ apiKey: "local-key",+ workingDir: "/workspace/project",+ });});afterEach(() => {@@ -99,6 +106,11 @@ describe("AgentServerRuntimeService.executeCommand", () => {);expect(RemoteWorkspace).toHaveBeenCalledTimes(1);+ expect(getAgentServerClientOptions).toHaveBeenCalledWith({+ conversationUrl:+ "http://local-agent.example.com/api/conversations/conv-1",+ sessionApiKey: SESSION_KEY,+ });expect(executeCommandMock).toHaveBeenCalledWith("git rev-parse --abbrev-ref HEAD","/workspace/project",@@ -107,6 +119,40 @@ describe("AgentServerRuntimeService.executeCommand", () => {expect(result).toEqual({ exit_code: 0, stdout: "main\n", stderr: "" });});+ it("does not pass the command timeout into the client options (unit mismatch)", async () => {+ // The SDK HttpClient timeout is in ms; `timeout` here is seconds. The+ // SDK's executeCommand sets its own (timeout+10)*1000 ms per-request+ // timeout, so the client default must stay unset (60s) β never the raw+ // seconds value.+ executeCommandMock.mockResolvedValue({ exit_code: 0, stdout: "" });++ await AgentServerRuntimeService.executeCommand(+ "http://local-agent.example.com/api/conversations/conv-1",+ SESSION_KEY,+ "ls",+ "/",+ 5,+ );++ expect(getAgentServerClientOptions).toHaveBeenCalledWith({+ conversationUrl:+ "http://local-agent.example.com/api/conversations/conv-1",+ sessionApiKey: SESSION_KEY,+ });+ });++ it("coerces missing stdout/stderr/exit_code to safe defaults", async () => {+ executeCommandMock.mockResolvedValue({});++ const result = await AgentServerRuntimeService.executeCommand(+ "http://local-agent.example.com/api/conversations/conv-1",+ SESSION_KEY,+ "true",+ );++ expect(result).toEqual({ exit_code: -1, stdout: "", stderr: "" });+ });+it("does not call callCloudProxy for local backends", async () => {executeCommandMock.mockResolvedValue({exit_code: 0,@@ -123,8 +169,8 @@ describe("AgentServerRuntimeService.executeCommand", () => {describe("cloud backend", () => {beforeEach(activateCloud);- it("routes through callCloudProxy with correct path, body, and auth", async () => {- vi.mocked(callCloudProxy).mockResolvedValue({+ it("calls the runtime directly via RemoteWorkspace with the session key", async () => {+ executeCommandMock.mockResolvedValue({exit_code: 0,stdout: "src/index.ts\n",stderr: "",@@ -138,18 +184,15 @@ describe("AgentServerRuntimeService.executeCommand", () => {30,);- const proxyCall = vi.mocked(callCloudProxy).mock.calls[0][0];- expect(proxyCall.method).toBe("POST");- expect(proxyCall.path).toBe("/api/bash/execute_bash_command");- expect(proxyCall.hostOverride).toBe("https://runtime.example.com");- expect(proxyCall.body).toEqual({- command: "find . -type f",- cwd: "/workspace/project",- timeout: 30,- });- expect(proxyCall.authMode).toBe("session-api-key");- expect(proxyCall.sessionApiKey).toBe(SESSION_KEY);- expect(proxyCall.timeoutSeconds).toBe(40);+ // Cloud now hits the runtime host directly (CORS allowlisted), not+ // the /api/cloud-proxy envelope.+ expect(callCloudProxy).not.toHaveBeenCalled();+ expect(RemoteWorkspace).toHaveBeenCalledTimes(1);+ expect(executeCommandMock).toHaveBeenCalledWith(+ "find . -type f",+ "/workspace/project",+ 30,+ );expect(result).toEqual({exit_code: 0,stdout: "src/index.ts\n",@@ -157,8 +200,8 @@ describe("AgentServerRuntimeService.executeCommand", () => {});});- it("omits cwd from proxy body when not provided", async () => {- vi.mocked(callCloudProxy).mockResolvedValue({ exit_code: 0 });+ it("delegates cwd and timeout straight through to the runtime", async () => {+ executeCommandMock.mockResolvedValue({ exit_code: 0, stdout: "" });await AgentServerRuntimeService.executeCommand(CLOUD_CONVERSATION_URL,@@ -168,13 +211,15 @@ describe("AgentServerRuntimeService.executeCommand", () => {10,);- const proxyBody = vi.mocked(callCloudProxy).mock.calls[0][0].body as Record<string, unknown>;- expect(proxyBody).not.toHaveProperty("cwd");- expect(proxyBody.command).toBe("echo hi");+ expect(executeCommandMock).toHaveBeenCalledWith("echo hi", undefined, 10);});- it("normalises missing stdout/stderr fields to empty strings", async () => {- vi.mocked(callCloudProxy).mockResolvedValue({ exit_code: 1 });+ it("passes the runtime result through unchanged", async () => {+ executeCommandMock.mockResolvedValue({+ exit_code: 1,+ stdout: "out",+ stderr: "err",+ });const result = await AgentServerRuntimeService.executeCommand(CLOUD_CONVERSATION_URL,@@ -184,11 +229,11 @@ describe("AgentServerRuntimeService.executeCommand", () => {5,);- expect(result).toEqual({ exit_code: 1, stdout: "", stderr: "" });+ expect(result).toEqual({ exit_code: 1, stdout: "out", stderr: "err" });});- it("does not create a RemoteWorkspace for cloud calls", async () => {- vi.mocked(callCloudProxy).mockResolvedValue({ exit_code: 0 });+ it("does not call callCloudProxy for cloud calls", async () => {+ executeCommandMock.mockResolvedValue({ exit_code: 0 });await AgentServerRuntimeService.executeCommand(CLOUD_CONVERSATION_URL,@@ -196,24 +241,16 @@ describe("AgentServerRuntimeService.executeCommand", () => {"echo ok",);- expect(RemoteWorkspace).not.toHaveBeenCalled();+ expect(callCloudProxy).not.toHaveBeenCalled();});- it("falls back to local path when conversationUrl is null", async () => {- executeCommandMock.mockResolvedValue({- exit_code: 0,- stdout: "",- stderr: "",- });-- await AgentServerRuntimeService.executeCommand(- null,- SESSION_KEY,- "echo ok",- );+ it("throws when conversationUrl is null (no runtime to target)", async () => {+ await expect(+ AgentServerRuntimeService.executeCommand(null, SESSION_KEY, "echo ok"),+ ).rejects.toThrow(/requires a conversation URL on cloud backends/);expect(callCloudProxy).not.toHaveBeenCalled();- expect(RemoteWorkspace).toHaveBeenCalledTimes(1);+ expect(RemoteWorkspace).not.toHaveBeenCalled();});});});@@ -255,9 +292,9 @@ describe("AgentServerRuntimeService.downloadFile", () => {describe("cloud backend", () => {beforeEach(activateCloud);- it("routes through callCloudProxy with GET and URL-encoded path", async () => {- const blob = new Blob([new TextEncoder().encode("file content")]);- vi.mocked(callCloudProxy).mockResolvedValue(blob);+ it("downloads from the runtime directly via FileClient", async () => {+ const fileBytes = new TextEncoder().encode("file content");+ downloadFileMock.mockResolvedValue(fileBytes.buffer);const result = await AgentServerRuntimeService.downloadFile(CLOUD_CONVERSATION_URL,@@ -265,22 +302,18 @@ describe("AgentServerRuntimeService.downloadFile", () => {"/workspace/project/src/main.ts",);- const proxyCall = vi.mocked(callCloudProxy).mock.calls[0][0];- expect(proxyCall.method).toBe("GET");- expect(proxyCall.path).toBe(- "/api/file/download?path=%2Fworkspace%2Fproject%2Fsrc%2Fmain.ts",+ // Cloud now hits the runtime host directly (CORS allowlisted), not+ // the /api/cloud-proxy envelope.+ expect(callCloudProxy).not.toHaveBeenCalled();+ expect(FileClient).toHaveBeenCalledTimes(1);+ expect(downloadFileMock).toHaveBeenCalledWith(+ "/workspace/project/src/main.ts",);- expect(proxyCall.hostOverride).toBe("https://runtime.example.com");- expect(proxyCall.authMode).toBe("session-api-key");- expect(proxyCall.sessionApiKey).toBe(SESSION_KEY);- expect(proxyCall.responseType).toBe("blob");-- // Blob.arrayBuffer() round-trip: decoded text should match the original.expect(new TextDecoder().decode(result)).toBe("file content");});- it("does not create a FileClient for cloud calls", async () => {- vi.mocked(callCloudProxy).mockResolvedValue(new Blob());+ it("does not call callCloudProxy for cloud calls", async () => {+ downloadFileMock.mockResolvedValue(new ArrayBuffer(0));await AgentServerRuntimeService.downloadFile(CLOUD_CONVERSATION_URL,@@ -288,20 +321,16 @@ describe("AgentServerRuntimeService.downloadFile", () => {"/workspace/file.txt",);- expect(FileClient).not.toHaveBeenCalled();+ expect(callCloudProxy).not.toHaveBeenCalled();});- it("falls back to local path when conversationUrl is null", async () => {- downloadFileMock.mockResolvedValue(new ArrayBuffer(0));-- await AgentServerRuntimeService.downloadFile(- null,- SESSION_KEY,- "/workspace/file.txt",- );+ it("throws when conversationUrl is null (no runtime to target)", async () => {+ await expect(+ AgentServerRuntimeService.downloadFile(null, SESSION_KEY, "/f.txt"),+ ).rejects.toThrow(/requires a conversation URL on cloud backends/);expect(callCloudProxy).not.toHaveBeenCalled();- expect(FileClient).toHaveBeenCalledTimes(1);+ expect(FileClient).not.toHaveBeenCalled();});});});diff --git a/src/api/bash-service/bash-service.api.ts b/src/api/bash-service/bash-service.api.tsindex a8cab102d0..932ea98422 100644--- a/src/api/bash-service/bash-service.api.ts+++ b/src/api/bash-service/bash-service.api.ts@@ -4,9 +4,7 @@ import type {BashEventPage,BashOutput,} from "@openhands/typescript-client";-import { buildHttpBaseUrl } from "#/utils/websocket-url";import { getActiveBackend } from "../backend-registry/active-store";-import { callCloudProxy } from "../cloud/proxy";import { getAgentServerClientOptions } from "../agent-server-client-options";interface SearchOptions {@@ -31,10 +29,11 @@ function isBashOutput(event: BashEvent): event is BashOutput {* agent-server directly with the SDK's `BashClient` (a per-conversation* URL is honoured when known, otherwise we fall back to the backend* host β a single local agent-server hosts all conversations). In- * **cloud** mode we tunnel through `callCloudProxy` with the runtime URL- * as `hostOverride`: direct browser calls to `*.prod-runtime.all-hands.dev`- * are blocked by CORS, and runtime endpoints authenticate with the- * conversation's `X-Session-API-Key`.+ * **cloud** mode we call that same per-conversation runtime host+ * directly from the browser: the runtime's CORS allowlist+ * (`OH_ALLOW_CORS_ORIGINS`, set to the Canvas origin in saas-deploy)+ * permits the cross-origin request, and runtime endpoints authenticate+ * with the conversation's `X-Session-API-Key`.** Note on the search filter name: the agent-server API uses* `command_id__eq` (not `bash_command_id__eq`) β that's the parameter the@@ -79,9 +78,7 @@ class BashService {sessionApiKey: string | null | undefined,options: SearchOptions,): Promise<BashEventPage> {- const active = getActiveBackend().backend;-- if (active.kind === "cloud") {+ if (getActiveBackend().backend.kind === "cloud") {// Cloud requires the per-conversation runtime URL β there is no// shared cloud host that owns bash events. Callers must wait for// the conversation to be hydrated before invoking this method on@@ -91,24 +88,8 @@ class BashService {"BashService.listOutputs requires a conversation URL on cloud backends",);}- const params = new URLSearchParams();- Object.entries(options).forEach(([k, v]) => {- if (v !== undefined && v !== null) params.set(k, String(v));- });- return callCloudProxy<BashEventPage>({- backend: active,- method: "GET",- hostOverride: buildHttpBaseUrl(conversationUrl),- path: `/api/bash/bash_events/search?${params.toString()}`,- authMode: "session-api-key",- sessionApiKey,- });}- // Local mode: the active backend's agent-server hosts the bash- // events. The optional `conversationUrl` is used when present (lets- // us target a per-conversation sub-host), otherwise we fall through- // to `backend.host` via `getAgentServerClientOptions`.return new BashClient(getAgentServerClientOptions({...(conversationUrl ? { conversationUrl } : {}),diff --git a/src/api/conversation-service/agent-server-conversation-service.api.ts b/src/api/conversation-service/agent-server-conversation-service.api.tsindex 7f140c7773..a700d9b3ca 100644--- a/src/api/conversation-service/agent-server-conversation-service.api.ts+++ b/src/api/conversation-service/agent-server-conversation-service.api.ts@@ -13,7 +13,6 @@ import {import { v4 as uuidv4 } from "uuid";import { AgentKind, Provider } from "#/types/settings";import type { ConversationRuntimeContext } from "#/api/conversation-file-upload.api";-import { buildHttpBaseUrl } from "#/utils/websocket-url";import {buildConversationWorkingDirForBackend,getAgentServerWorkingDir,@@ -409,6 +408,9 @@ class AgentServerConversationService {let sessionApiKey = runtime?.sessionApiKey ?? null;if (active.kind === "cloud") {+ // Cloud runtimes live at a per-conversation host whose URL + session+ // API key come from the App API. Resolve them first, then call the+ // runtime directly (CORS allowlisted for the Canvas origin).if (!conversationUrl || !sessionApiKey) {const [conversation] = await batchGetCloudConversations([conversationId,@@ -422,18 +424,6 @@ class AgentServerConversationService {"Conversation sandbox is still starting. Wait for it to finish, then try again.",);}-- await callCloudProxy({- backend: active,- method: "POST",- hostOverride: buildHttpBaseUrl(conversationUrl),- path: `/api/conversations/${conversationId}/events`,- body: { ...message, run: true },- authMode: "session-api-key",- sessionApiKey,- });-- return message;}await new ConversationClient(@@ -895,9 +885,9 @@ class AgentServerConversationService {/*** Force condensation ("compact") of the conversation history via- * `POST /api/conversations/{id}/condense`. Routed the same way as- * {@link sendMessage}: through the cloud proxy at the conversation's own- * runtime host for cloud backends, directly against that runtime otherwise.+ * `POST /api/conversations/{id}/condense`. Calls the conversation's own+ * runtime host directly (CORS allowlisted for the Canvas origin in cloud+ * mode), the same path used for sending events.*/static async condenseConversation(conversationId: string,@@ -906,16 +896,15 @@ class AgentServerConversationService {): Promise<void> {const active = getActiveBackend().backend;- if (active.kind === "cloud" && conversationUrl) {- await callCloudProxy({- backend: active,- method: "POST",- hostOverride: buildHttpBaseUrl(conversationUrl),- path: `/api/conversations/${conversationId}/condense`,- authMode: "session-api-key",- sessionApiKey,- });- return;+ // Symmetric with every other cloud runtime call in this module: on cloud+ // backends the condense endpoint lives on the per-conversation runtime+ // host, so a missing conversation URL is a caller bug, not a "no backend+ // configured" condition. Throw the specific message instead of letting+ // `getAgentServerClientOptions` surface a generic `NoBackendAvailableError`.+ if (active.kind === "cloud" && !conversationUrl) {+ throw new Error(+ "AgentServerConversationService.condenseConversation requires a conversation URL on cloud backends",+ );}await new ConversationClient(diff --git a/src/api/event-service/event-service.api.test.ts b/src/api/event-service/event-service.api.test.tsindex 9957c0cc6b..0851df1e7e 100644--- a/src/api/event-service/event-service.api.test.ts+++ b/src/api/event-service/event-service.api.test.ts@@ -95,9 +95,9 @@ describe("EventService", () => {});describe("respondToConfirmation", () => {- it("routes cloud confirmations through the runtime proxy with session authentication", async () => {+ it("routes cloud confirmations straight to the runtime via the typed client", async () => {const request = { accept: false, reason: "Needs human review" };- callCloudProxyMock.mockResolvedValue({ success: true });+ respondToConfirmationMock.mockResolvedValue({ success: true });await expect(EventService.respondToConfirmation(@@ -108,19 +108,23 @@ describe("EventService", () => {),).resolves.toEqual({ success: true });- expect(buildHttpBaseUrlMock).toHaveBeenCalledWith(- "wss://runtime.example.com/base/api/conversations/conversation-cloud",- );- expect(callCloudProxyMock).toHaveBeenCalledWith({- backend: cloudBackend,- method: "POST",- hostOverride: "https://runtime.example.com/base",- path: "/api/conversations/conversation-cloud/events/respond_to_confirmation",- body: request,- authMode: "session-api-key",+ // Cloud now calls the runtime host directly (CORS allowlisted),+ // authenticated with the session key β no /api/cloud-proxy envelope.+ expect(callCloudProxyMock).not.toHaveBeenCalled();+ expect(getAgentServerClientOptionsMock).toHaveBeenCalledWith({+ conversationUrl:+ "wss://runtime.example.com/base/api/conversations/conversation-cloud",sessionApiKey: "session-key",});- expect(conversationClientConstructorMock).not.toHaveBeenCalled();+ expect(conversationClientConstructorMock).toHaveBeenCalledWith({+ host: "http://local-client.example.com",+ apiKey: "client-key",+ workingDir: "workspace/project",+ });+ expect(respondToConfirmationMock).toHaveBeenCalledWith(+ "conversation-cloud",+ request,+ );});it("uses the typed conversation client for local confirmations", async () => {@@ -154,8 +158,8 @@ describe("EventService", () => {});describe("getEventCount", () => {- it("gets the cloud count from the runtime proxy", async () => {- callCloudProxyMock.mockResolvedValue(17);+ it("gets the cloud count straight from the runtime via the typed client", async () => {+ getEventCountMock.mockResolvedValue(17);await expect(EventService.getEventCount(@@ -165,18 +169,20 @@ describe("EventService", () => {),).resolves.toBe(17);- expect(buildHttpBaseUrlMock).toHaveBeenCalledWith(- "https://runtime.example.com/api/conversations/conversation-cloud",- );- expect(callCloudProxyMock).toHaveBeenCalledWith({- backend: cloudBackend,- method: "GET",- hostOverride: "https://runtime.example.com/base",- path: "/api/conversations/conversation-cloud/events/count",- authMode: "session-api-key",+ // Cloud now calls the runtime host directly (CORS allowlisted) β+ // no /api/cloud-proxy envelope.+ expect(callCloudProxyMock).not.toHaveBeenCalled();+ expect(getAgentServerClientOptionsMock).toHaveBeenCalledWith({+ conversationUrl:+ "https://runtime.example.com/api/conversations/conversation-cloud",sessionApiKey: null,});- expect(conversationClientConstructorMock).not.toHaveBeenCalled();+ expect(conversationClientConstructorMock).toHaveBeenCalledWith({+ host: "http://local-client.example.com",+ apiKey: "client-key",+ workingDir: "workspace/project",+ });+ expect(getEventCountMock).toHaveBeenCalledWith("conversation-cloud");});it("gets the local count from the typed conversation client", async () => {diff --git a/src/api/event-service/event-service.api.ts b/src/api/event-service/event-service.api.tsindex 8745d59041..0e56a7d6d7 100644--- a/src/api/event-service/event-service.api.ts+++ b/src/api/event-service/event-service.api.ts@@ -1,7 +1,6 @@import { ConversationClient } from "@openhands/typescript-client/clients";import { RemoteEventsList } from "@openhands/typescript-client/events/remote-events-list";import { OpenHandsEvent } from "#/types/agent-server/core";-import { buildHttpBaseUrl } from "#/utils/websocket-url";import { getActiveBackend } from "../backend-registry/active-store";import { callCloudProxy } from "../cloud/proxy";import {@@ -23,18 +22,19 @@ import type {* event *history* (`/api/v1/conversation/{id}/events/search`).* Persisted by the cloud backend β survives the runtime sandbox.*- * - **Runtime sandbox** (extracted from `conversation.conversation_url`- * and passed as `hostOverride`): live runtime endpoints like- * `/api/conversations/{id}/events/count` and- * `/api/conversations/{id}/events/respond_to_confirmation`. Auth on+ * - **Runtime sandbox** (extracted from `conversation.conversation_url`):+ * live runtime endpoints like `/api/conversations/{id}/events/count`+ * and `/api/conversations/{id}/events/respond_to_confirmation`. Auth on* these endpoints is `X-Session-API-Key`, not `Authorization: Bearer`.** App API calls go directly to the cloud backend with bearer auth. Runtime- * sandbox calls go through `/api/cloud-proxy`, which avoids depending on CORS- * for per-conversation runtime hosts.+ * sandbox calls go **directly** to the per-conversation runtime host from the+ * browser β the runtime's CORS allowlist+ * (`OH_ALLOW_CORS_ORIGINS`, set to the Canvas origin in saas-deploy) permits+ * the cross-origin call, and the `X-Session-API-Key` preflight passes.*- * Local mode keeps the existing typescript-client path: it targets the- * conversation's host directly via typed client classes.+ * Local mode targets the conversation's host directly via typed client+ * classes β the same path cloud mode now uses.*/class EventService {static async respondToConfirmation(@@ -43,20 +43,6 @@ class EventService {request: ConfirmationResponseRequest,sessionApiKey?: string | null,): Promise<ConfirmationResponseResponse> {- const active = getActiveBackend().backend;-- if (active.kind === "cloud") {- return callCloudProxy<ConfirmationResponseResponse>({- backend: active,- method: "POST",- hostOverride: buildHttpBaseUrl(conversationUrl),- path: `/api/conversations/${conversationId}/events/respond_to_confirmation`,- body: request,- authMode: "session-api-key",- sessionApiKey,- });- }-return new ConversationClient(getAgentServerClientOptions({conversationUrl,@@ -73,19 +59,6 @@ class EventService {conversationUrl: string,sessionApiKey?: string | null,): Promise<number> {- const active = getActiveBackend().backend;-- if (active.kind === "cloud") {- return callCloudProxy<number>({- backend: active,- method: "GET",- hostOverride: buildHttpBaseUrl(conversationUrl),- path: `/api/conversations/${conversationId}/events/count`,- authMode: "session-api-key",- sessionApiKey,- });- }-return new ConversationClient(getAgentServerClientOptions({conversationUrl,diff --git a/src/api/git-service/agent-server-git-service.api.ts b/src/api/git-service/agent-server-git-service.api.tsindex ded0874562..9a63327039 100644--- a/src/api/git-service/agent-server-git-service.api.ts+++ b/src/api/git-service/agent-server-git-service.api.ts@@ -1,7 +1,6 @@import { isAxiosError } from "axios";import { RemoteWorkspace } from "@openhands/typescript-client/workspace/remote-workspace";import { mapAnyGitStatusToClientStatus } from "#/utils/git-status-mapper";-import { buildHttpBaseUrl } from "#/utils/websocket-url";import type {GitChange,GitChangeDiff,@@ -31,17 +30,18 @@ interface AgentServerGitCommitsPage {}/**- * Git operations for agent-server conversations.+ * Cloud-aware Git operations for agent-server conversations.** In **local** mode the runtime is reachable directly from the browser* (it's `127.0.0.1:18000`); the SDK's `RemoteWorkspace` calls land- * fine. In **cloud** mode the runtime is at- * `*.prod-runtime.all-hands.dev`, which doesn't allow CORS from- * `localhost`. So cloud-mode calls hit the cloud API's- * `GET /api/v1/app-conversations/{id}/git/{changes,diff}` proxy- * endpoints instead β the server resolves the conversation's runtime- * and makes the hop itself with the sandbox's session API key, and the- * cloud API's CORS is permissive for bearer-token requests.+ * fine. In **cloud** mode the runtime is at `*.prod-runtime.all-hands.dev`,+ * whose CORS allowlist (`OH_ALLOW_CORS_ORIGINS`, set to the Canvas origin+ * in saas-deploy) permits direct browser calls authenticated with the+ * conversation's `X-Session-API-Key`. The changes/diff listing endpoints+ * additionally have dedicated cloud App-API proxies+ * (`GET /api/v1/app-conversations/{id}/git/{changes,diff}`) which the+ * server resolves itself; the commit endpoints below go straight to the+ * runtime.*//**@@ -49,21 +49,19 @@ interface AgentServerGitCommitsPage {* `/workspace/` to relative paths (so a relative arg like* `workspace/project` becomes `/workspace/workspace/project` and 404s).* `getGitPath` returns the local agent-server's relative convention by- * default; normalize to an absolute path before sending to the cloud- * runtime.+ * default; normalize to an absolute path before sending to the runtime.*/function toAbsoluteRuntimePath(path: string): string {return path.startsWith("/") ? path : `/${path}`;}/**- * GET an arbitrary runtime git endpoint in both backend modes. Local mode- * uses the SDK's public `HttpClient` (the typed `gitChanges`/`gitDiff`- * wrappers don't know the newer endpoints/params, and they re-wrap errors,- * dropping the `.status` needed for 404 feature-detection). Cloud mode goes- * through the generic cloud-proxy envelope with the sandbox's session API- * key β the same hop `executeCommand`/`downloadFile` use β so no dedicated- * cloud API endpoints are required.+ * GET an arbitrary runtime git endpoint in both backend modes. Targets the+ * per-conversation runtime host directly via the SDK's public `HttpClient`+ * (the typed `gitChanges`/`gitDiff` wrappers don't know the newer+ * endpoints/params, and they re-wrap errors, dropping the `.status` needed+ * for 404 feature-detection). Authenticated with the sandbox's session API+ * key; the runtime CORS allowlist permits the cross-origin cloud call.*/async function getFromRuntime<T>(conversationUrl: string | null | undefined,@@ -71,26 +69,17 @@ async function getFromRuntime<T>(apiPath: string,params: { path: string } & Record<string, string>,): Promise<T> {- const active = getActiveBackend().backend;-- if (active.kind === "cloud" && conversationUrl) {- const search = new URLSearchParams({- ...params,- path: toAbsoluteRuntimePath(params.path),- });- return callCloudProxy<T>({- backend: active,- method: "GET",- hostOverride: buildHttpBaseUrl(conversationUrl),- path: `${apiPath}?${search.toString()}`,- authMode: "session-api-key",- sessionApiKey: sessionApiKey ?? undefined,- });+ if (getActiveBackend().backend.kind === "cloud" && !conversationUrl) {+ throw new Error(+ "AgentServerGitService.getFromRuntime requires a conversation URL on cloud backends",+ );}const response = await new RemoteWorkspace(getAgentServerClientOptions({ conversationUrl, sessionApiKey }),- ).client.get<T>(apiPath, { params });+ ).client.get<T>(apiPath, {+ params: { ...params, path: toAbsoluteRuntimePath(params.path) },+ });return response.data;}diff --git a/src/api/runtime-service/agent-server-runtime-service.ts b/src/api/runtime-service/agent-server-runtime-service.tsindex 83d45845c5..a4a77c476a 100644--- a/src/api/runtime-service/agent-server-runtime-service.ts+++ b/src/api/runtime-service/agent-server-runtime-service.ts@@ -2,8 +2,6 @@ import { FileClient } from "@openhands/typescript-client/clients";import { RemoteWorkspace } from "@openhands/typescript-client/workspace/remote-workspace";import { getAgentServerClientOptions } from "#/api/agent-server-client-options";import { getActiveBackend } from "#/api/backend-registry/active-store";-import { callCloudProxy } from "#/api/cloud/proxy";-import { buildHttpBaseUrl } from "#/utils/websocket-url";export interface CommandResult {exit_code: number;@@ -17,9 +15,10 @@ export interface CommandResult {* In **local** mode the runtime is reachable directly from the browser* (e.g. `127.0.0.1:18000`) so the SDK's typed clients work fine.* In **cloud** mode the runtime lives at `*.prod-runtime.all-hands.dev`,- * which doesn't allow CORS from `localhost`, so all calls go through- * `callCloudProxy` with the runtime URL as `hostOverride` and the- * conversation's `session_api_key` as auth β server-side hop, no CORS.+ * whose CORS allowlist (`OH_ALLOW_CORS_ORIGINS`, set to the Canvas origin+ * in saas-deploy) permits direct browser calls authenticated with the+ * conversation's `X-Session-API-Key`. So both modes now use the same+ * direct typed-client path against the per-conversation runtime URL.*/class AgentServerRuntimeService {static async executeCommand(@@ -31,39 +30,32 @@ class AgentServerRuntimeService {): Promise<CommandResult> {const active = getActiveBackend().backend;- if (active.kind === "cloud" && conversationUrl) {- const output = await callCloudProxy<{- exit_code?: number;- stdout?: string;- stderr?: string;- }>({- backend: active,- method: "POST",- hostOverride: buildHttpBaseUrl(conversationUrl),- path: "/api/bash/execute_bash_command",- body: {- command,- ...(cwd ? { cwd } : {}),- timeout: Math.floor(timeout),- },- authMode: "session-api-key",- sessionApiKey,- timeoutSeconds: timeout + 10,- });- return {- exit_code: output.exit_code ?? -1,- stdout: output.stdout ?? "",- stderr: output.stderr ?? "",- };+ if (active.kind === "cloud" && !conversationUrl) {+ throw new Error(+ "AgentServerRuntimeService.executeCommand requires a conversation URL on cloud backends",+ );}+ // `RemoteWorkspace.executeCommand` forwards `timeout` (seconds) to the+ // agent-server as the command timeout AND sets the HTTP request timeout to+ // `(timeout + 10) * 1000` ms β the same +10s buffer the old cloud+ // `callCloudProxy` branch used (`timeoutSeconds: timeout + 10`). We+ // deliberately do NOT pass `timeout` into `getAgentServerClientOptions`:+ // that option is the SDK HttpClient's default timeout in *milliseconds*,+ // so a seconds value (e.g. 30) would be read as 30 ms. The per-request+ // timeout the SDK sets on `executeCommand` overrides the client default+ // anyway, but passing a ms-mismatched default is a latent footgun if any+ // method on the client ever lacks a per-request timeout.const result = await new RemoteWorkspace(getAgentServerClientOptions({ conversationUrl, sessionApiKey }),).executeCommand(command, cwd, timeout);+ // The SDK already coerces these (`exit_code ?? 0`, `stdout || ''`,+ // `stderr || ''`); keep a defensive fallback so a contract drift in the+ // client can never surface `undefined` to callers.return {- exit_code: result.exit_code,- stdout: result.stdout,- stderr: result.stderr,+ exit_code: result.exit_code ?? -1,+ stdout: result.stdout ?? "",+ stderr: result.stderr ?? "",};}@@ -74,17 +66,10 @@ class AgentServerRuntimeService {): Promise<ArrayBuffer> {const active = getActiveBackend().backend;- if (active.kind === "cloud" && conversationUrl) {- const blob = await callCloudProxy<Blob>({- backend: active,- method: "GET",- hostOverride: buildHttpBaseUrl(conversationUrl),- path: `/api/file/download?path=${encodeURIComponent(path)}`,- authMode: "session-api-key",- sessionApiKey,- responseType: "blob",- });- return blob.arrayBuffer();+ if (active.kind === "cloud" && !conversationUrl) {+ throw new Error(+ "AgentServerRuntimeService.downloadFile requires a conversation URL on cloud backends",+ );}return new FileClient(