refactor: narrow codex harness selection

This commit is contained in:
Peter Steinberger
2026-04-11 00:11:15 +01:00
parent cfae8fd1e9
commit 47c0ce5f85
5 changed files with 25 additions and 12 deletions

View File

@@ -99,9 +99,9 @@ OpenClaw may fall back to PI when the selected plugin harness fails before a
turn has produced side effects. Set `OPENCLAW_AGENT_HARNESS_FALLBACK=none` or
`embeddedHarness.fallback: "none"` to make that fallback a hard failure instead.
The bundled Codex plugin registers `codex` as its harness id. For compatibility,
`codex-app-server` and `app-server` also resolve to that same harness when you
set `OPENCLAW_AGENT_RUNTIME` manually.
The bundled Codex plugin registers `codex` as its harness id. Core treats that
as an ordinary plugin harness id; Codex-specific aliases belong in the plugin
or operator config, not in the shared runtime selector.
## Provider plus harness pairing

View File

@@ -10,7 +10,7 @@ import { runCodexAppServerAttempt } from "./src/app-server/run-attempt.js";
import { clearCodexAppServerBinding } from "./src/app-server/session-binding.js";
import { clearSharedCodexAppServerClient } from "./src/app-server/shared-client.js";
const DEFAULT_CODEX_HARNESS_PROVIDER_IDS = new Set(["codex", "openai-codex"]);
const DEFAULT_CODEX_HARNESS_PROVIDER_IDS = new Set(["codex"]);
export type { CodexAppServerListModelsOptions, CodexAppServerModel, CodexAppServerModelListResult };
export { listCodexAppServerModels };

View File

@@ -1,6 +1,7 @@
import fs from "node:fs";
import { describe, expect, it, vi } from "vitest";
import { createTestPluginApi } from "../../test/helpers/plugins/plugin-api.js";
import { createCodexAppServerAgentHarness } from "./harness.js";
import plugin from "./index.js";
describe("codex plugin", () => {
@@ -42,4 +43,20 @@ describe("codex plugin", () => {
description: "Inspect and control the Codex app-server harness",
});
});
it("only claims the codex provider by default", () => {
const harness = createCodexAppServerAgentHarness();
expect(
harness.supports({ provider: "codex", modelId: "gpt-5.4", requestedRuntime: "auto" })
.supported,
).toBe(true);
expect(
harness.supports({
provider: "openai-codex",
modelId: "gpt-5.4",
requestedRuntime: "auto",
}),
).toMatchObject({ supported: false });
});
});

View File

@@ -10,12 +10,11 @@ describe("resolveEmbeddedAgentRuntime", () => {
expect(resolveEmbeddedAgentRuntime({ OPENCLAW_AGENT_RUNTIME: "pi" })).toBe("pi");
});
it("accepts codex app-server aliases", () => {
expect(resolveEmbeddedAgentRuntime({ OPENCLAW_AGENT_RUNTIME: "codex-app-server" })).toBe(
"codex",
);
it("preserves plugin harness ids without core-owned aliases", () => {
expect(resolveEmbeddedAgentRuntime({ OPENCLAW_AGENT_RUNTIME: "codex" })).toBe("codex");
expect(resolveEmbeddedAgentRuntime({ OPENCLAW_AGENT_RUNTIME: "app-server" })).toBe("codex");
expect(resolveEmbeddedAgentRuntime({ OPENCLAW_AGENT_RUNTIME: "codex-app-server" })).toBe(
"codex-app-server",
);
});
it("accepts auto mode", () => {

View File

@@ -9,9 +9,6 @@ export function normalizeEmbeddedAgentRuntime(raw: string | undefined): Embedded
if (value === "pi") {
return "pi";
}
if (value === "codex" || value === "codex-app-server" || value === "app-server") {
return "codex";
}
if (value === "auto") {
return "auto";
}