Skip to content

Commit e00f860

Browse files
TheAngryPitCassieMeijalehman
authored
fix(codex): Computer Use fails when Desktop bundles a newer app-server (#125883)
* fix(codex): allow newer app-server runtimes * fix(codex): bound external app-server compatibility --------- Co-authored-by: TheAngryPit <[email protected]> Co-authored-by: Josh Lehman <[email protected]>
1 parent fa40741 commit e00f860

11 files changed

Lines changed: 170 additions & 53 deletions

File tree

‎docs/plugins/codex-harness-reference.md‎

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -317,10 +317,11 @@ If the normal app-server runtime would be `danger-full-access`, enabling
317317
permission profile instead. Codex-managed network enforcement is sandboxed
318318
networking, so a full-access profile would not protect outbound traffic.
319319

320-
The plugin accepts exactly stable Codex app-server `0.147.0`. Older or newer
321-
versions, prereleases, build-suffixed versions, and unversioned app-server
322-
handshakes are rejected. The same exact-version requirement applies to explicit
323-
custom executables, remote app-servers, and macOS desktop binaries.
320+
The plugin ships Codex app-server `0.147.0` and accepts external versions through
321+
`0.148.0-alpha.15`. Versions outside that tested range and malformed or
322+
unversioned handshakes are rejected. Build metadata does not affect SemVer
323+
precedence. The same range applies to explicit custom executables, remote
324+
app-servers, and macOS desktop binaries; admission is not readiness proof.
324325

325326
OpenClaw treats non-loopback WebSocket app-server URLs as remote and requires
326327
identity-bearing WebSocket auth through `appServer.authToken` or an
@@ -369,7 +370,7 @@ configured plugin's details to reserve the denied app IDs. It does not scan
369370
unrelated marketplaces or install, enable, or authenticate the disabled plugin;
370371
missing ownership fails closed.
371372

372-
Only connect OpenClaw to a `0.147.0` remote app-server trusted to accept
373+
Only connect OpenClaw to a remote app-server in the supported range trusted to accept
373374
configured marketplace plugin installs and inventory refreshes. Missing modern
374375
inventory methods and server, authentication, or transport failures fail closed.
375376

‎docs/plugins/codex-harness.md‎

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -89,10 +89,12 @@ channel is the communication surface.
8989

9090
- The official `@openclaw/codex` plugin installed. Include `codex` in
9191
`plugins.allow` if your config uses an allowlist.
92-
- Codex app-server `0.147.0`. The plugin ships and manages `@openai/codex`
93-
`0.147.0` by default, so a `codex` command on `PATH` does not affect normal
94-
startup. Explicit custom, remote, and macOS desktop-owned app-servers must
95-
report the same exact stable `0.147.0` version.
92+
- Codex app-server `0.147.0` through `0.148.0-alpha.15`. The plugin still ships and manages the
93+
exact `@openai/codex` `0.147.0` artifact, so a `codex` command on `PATH` does
94+
not affect normal startup. Explicit custom, remote, and macOS desktop-owned
95+
app-servers must report valid SemVer inside that tested external range.
96+
Versions above the managed artifact initialize with a warning; acceptance
97+
permits an attempt and is not readiness or capability proof.
9698
- Node.js on the remote Codex app-server host when `remoteWorkspaceRoot` is set
9799
and cross-machine workspace attachments must be transferred.
98100
- Codex auth through `openclaw models auth login --provider openai`, an
@@ -1353,11 +1355,13 @@ instead of a plain OpenAI API-key failure.
13531355
Doctor rewrites legacy model refs to `openai/*`, removes stale session and
13541356
whole-agent runtime pins, and preserves existing auth-profile overrides.
13551357

1356-
**The app-server is rejected:** use exactly stable Codex `0.147.0`. Older or
1357-
newer versions, prereleases, build-suffixed versions, and unversioned servers
1358-
are rejected because OpenClaw validates generated schemas and runtime contracts
1359-
against the Codex version it ships. Update or remove custom, remote, or desktop
1360-
binary overrides that select another version.
1358+
**The app-server is rejected:** use Codex `0.147.0` through
1359+
`0.148.0-alpha.15`. OpenClaw rejects versions outside that tested range, plus
1360+
malformed and unversioned servers. Same-version prereleases such as
1361+
`0.147.0-alpha.2` remain below the stable minimum; build metadata such as
1362+
`0.147.0+desktop` does not affect precedence. An accepted external version is
1363+
permitted to initialize rather than treated as proof of compatibility, so
1364+
startup and capability operations can still fail with their normal diagnostics.
13611365

13621366
**`/codex status` cannot connect:** check that the `codex` plugin
13631367
is enabled, that `plugins.allow` includes it when an allowlist is

‎docs/plugins/codex-native-plugins.md‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,10 @@ working.
2222
- The agent runtime must be the native Codex harness.
2323
- `plugins.entries.codex.enabled` is `true`.
2424
- `plugins.entries.codex.config.codexPlugins.enabled` is `true`.
25-
- Codex app-server reports exactly stable `0.147.0`. The official plugin ships
26-
`@openai/codex` `0.147.0`; custom, remote, and macOS desktop-owned binaries
27-
must use the same exact version.
25+
- Codex app-server reports a version from `0.147.0` through
26+
`0.148.0-alpha.15`. The official plugin still ships `@openai/codex`
27+
`0.147.0`; accepted external versions remain subject to normal startup and
28+
capability validation.
2829
- The target Codex app-server can see the expected marketplace, plugin, and
2930
app inventory.
3031
- Migration supports only `openai-curated` plugins that it observed as

‎docs/plugins/sdk-agent-harness.md‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -319,8 +319,9 @@ For operator setup, model prefix examples, and Codex-only configs, see
319319

320320
The Codex plugin enforces the minimum app-server version documented in
321321
[Codex Harness](/plugins/codex-harness). It checks the initialize handshake and
322-
blocks older or unversioned servers, so OpenClaw only runs against the protocol
323-
surface it has tested.
322+
blocks versions outside the tested external range plus malformed or unversioned
323+
servers. Admission permits startup to continue; it does not prove later runtime
324+
or capability operations will succeed.
324325

325326
### Tool-result middleware
326327

‎extensions/codex/package.json‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
"type": "module",
1010
"dependencies": {
1111
"@openai/codex": "0.147.0",
12+
"semver": "7.8.5",
1213
"smol-toml": "1.7.1",
1314
"typebox": "1.3.6",
1415
"ws": "8.21.1",

‎extensions/codex/src/app-server/client.test.ts‎

Lines changed: 73 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,11 @@ import {
88
} from "./client.js";
99
import { resetSharedCodexAppServerClientForTests } from "./shared-client.js";
1010
import { createClientHarness } from "./test-support.js";
11-
import { CODEX_APP_SERVER_VERSION } from "./version.js";
11+
import {
12+
CODEX_APP_SERVER_VERSION,
13+
MAX_SUPPORTED_CODEX_APP_SERVER_VERSION,
14+
MIN_SUPPORTED_CODEX_APP_SERVER_VERSION,
15+
} from "./version.js";
1216

1317
const CODEX_DYNAMIC_TOOL_SERVER_REQUEST_TIMEOUT_MS = 660_000;
1418

@@ -357,11 +361,11 @@ describe("CodexAppServerClient", () => {
357361
const { harness, initializing, outbound } = startInitialize();
358362
harness.send({
359363
id: outbound.id,
360-
result: { userAgent: "openclaw/0.124.9 (macOS; test)" },
364+
result: { userAgent: "openclaw/0.146.9 (macOS; test)" },
361365
});
362366

363367
await expect(initializing).rejects.toThrow(
364-
`Codex app-server ${CODEX_APP_SERVER_VERSION} is required, but detected 0.124.9`,
368+
`A Codex app-server from ${MIN_SUPPORTED_CODEX_APP_SERVER_VERSION} through ${MAX_SUPPORTED_CODEX_APP_SERVER_VERSION} is required, but detected 0.146.9`,
365369
);
366370
expect(harness.writes).toHaveLength(1);
367371
});
@@ -374,7 +378,7 @@ describe("CodexAppServerClient", () => {
374378
});
375379

376380
await expect(initializing).rejects.toThrow(
377-
`Codex app-server ${CODEX_APP_SERVER_VERSION} is required, but detected 0.146.0`,
381+
`A Codex app-server from ${MIN_SUPPORTED_CODEX_APP_SERVER_VERSION} through ${MAX_SUPPORTED_CODEX_APP_SERVER_VERSION} is required, but detected 0.146.0`,
378382
);
379383
expect(harness.writes).toHaveLength(1);
380384
});
@@ -387,22 +391,23 @@ describe("CodexAppServerClient", () => {
387391
});
388392

