π OpenHands: AI-Driven Development
fix(acp): tie the client ACP registry pin to agent-server, drop the codex shim (#17423)
simonrosenberg0bb101e1e491
diff --git a/.github/workflows/sdk-version-sync.yml b/.github/workflows/sdk-version-sync.ymlindex ba058c391c..b3a30d9251 100644--- a/.github/workflows/sdk-version-sync.yml+++ b/.github/workflows/sdk-version-sync.yml@@ -5,6 +5,7 @@ on:paths:# Only run on PRs that touch version-related files- "config/defaults.json"+ - "package.json"- "scripts/dev-safe.mjs"- "scripts/dev-with-automation.mjs"- "scripts/check-sdk-version-sync.mjs"@@ -14,6 +15,7 @@ on:- mainpaths:- "config/defaults.json"+ - "package.json"- "scripts/dev-safe.mjs"- "scripts/dev-with-automation.mjs"- "scripts/check-sdk-version-sync.mjs"diff --git a/__tests__/api/agent-server-adapter.test.ts b/__tests__/api/agent-server-adapter.test.tsindex 5b76451aa5..f55c7047df 100644--- a/__tests__/api/agent-server-adapter.test.ts+++ b/__tests__/api/agent-server-adapter.test.ts@@ -1,5 +1,6 @@import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";import type { MockInstance } from "vitest";+import { getAcpProvider as getClientAcpProvider } from "@openhands/typescript-client";import { CANVAS_UI_CLIENT_TOOL_NAME } from "#/constants/canvas-ui";import { LAUNCH_CHILD_CONVERSATION_TOOL_NAME } from "#/constants/child-conversation";@@ -1519,9 +1520,7 @@ describe("buildStartConversationRequest β ACP discriminator", () => {expect(payload.agent).toBeUndefined();expect(payload.agent_settings.agent_kind).toBe("acp");expect(payload.agent_settings.acp_command).toEqual([- "npx",- "-y",- "@agentclientprotocol/[email protected]",+ ...getClientAcpProvider("claude-code")!.default_command,]);expect(payload.agent_settings.acp_model).toBe("claude-opus-4-5");// LLM-only fields must not leak into the ACP settings payload.@@ -1671,9 +1670,7 @@ describe("buildStartConversationRequest β ACP discriminator", () => {};expect(payload.agent_settings.acp_command).toEqual([- "npx",- "-y",- "@agentclientprotocol/[email protected]",+ ...getClientAcpProvider("claude-code")!.default_command,]);});@@ -1693,9 +1690,7 @@ describe("buildStartConversationRequest β ACP discriminator", () => {};expect(payload.agent_settings.acp_command).toEqual([- "npx",- "-y",- "@agentclientprotocol/[email protected]",+ ...getClientAcpProvider("codex")!.default_command,]);});@@ -1840,9 +1835,7 @@ describe("buildStartConversationRequest β ACP discriminator", () => {expect(acpPayload.agent_settings.agent_kind).toBe("acp");expect(acpPayload.agent_settings.acp_command).toEqual([- "npx",- "-y",- "@agentclientprotocol/[email protected]",+ ...getClientAcpProvider("claude-code")!.default_command,]);expect(acpPayload.agent_settings.acp_model).toBe("claude-opus-4-5");// acp_env is no longer a forwarded ACP setting β a stale value on saveddiff --git a/__tests__/constants/acp-providers.test.ts b/__tests__/constants/acp-providers.test.tsindex c1b079659f..ca65e08aa4 100644--- a/__tests__/constants/acp-providers.test.ts+++ b/__tests__/constants/acp-providers.test.ts@@ -10,7 +10,6 @@ import {getAcpProvider,getAcpProviderDisplayName,getAcpProviderSecrets,- resolveCodexDefaultCommand,} from "#/constants/acp-providers";describe("getAcpProviderDisplayName", () => {@@ -51,22 +50,10 @@ describe("ACP provider registry", () => {const sdk = getClientAcpProvider(provider.key);expect(sdk, provider.key).not.toBeNull();expect(provider.display_name).toBe(sdk!.display_name);- if (provider.key === "codex") {- expect(provider.default_command).toEqual([- "npx",- "-y",- "@agentclientprotocol/[email protected]",- ]);- expect(provider.available_models?.[0]).toEqual({- id: "gpt-6-astra",- label: "GPT-6 Astra",- });- } else {- expect(provider.default_command).toEqual([...sdk!.default_command]);- expect(provider.available_models).toEqual(- sdk!.available_models.map((m) => ({ id: m.id, label: m.label })),- );- }+ expect(provider.default_command).toEqual([...sdk!.default_command]);+ expect(provider.available_models).toEqual(+ sdk!.available_models.map((m) => ({ id: m.id, label: m.label })),+ );expect(provider.default_model).toBe(sdk!.default_model ?? undefined);// UI-only overlay stays local.expect(provider.icon).toBeTruthy();@@ -87,37 +74,6 @@ describe("ACP provider registry", () => {}});- it("temporarily overrides only the exact stale codex pin from the pinned client", () => {- // Unlike the model dedup, the launch-command shim has a guard: once the pinned- // client ships the upstream command, Canvas defers to the registry value so the- // temporary shim stops firing without a separate cleanup pass.- expect(- resolveCodexDefaultCommand([- "npx",- "-y",- "@agentclientprotocol/[email protected]",- ]),- ).toEqual(["npx", "-y", "@agentclientprotocol/[email protected]"]);-- // Registry values at-or-newer than the tested version stay authoritative β- // the shim must never revert a future upstream bump.-- expect(- resolveCodexDefaultCommand([- "npx",- "-y",- "@agentclientprotocol/[email protected]",- ]),- ).toEqual(["npx", "-y", "@agentclientprotocol/[email protected]"]);- expect(- resolveCodexDefaultCommand([- "npx",- "-y",- "@agentclientprotocol/[email protected]",- ]),- ).toEqual(["npx", "-y", "@agentclientprotocol/[email protected]"]);- });-it("does not suggest generic default model placeholders", () => {// Model lists are SDK-owned (see ACP_PROVIDERS) β Canvas no longer hand-keeps// them. The claude-code registry intentionally offers an id ``default``diff --git a/__tests__/routes/agent-settings.test.tsx b/__tests__/routes/agent-settings.test.tsxindex 0acbda269b..19de58e7c7 100644--- a/__tests__/routes/agent-settings.test.tsx+++ b/__tests__/routes/agent-settings.test.tsx@@ -3,6 +3,7 @@ import { render, screen, waitFor } from "@testing-library/react";import userEvent from "@testing-library/user-event";import { MemoryRouter } from "react-router";import { beforeEach, describe, expect, it, vi } from "vitest";+import { getAcpProvider as getClientAcpProvider } from "@openhands/typescript-client";import {AgentSettingsScreen,type AgentSettingsSaveControl,@@ -12,6 +13,9 @@ import { SecretsService } from "#/api/secrets-service";import { MOCK_DEFAULT_USER_SETTINGS } from "#/mocks/handlers";import { Settings } from "#/types/settings";+const CLAUDE_COMMAND = getClientAcpProvider("claude-code")!.default_command;+const CODEX_COMMAND = getClientAcpProvider("codex")!.default_command;+// Stub the login-detection probe so the ACP credentials section doesn't spin a// subprocess; default to no detected session so existing tests are unaffected.const acpAuthStatusMock = vi.hoisted(() => vi.fn());@@ -550,10 +554,7 @@ describe("AgentSettingsScreen", () => {"agent-command-input",) as HTMLTextAreaElement;await user.clear(commandInput);- await user.type(- commandInput,- "npx -y @agentclientprotocol/[email protected]",- );+ await user.type(commandInput, CODEX_COMMAND.join(" "));// The model field now reflects the Codex default, not the stale Claude one.expect(screen.getByLabelText("SETTINGS$AGENT_MODEL")).toHaveValue(@@ -597,9 +598,7 @@ describe("AgentSettingsScreen", () => {const commandInput = (await screen.findByTestId("agent-command-input",)) as HTMLTextAreaElement;- expect(commandInput.value).toBe(- "npx -y @agentclientprotocol/[email protected]",- );+ expect(commandInput.value).toBe(CLAUDE_COMMAND.join(" "));expect(screen.getByLabelText("SETTINGS$AGENT_MODEL")).toHaveValue("Claude Opus (1M)",);@@ -791,9 +790,7 @@ describe("AgentSettingsScreen", () => {const cmd = (await screen.findByTestId("agent-command-input",)) as HTMLTextAreaElement;- expect(cmd.value).toBe(- "npx -y @agentclientprotocol/[email protected] --extra-arg",- );+ expect(cmd.value).toBe(`${CLAUDE_COMMAND.join(" ")} --extra-arg`);// Make a real edit so Save enables, then submit. The payload must// carry the registry-default prefix the user can SEE in the textarea,@@ -810,9 +807,7 @@ describe("AgentSettingsScreen", () => {};expect(call.agent_settings_diff?.acp_server).toBe("custom");expect(call.agent_settings_diff?.acp_command).toEqual([- "npx",- "-y",- "@agentclientprotocol/[email protected]",+ ...CLAUDE_COMMAND,"--extra-arg","--saved",]);diff --git a/__tests__/scripts/check-sdk-version-sync.test.ts b/__tests__/scripts/check-sdk-version-sync.test.tsindex 31d5b3ed48..48cd4a068a 100644--- a/__tests__/scripts/check-sdk-version-sync.test.ts+++ b/__tests__/scripts/check-sdk-version-sync.test.ts@@ -4,6 +4,11 @@ import { describe, it, expect, vi, beforeEach, afterEach } from "vitest";type NormalizeVersion = (version: string | null) => string | null;type VersionsEqual = (v1: string, v2: string) => boolean;type ParseSdkVersions = (requiresDist: string[]) => Record<string, string>;+type FindClientPinMismatch = (+ pinned: string | null,+ expected: string,+) => { package: string; expected: string; actual: string | null } | null;+type ReadClientPin = () => string | null;// Import after mocking - need dynamic import since the script has side effectsdescribe("check-sdk-version-sync helpers", () => {@@ -11,6 +16,9 @@ describe("check-sdk-version-sync helpers", () => {let versionsEqual: VersionsEqual;let parseSdkVersionsFromRequiresDist: ParseSdkVersions;let SDK_PACKAGES: string[];+ let findClientPinMismatch: FindClientPinMismatch;+ let readClientPin: ReadClientPin;+ let CLIENT_PACKAGE_NAME: string;beforeEach(async () => {// Reset modules to get fresh imports@@ -27,6 +35,10 @@ describe("check-sdk-version-sync helpers", () => {parseSdkVersionsFromRequiresDist =module.parseSdkVersionsFromRequiresDist as ParseSdkVersions;SDK_PACKAGES = module.SDK_PACKAGES as string[];+ findClientPinMismatch =+ module.findClientPinMismatch as FindClientPinMismatch;+ readClientPin = module.readClientPin as ReadClientPin;+ CLIENT_PACKAGE_NAME = module.CLIENT_PACKAGE_NAME as string;});afterEach(() => {@@ -158,4 +170,41 @@ describe("check-sdk-version-sync helpers", () => {expect(SDK_PACKAGES).toHaveLength(4);});});++ describe("findClientPinMismatch", () => {+ it("accepts a pin equal to the expected agent-server version", () => {+ expect(findClientPinMismatch("1.46.0", "1.46.0")).toBeNull();+ expect(findClientPinMismatch("1.46", "1.46.0")).toBeNull();+ });++ it("reports the skew that ships a stale ACP picker", () => {+ // 1.39.0 against agent-server 1.46.0 is the drift that left GPT-6 Astra+ // out of the Codex picker while offering three ids the server rejects.+ expect(findClientPinMismatch("1.39.0", "1.46.0")).toEqual({+ package: CLIENT_PACKAGE_NAME,+ expected: "1.46.0",+ actual: "1.39.0",+ });+ });++ it("rejects a range, which would let the skew back in", () => {+ for (const range of ["^1.46.0", "~1.46.0", ">=1.46.0", "latest"]) {+ expect(findClientPinMismatch(range, "1.46.0"), range).not.toBeNull();+ }+ });++ it("reports an absent dependency rather than passing silently", () => {+ expect(findClientPinMismatch(null, "1.46.0")).toEqual({+ package: CLIENT_PACKAGE_NAME,+ expected: "1.46.0",+ actual: null,+ });+ });+ });++ describe("readClientPin", () => {+ it("reads an exact pin this repo actually ships", () => {+ expect(readClientPin()).toMatch(/^[0-9]+\.[0-9]+\.[0-9]+$/);+ });+ });});diff --git a/package-lock.json b/package-lock.jsonindex b172bed0fb..0958d37a3a 100644--- a/package-lock.json+++ b/package-lock.json@@ -14,7 +14,7 @@"@microlink/react-json-view": "1.31.25","@monaco-editor/react": "4.7.0","@openhands/extensions": "0.20.0",- "@openhands/typescript-client": "1.39.0",+ "@openhands/typescript-client": "1.46.0","@react-router/node": "7.18.2","@react-router/serve": "7.18.2","@tailwindcss/vite": "4.3.3",@@ -4178,9 +4178,9 @@}},"node_modules/@openhands/typescript-client": {- "version": "1.39.0",- "resolved": "https://registry.npmjs.org/@openhands/typescript-client/-/typescript-client-1.39.0.tgz",- "integrity": "sha512-AXRR9bXYYsT87NvkJCB2sLBxAjoGwt6MIQED4g5EufpXaUvY21BDyuDjNpsVtGl6WFnjbvTK1kFytkbxAe0rvw==",+ "version": "1.46.0",+ "resolved": "https://registry.npmjs.org/@openhands/typescript-client/-/typescript-client-1.46.0.tgz",+ "integrity": "sha512-bl2zxW8E2EfI3x19Po62pveRdTVLo0IKD6m1PhWdJwg4KYmZEWfANNDgWI/ufcEOfiqBcn+iIFDUvcfZRn7ttg==","license": "MIT","dependencies": {"@openrouter/sdk": "^1.2.11",diff --git a/package.json b/package.jsonindex 870108c5df..3c62c30a3b 100644--- a/package.json+++ b/package.json@@ -24,7 +24,7 @@"@microlink/react-json-view": "1.31.25","@monaco-editor/react": "4.7.0","@openhands/extensions": "0.20.0",- "@openhands/typescript-client": "1.39.0",+ "@openhands/typescript-client": "1.46.0","@react-router/node": "7.18.2","@react-router/serve": "7.18.2","@tailwindcss/vite": "4.3.3",diff --git a/scripts/check-sdk-version-sync.mjs b/scripts/check-sdk-version-sync.mjsindex d40b63e2c0..e891782751 100644--- a/scripts/check-sdk-version-sync.mjs+++ b/scripts/check-sdk-version-sync.mjs@@ -3,8 +3,15 @@/*** Check SDK Version Sync*- * Verifies that the released automation package (openhands-automation on PyPI)- * uses the SDK version expected for that automation release for all agent SDK libraries:+ * Verifies two things against versions.agentServer in config/defaults.json:+ *+ * 1. The local @openhands/typescript-client pin in package.json. Canvas renders+ * the ACP provider picker from that generated registry mirror but launches+ * the adapter through the agent-server image, so a skew ships a picker+ * offering models and launch commands agent-server does not implement.+ *+ * 2. That the released automation package (openhands-automation on PyPI)+ * uses the SDK version expected for that automation release for all agent SDK libraries:* - openhands-sdk* - openhands-tools* - openhands-workspace@@ -101,6 +108,11 @@ const SDK_PACKAGES = ["openhands-agent-server",];+// Mirrors the SDK's ACP provider registry. Must track versions.agentServer:+// the picker is rendered from this pin but the adapter is launched by that+// image, so a skew advertises models the running agent-server cannot run.+const CLIENT_PACKAGE_NAME = "@openhands/typescript-client";+// Configurable automation package (can be overridden via env)const AUTOMATION_PACKAGE_NAME = process.env.AUTOMATION_PACKAGE_NAME || "openhands-automation";@@ -173,6 +185,34 @@ function getExpectedVersion() {};}+/**+ * Compare the local typescript-client pin against the expected SDK version.+ * Returns a mismatch descriptor, or null when they agree.+ */+function findClientPinMismatch(pinnedVersion, expectedVersion) {+ if (!pinnedVersion) {+ return { package: CLIENT_PACKAGE_NAME, expected: expectedVersion, actual: null };+ }+ // A range would reintroduce the skew this check exists to catch.+ if (!/^[0-9]/.test(pinnedVersion)) {+ return { package: CLIENT_PACKAGE_NAME, expected: expectedVersion, actual: pinnedVersion };+ }+ if (versionsEqual(pinnedVersion, expectedVersion)) {+ return null;+ }+ return { package: CLIENT_PACKAGE_NAME, expected: expectedVersion, actual: pinnedVersion };+}++/**+ * Read the typescript-client pin from package.json.+ */+function readClientPin() {+ const pkg = JSON.parse(+ readFileSync(join(projectRoot, "package.json"), "utf-8"),+ );+ return pkg.dependencies?.[CLIENT_PACKAGE_NAME] ?? null;+}+/*** Fetch the latest version of a package from PyPI*/@@ -308,6 +348,34 @@ async function main() {`Expected automation SDK version: ${colors.green}${expectedVersion}${colors.reset} (from ${versionSource})`,);+ // Offline, so it runs first and fails fast without the PyPI round trip.+ const clientMismatch = findClientPinMismatch(readClientPin(), expectedVersion);+ if (clientMismatch) {+ console.log("");+ console.log(+ ` ${CLIENT_PACKAGE_NAME.padEnd(30)} ${colors.red}β ${clientMismatch.actual ?? "(absent)"} (expected ${expectedVersion})${colors.reset}`,+ );+ console.log("");+ console.log(`${colors.red}Version mismatch detected!${colors.reset}`);+ console.log("");+ console.log(+ `${CLIENT_PACKAGE_NAME} mirrors the SDK's ACP provider registry that Canvas renders the`,+ );+ console.log(+ `ACP picker from, but the adapter is launched by agent-server ${expectedVersion}. A skew ships a`,+ );+ console.log("picker offering models and launch commands that agent-server does not implement.");+ console.log("");+ console.log("To fix, update one of the following:");+ console.log(` 1. Pin ${CLIENT_PACKAGE_NAME} to ${expectedVersion} in package.json`);+ console.log(" 2. Update versions.agentServer in config/defaults.json");+ console.log("");+ process.exit(1);+ }+ console.log(+ `Client registry pin: ${colors.green}${CLIENT_PACKAGE_NAME}@${expectedVersion}${colors.reset} (matches versions.agentServer)`,+ );+// Get automation version from env var or config/defaults.jsonconst { version: automationVersion, source: automationSource } = getAutomationVersion();console.log(@@ -422,7 +490,10 @@ export {normalizeVersion,versionsEqual,parseSdkVersionsFromRequiresDist,+ findClientPinMismatch,+ readClientPin,SDK_PACKAGES,+ CLIENT_PACKAGE_NAME,AUTOMATION_PACKAGE_NAME,};diff --git a/src/constants/acp-providers.test.ts b/src/constants/acp-providers.test.tsindex 692c987932..79251b0037 100644--- a/src/constants/acp-providers.test.ts+++ b/src/constants/acp-providers.test.ts@@ -4,49 +4,30 @@ import {ACP_MANAGED_SENTINEL,ACP_PROVIDERS,getAcpProviderSecrets,- resolveCodexDefaultCommand,SURFACED_ACP_PROVIDERS,resolveEffectiveAcpModel,} from "./acp-providers";describe("ACP_PROVIDERS", () => {- it("offers GPT-6 Astra first for Codex ACP", () => {+ it("passes every codex data field through from the pinned client registry", () => {+ // No local override may sit between the registry and the picker: a+ // hand-maintained model entry survives an upstream *removal*, so Canvas+ // would keep offering an id the live ACP server has started rejecting.const codex = ACP_PROVIDERS.find(({ key }) => key === "codex");- expect(codex?.available_models?.[0]).toEqual({- id: "gpt-6-astra",- label: "GPT-6 Astra",- });- expect(codex?.default_command).toEqual([- "npx",- "-y",- "@agentclientprotocol/[email protected]",- ]);+ const client = CLIENT_ACP_PROVIDERS.codex;+ expect(codex?.default_command).toEqual([...client.default_command]);+ expect(codex?.available_models).toEqual(+ client.available_models.map(({ id, label }) => ({ id, label })),+ );});-});-describe("resolveCodexDefaultCommand", () => {- it("overrides only the exact stale codex pin from the pinned client", () => {- expect(- resolveCodexDefaultCommand([- "npx",- "-y",- "@agentclientprotocol/[email protected]",- ]),- ).toEqual(["npx", "-y", "@agentclientprotocol/[email protected]"]);- expect(- resolveCodexDefaultCommand([- "npx",- "-y",- "@agentclientprotocol/[email protected]",- ]),- ).toEqual(["npx", "-y", "@agentclientprotocol/[email protected]"]);- expect(- resolveCodexDefaultCommand([- "npx",- "-y",- "@agentclientprotocol/[email protected]",- ]),- ).toEqual(["npx", "-y", "@agentclientprotocol/[email protected]"]);+ it("carries GPT-6 Astra, so the pin is new enough to launch it", () => {+ // Canary for the pin's freshness, not a catalog Canvas maintains: Astra+ // needs codex-acp >= 1.10.0, which only client >= 1.45.0 mirrors.+ const codex = ACP_PROVIDERS.find(({ key }) => key === "codex");+ expect(codex?.available_models?.map(({ id }) => id)).toContain(+ "gpt-6-astra",+ );});});diff --git a/src/constants/acp-providers.ts b/src/constants/acp-providers.tsindex 47ac5358cb..cff1959845 100644--- a/src/constants/acp-providers.ts+++ b/src/constants/acp-providers.ts@@ -144,44 +144,11 @@ const ACP_PROVIDER_UI: Record<},};-const CODEX_ASTRA_MODEL: ACPModelOption = {- id: "gpt-6-astra",- label: "GPT-6 Astra",-};-// The pinned ``@openhands/typescript-client`` (1.39.0) still mirrors the-// pre-Astra codex ``default_command`` (1.1.7), which the Codex ACP wrapper-// rejects for ``gpt-6-astra``. Until that client release ships the upstream-// fix, Canvas launches codex with the first tested Astra-compatible version.-const CODEX_LEGACY_ACP_COMMAND = "npx -y @agentclientprotocol/[email protected]";-const CODEX_ASTRA_ACP_VERSION = "@agentclientprotocol/[email protected]";-const CODEX_ASTRA_COMMAND = ["npx", "-y", CODEX_ASTRA_ACP_VERSION];--/**- * Resolve codex's launch command from the SDK registry, applying the temporary- * Astra shim only to the exact stale pin the pinned client reports. Any other- * registry value (including a future ``1.10.0``-or-newer release)is- * authoritative β so once upstream catches up, this shim stops firing and can- * be deleted without a separate cleanup pass.- */-export function resolveCodexDefaultCommand(- registryCommand: readonly string[],-): string[] {- if (registryCommand.join(" ") === CODEX_LEGACY_ACP_COMMAND) {- return [...CODEX_ASTRA_COMMAND];- }- return [...registryCommand];-}-function getAvailableModels(key: string): ACPModelOption[] | undefined {- const models = getClientAcpProvider(key)?.available_models?.map((model) => ({+ return getClientAcpProvider(key)?.available_models?.map((model) => ({id: model.id,label: model.label,}));- if (key !== "codex") return models;- return [- CODEX_ASTRA_MODEL,- ...(models ?? []).filter(({ id }) => id !== CODEX_ASTRA_MODEL.id),- ];}/**@@ -203,12 +170,7 @@ export const ACP_PROVIDERS: ACPProviderConfig[] = Object.entries(return {key,display_name: info?.display_name ?? key,- default_command:- key === "codex"- ? resolveCodexDefaultCommand(info?.default_command ?? [])- : info- ? [...info.default_command]- : [],+ default_command: info ? [...info.default_command] : [],available_models: getAvailableModels(key),default_model: info?.default_model ?? undefined,description_key: ui.description_key,