From ef828d55af13a1237939cf8e1bb93b852439ee47 Mon Sep 17 00:00:00 2001 From: Vincent Koc Date: Sun, 26 Apr 2026 21:01:22 -0700 Subject: [PATCH] test(live): accept current Codex status text Accept current Codex harness status prose while still requiring the OpenClaw status shape, active model, and live harness session. --- ...gateway-codex-harness.live-helpers.test.ts | 19 +++++++++++ .../gateway-codex-harness.live-helpers.ts | 33 +++++++++++++++++++ .../gateway-codex-harness.live.test.ts | 17 +++------- 3 files changed, 56 insertions(+), 13 deletions(-) diff --git a/src/gateway/gateway-codex-harness.live-helpers.test.ts b/src/gateway/gateway-codex-harness.live-helpers.test.ts index caa5ef46d15..265ad217cf4 100644 --- a/src/gateway/gateway-codex-harness.live-helpers.test.ts +++ b/src/gateway/gateway-codex-harness.live-helpers.test.ts @@ -1,10 +1,29 @@ import { describe, expect, it } from "vitest"; import { EXPECTED_CODEX_MODELS_COMMAND_TEXT, + EXPECTED_CODEX_STATUS_COMMAND_TEXT, isExpectedCodexModelsCommandText, + isExpectedCodexStatusCommandText, } from "./gateway-codex-harness.live-helpers.js"; describe("gateway codex harness live helpers", () => { + it("accepts the current codex status prose from the live harness", () => { + const text = + "OpenClaw is running on `openai/gpt-5.5` with low reasoning/text settings. Context is at `22k/272k` tokens, no compactions, and the current session is `agent:dev:live-codex-harness`."; + + expect( + EXPECTED_CODEX_STATUS_COMMAND_TEXT.some((expectedText) => text.includes(expectedText)), + ).toBe(false); + expect(isExpectedCodexStatusCommandText(text)).toBe(true); + }); + + it("rejects status prose for a different codex session", () => { + const text = + "OpenClaw is running on `openai/gpt-5.5` with low reasoning/text settings. Context is at `22k/272k` tokens, no compactions, and the current session is `agent:dev:other`."; + + expect(isExpectedCodexStatusCommandText(text)).toBe(false); + }); + it("accepts the interactive model-selection summary emitted by current codex", () => { const text = [ "`/codex models` opened an interactive model-selection prompt rather than printing a plain list.", diff --git a/src/gateway/gateway-codex-harness.live-helpers.ts b/src/gateway/gateway-codex-harness.live-helpers.ts index cee1176fc9c..eb2600fbc26 100644 --- a/src/gateway/gateway-codex-harness.live-helpers.ts +++ b/src/gateway/gateway-codex-harness.live-helpers.ts @@ -71,6 +71,39 @@ export const EXPECTED_CODEX_MODELS_COMMAND_TEXT = [ "Current OpenClaw session status reports the active model as:", ] as const; +export const EXPECTED_CODEX_STATUS_COMMAND_TEXT = [ + "Codex app-server:", + "Model: `codex/", + "Model: codex/", + "Session: `agent:dev:live-codex-harness`", + "Session: agent:dev:live-codex-harness", + "OpenClaw `", + "OpenClaw status:", + "model `codex/", + "session `agent:dev:live-codex-harness`", + "Model/status card shown above", + "Status shown above.", +] as const; + +export function isExpectedCodexStatusCommandText(text: string): boolean { + const normalized = text.toLowerCase(); + const mentionsOpenClawStatus = + normalized.includes("openclaw is running on") || normalized.includes("openclaw status:"); + const mentionsHarnessSession = + normalized.includes("session: `agent:dev:live-codex-harness`") || + normalized.includes("session: agent:dev:live-codex-harness") || + normalized.includes("session `agent:dev:live-codex-harness`") || + normalized.includes("current session is `agent:dev:live-codex-harness`") || + normalized.includes("current session is agent:dev:live-codex-harness"); + const mentionsModel = + normalized.includes("`openai/") || + normalized.includes(" openai/") || + normalized.includes("`codex/") || + normalized.includes(" codex/"); + + return mentionsOpenClawStatus && mentionsHarnessSession && mentionsModel; +} + export function isExpectedCodexModelsCommandText(text: string): boolean { const normalized = text.toLowerCase(); const mentionsCodexModelsCommand = diff --git a/src/gateway/gateway-codex-harness.live.test.ts b/src/gateway/gateway-codex-harness.live.test.ts index 7d4dd944e7c..6d4795f7771 100644 --- a/src/gateway/gateway-codex-harness.live.test.ts +++ b/src/gateway/gateway-codex-harness.live.test.ts @@ -17,7 +17,9 @@ import { } from "./gateway-cli-backend.live-helpers.js"; import { EXPECTED_CODEX_MODELS_COMMAND_TEXT, + EXPECTED_CODEX_STATUS_COMMAND_TEXT, isExpectedCodexModelsCommandText, + isExpectedCodexStatusCommandText, } from "./gateway-codex-harness.live-helpers.js"; import { assertCronJobMatches, @@ -790,19 +792,8 @@ describeLive("gateway live (Codex harness)", () => { client, sessionKey, command: "/codex status", - expectedText: [ - "Codex app-server:", - "Model: `codex/", - "Model: codex/", - "Session: `agent:dev:live-codex-harness`", - "Session: agent:dev:live-codex-harness", - "OpenClaw `", - "OpenClaw status:", - "model `codex/", - "session `agent:dev:live-codex-harness`", - "Model/status card shown above", - "Status shown above.", - ], + expectedText: [...EXPECTED_CODEX_STATUS_COMMAND_TEXT], + isExpectedText: isExpectedCodexStatusCommandText, }); logCodexLiveStep("codex-status-command", { statusText });