389393
await expect(initializing).rejects.toThrow(
390-
`Codex app-server ${CODEX_APP_SERVER_VERSION} is required, but detected 0.147.0-alpha.2`,
394+
`A Codex app-server from ${MIN_SUPPORTED_CODEX_APP_SERVER_VERSION} through ${MAX_SUPPORTED_CODEX_APP_SERVER_VERSION} is required, but detected 0.147.0-alpha.2`,
391395
);
392396
expect(harness.writes).toHaveLength(1);
393397
});
394398

395-
it("blocks Codex app-server build metadata on the exact supported version", async () => {
399+
it("accepts compatible build metadata on the minimum supported version", async () => {
400+
const warn = vi.spyOn(embeddedAgentLog, "warn").mockImplementation(() => undefined);
396401
const { harness, initializing, outbound } = startInitialize();
397402
harness.send({
398403
id: outbound.id,
399-
result: { userAgent: "openclaw/0.147.0+alpha.2 (macOS; test)" },
404+
result: { userAgent: "openclaw/0.147.0+desktop (macOS; test)" },
400405
});
401406

402-
await expect(initializing).rejects.toThrow(
403-
`Codex app-server ${CODEX_APP_SERVER_VERSION} is required, but detected 0.147.0+alpha.2`,
404-
);
405-
expect(harness.writes).toHaveLength(1);
407+
await expect(initializing).resolves.toBeUndefined();
408+
expect(harness.client.getServerVersion()).toBe("0.147.0+desktop");
409+
expect(JSON.parse(harness.writes[1] ?? "{}")).toEqual({ method: "initialized" });
410+
expect(warn).not.toHaveBeenCalled();
406411
});
407412

408413
it("blocks Codex app-server prereleases outside generated stable schemas", async () => {
@@ -413,7 +418,7 @@ describe("CodexAppServerClient", () => {
413418
});
414419

415420
await expect(initializing).rejects.toThrow(
416-
`Codex app-server ${CODEX_APP_SERVER_VERSION} is required`,
421+
`A Codex app-server from ${MIN_SUPPORTED_CODEX_APP_SERVER_VERSION} through ${MAX_SUPPORTED_CODEX_APP_SERVER_VERSION} is required`,
417422
);
418423
expect(harness.writes).toHaveLength(1);
419424
});
@@ -426,31 +431,72 @@ describe("CodexAppServerClient", () => {
426431
});
427432

428433
await expect(initializing).rejects.toThrow(
429-
`Codex app-server ${CODEX_APP_SERVER_VERSION} is required`,
434+
`A Codex app-server from ${MIN_SUPPORTED_CODEX_APP_SERVER_VERSION} through ${MAX_SUPPORTED_CODEX_APP_SERVER_VERSION} is required`,
430435
);
431436
expect(harness.writes).toHaveLength(1);
432437
});
433438

434-
it("blocks stable Codex app-server versions newer than generated schemas", async () => {
435-
const newerVersion = "0.146.2";
436-
const { harness, initializing, outbound } = startInitialize();
437-
harness.send({
438-
id: outbound.id,
439-
result: { userAgent: `openclaw/${newerVersion} (macOS; test)` },
440-
});
441-
442-
await expect(initializing).rejects.toThrow(
443-
`Codex app-server ${CODEX_APP_SERVER_VERSION} is required`,
444-
);
445-
expect(harness.writes).toHaveLength(1);
446-
});
439+
it.each(["0.148.0-alpha.9", MAX_SUPPORTED_CODEX_APP_SERVER_VERSION])(
440+
"accepts tested Codex Desktop prerelease %s for normal startup validation",
441+
async (newerVersion) => {
442+
const warn = vi.spyOn(embeddedAgentLog, "warn").mockImplementation(() => undefined);
443+
const { harness, initializing, outbound } = startInitialize();
444+
harness.send({
445+
id: outbound.id,
446+
result: { userAgent: `openclaw/${newerVersion} (macOS; test)` },
447+
});
448+
449+
await expect(initializing).resolves.toBeUndefined();
450+
expect(harness.client.getServerVersion()).toBe(newerVersion);
451+
expect(JSON.parse(harness.writes[1] ?? "{}")).toEqual({ method: "initialized" });
452+
expect(warn).toHaveBeenCalledWith(
453+
"codex app-server is newer than OpenClaw's managed runtime; continuing with normal startup validation",
454+
{
455+
detectedVersion: newerVersion,
456+
validatedVersion: CODEX_APP_SERVER_VERSION,
457+
},
458+
);
459+
},
460+
);
461+
462+
it.each(["0.148.0-alpha.16", "0.148.0", "1.0.0"])(
463+
"blocks unverified future app-server version %s during initialize",
464+
async (version) => {
465+
const { harness, initializing, outbound } = startInitialize();
466+
harness.send({
467+
id: outbound.id,
468+
result: { userAgent: `openclaw/${version} (macOS; test)` },
469+
});
470+
471+
await expect(initializing).rejects.toThrow(
472+
`through ${MAX_SUPPORTED_CODEX_APP_SERVER_VERSION} is required`,
473+
);
474+
expect(harness.writes).toHaveLength(1);
475+
},
476+
);
477+
478+
it.each(["0.147.00", "0.148.0-alpha..9", "0.148.0-alpha.09"])(
479+
"blocks malformed app-server version %s during initialize",
480+
async (version) => {
481+
const { harness, initializing, outbound } = startInitialize();
482+
harness.send({
483+
id: outbound.id,
484+
result: { userAgent: `openclaw/${version} (macOS; test)` },
485+
});
486+
487+
await expect(initializing).rejects.toThrow(
488+
`A Codex app-server from ${MIN_SUPPORTED_CODEX_APP_SERVER_VERSION} through ${MAX_SUPPORTED_CODEX_APP_SERVER_VERSION} is required`,
489+
);
490+
expect(harness.writes).toHaveLength(1);
491+
},
492+
);
447493

448494
it("blocks app-server initialize responses without a version", async () => {
449495
const { harness, initializing, outbound } = startInitialize();
450496
harness.send({ id: outbound.id, result: {} });
451497

452498
await expect(initializing).rejects.toThrow(
453-
`Codex app-server ${CODEX_APP_SERVER_VERSION} is required`,
499+
`A Codex app-server from ${MIN_SUPPORTED_CODEX_APP_SERVER_VERSION} through ${MAX_SUPPORTED_CODEX_APP_SERVER_VERSION} is required`,
454500
);
455501
expect(harness.writes).toHaveLength(1);
456502
});

‎extensions/codex/src/app-server/client.ts‎

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import { embeddedAgentLog, OPENCLAW_VERSION } from "openclaw/plugin-sdk/agent-ha
88
import { coerceErrorMessage, toStringifiedError } from "openclaw/plugin-sdk/error-runtime";
99
import { normalizeOptionalString } from "openclaw/plugin-sdk/string-coerce-runtime";
1010
import { sliceUtf16Safe, truncateUtf16Safe } from "openclaw/plugin-sdk/text-utility-runtime";
11+
import { parse as parseSemver } from "semver";
1112
import { resolveCodexAppServerRuntimeOptions, type CodexAppServerStartOptions } from "./config.js";
1213
import {
1314
type CodexAppServerRequestMethod,
@@ -30,7 +31,11 @@ import {
3031
closeCodexAppServerTransportAndWait,
3132
type CodexAppServerTransport,
3233
} from "./transport.js";
33-
import { CODEX_APP_SERVER_VERSION } from "./version.js";
34+
import {
35+
CODEX_APP_SERVER_VERSION,
36+
MAX_SUPPORTED_CODEX_APP_SERVER_VERSION,
37+
MIN_SUPPORTED_CODEX_APP_SERVER_VERSION,
38+
} from "./version.js";
3439

3540
const CODEX_APP_SERVER_PARSE_LOG_MAX = 500;
3641
const CODEX_APP_SERVER_PARSE_BUFFER_MAX = 8 * 1024 * 1024;
@@ -999,7 +1004,7 @@ class CodexAppServerVersionError extends Error {
9991004
? `detected ${detectedVersion}`
10001005
: "OpenClaw could not determine the running Codex version";
10011006
super(
1002-
`Codex app-server ${CODEX_APP_SERVER_VERSION} is required, but ${detected}. Update the configured Codex app-server binary, or remove custom command overrides to use the managed binary.`,
1007+
`A Codex app-server from ${MIN_SUPPORTED_CODEX_APP_SERVER_VERSION} through ${MAX_SUPPORTED_CODEX_APP_SERVER_VERSION} is required, but ${detected}. Update the configured Codex app-server binary, or remove custom command overrides to use the managed binary.`,
10031008
);
10041009
this.name = "CodexAppServerVersionError";
10051010
this.detectedVersion = detectedVersion;
@@ -1008,9 +1013,26 @@ class CodexAppServerVersionError extends Error {
10081013

10091014
function assertSupportedCodexAppServerVersion(response: CodexInitializeResponse): string {
10101015
const detectedVersion = readCodexVersionFromUserAgent(response.userAgent);
1011-
if (detectedVersion !== CODEX_APP_SERVER_VERSION) {
1016+
if (!detectedVersion) {
1017+
throw new CodexAppServerVersionError(detectedVersion);
1018+
}
1019+
const detected = parseSemver(detectedVersion);
1020+
if (
1021+
!detected ||
1022+
detected.compare(MIN_SUPPORTED_CODEX_APP_SERVER_VERSION) < 0 ||
1023+
detected.compare(MAX_SUPPORTED_CODEX_APP_SERVER_VERSION) > 0
1024+
) {
10121025
throw new CodexAppServerVersionError(detectedVersion);
10131026
}
1027+
if (detected.compare(CODEX_APP_SERVER_VERSION) > 0) {
1028+
embeddedAgentLog.warn(
1029+
"codex app-server is newer than OpenClaw's managed runtime; continuing with normal startup validation",
1030+
{
1031+
detectedVersion,
1032+
validatedVersion: CODEX_APP_SERVER_VERSION,
1033+
},
1034+
);
1035+
}
10141036
return detectedVersion;
10151037
}
10161038

‎extensions/codex/src/app-server/shared-client.test.ts‎

Lines changed: 35 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,11 @@ import type { CodexAppServerStartOptions } from "./config.js";
99
import { acquireCodexNativeConfigFence } from "./native-config-fence.js";
1010
import { codexNativeSubagentMonitorRuntime } from "./native-subagent-monitor.js";
1111
import { createClientHarness } from "./test-support.js";
12-
import { CODEX_APP_SERVER_VERSION } from "./version.js";
12+
import {
13+
CODEX_APP_SERVER_VERSION,
14+
MAX_SUPPORTED_CODEX_APP_SERVER_VERSION,
15+
MIN_SUPPORTED_CODEX_APP_SERVER_VERSION,
16+
} from "./version.js";
1317

1418
const mocks = vi.hoisted(() => ({
1519
bridgeCodexAppServerStartOptions: vi.fn(async ({ startOptions }) => startOptions),
@@ -279,7 +283,7 @@ describe("shared Codex app-server client", () => {
279283
await sendInitializeResult(harness, "openclaw/0.117.9 (macOS; test)");
280284

281285
await expect(listPromise).rejects.toThrow(
282-
`Codex app-server ${CODEX_APP_SERVER_VERSION} is required`,
286+
`A Codex app-server from ${MIN_SUPPORTED_CODEX_APP_SERVER_VERSION} through ${MAX_SUPPORTED_CODEX_APP_SERVER_VERSION} is required`,
283287
);
284288
expect(harness.process.stdin.destroyed).toBe(true);
285289
startSpy.mockRestore();
@@ -508,6 +512,35 @@ describe("shared Codex app-server client", () => {
508512
expect(pluginLocal.process.stdin.destroyed).toBe(true);
509513
});
510514

515+
it("keeps a newer desktop app-server instead of falling back by version", async () => {
516+
const desktop = createClientHarness();
517+
const startSpy = vi.spyOn(CodexAppServerClient, "start").mockReturnValueOnce(desktop.client);
518+
const startOptions = configureManagedDesktopFallback();
519+
520+
const acquire = getSharedCodexAppServerClient({ startOptions, timeoutMs: 1_000 });
521+
await sendInitializeResult(desktop, "openclaw/0.148.0-alpha.9 (macOS; test)");
522+
const client = await acquire;
523+
524+
expect(client).toBe(desktop.client);
525+
expect(startSpy).toHaveBeenCalledTimes(1);
526+
expect(startSpy.mock.calls[0]?.[0]).toMatchObject({
527+
command: "/Applications/Codex.app/Contents/Resources/codex",
528+
commandSource: "resolved-managed",
529+
managedFallbackCommandPaths: ["/cache/openclaw/codex"],
530+
});
531+
expect(desktop.process.stdin.destroyed).toBe(false);
532+
expect(mocks.embeddedAgentLog.warn).toHaveBeenCalledWith(
533+
"codex app-server is newer than OpenClaw's managed runtime; continuing with normal startup validation",
534+
{
535+
detectedVersion: "0.148.0-alpha.9",
536+
validatedVersion: CODEX_APP_SERVER_VERSION,
537+
},
538+
);
539+
540+
await clearSharedCodexAppServerClientAndWait({ exitTimeoutMs: 25, forceKillDelayMs: 5 });
541+
expect(desktop.process.stdin.destroyed).toBe(true);
542+
});
543+
511544
it("shares a managed fallback with a waiter that arrives during fallback initialize", async () => {
512545
const desktop = createClientHarness();
513546
const fallback = createClientHarness();
Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,13 @@
11
/**
22
* Version and package pins for the managed Codex app-server runtime.
33
*/
4-
/** Exact Codex app-server version shipped and supported by the OpenClaw Codex bridge. */
4+
/** Exact Codex app-server version shipped by the OpenClaw Codex bridge. */
55
export const CODEX_APP_SERVER_VERSION = "0.147.0";
6+
/** Inclusive runtime compatibility floor for external app-server binaries. */
7+
export const MIN_SUPPORTED_CODEX_APP_SERVER_VERSION = "0.147.0";
8+
/** Inclusive runtime compatibility ceiling for external app-server binaries. */
9+
// The ceiling is the newest Desktop build covered by upstream source inspection and
10+
// a live Computer Use flow. Raising it requires equivalent protocol and live proof.
11+
export const MAX_SUPPORTED_CODEX_APP_SERVER_VERSION = "0.148.0-alpha.15";
612
/** npm package name for the managed Codex app-server binary. */
713
export const MANAGED_CODEX_APP_SERVER_PACKAGE = "@openai/codex";

‎extensions/codex/src/manifest.test.ts‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ describe("codex package manifest", () => {
2424

2525
expect(packageJson.devDependencies).toHaveProperty("@openclaw/plugin-sdk");
2626
expect(packageJson.dependencies?.["@openai/codex"]).toBe(CODEX_APP_SERVER_VERSION);
27-
expect(packageJson.dependencies).not.toHaveProperty("semver");
2827
expect(packageJson.openclaw?.release?.requireLatestDependencies).toEqual(["@openai/codex"]);
2928
expect(packageJson.openclaw?.install?.requiredPlatformPackages).toEqual([
3029
"@openai/codex-linux-x64",

0 commit comments

Comments
 (0)