diff --git a/src/gateway/gateway-codex-harness.live.test.ts b/src/gateway/gateway-codex-harness.live.test.ts index 80ebb9fa880b..b88f6f29acc4 100644 --- a/src/gateway/gateway-codex-harness.live.test.ts +++ b/src/gateway/gateway-codex-harness.live.test.ts @@ -276,11 +276,11 @@ function resolveCodexHarnessThinkingLevel(raw: string | undefined): CodexHarness return normalized as CodexHarnessThinkingLevel; } -function resolveCodexHarnessExpectedEffort(modelId: string): string | null { +function resolveCodexHarnessExpectedRequestEffort(modelId: string): string | null { const configured = process.env.OPENCLAW_LIVE_CODEX_HARNESS_EXPECTED_EFFORT; if (configured?.trim()) { const expected = resolveCodexHarnessThinkingLevel(configured); - return expected === "off" ? null : expected; + return expected === "off" ? null : expected === "ultra" ? "max" : expected; } const supported = CODEX_HARNESS_SUPPORTED_EFFORTS.get(modelId); if (!supported) { @@ -289,14 +289,14 @@ function resolveCodexHarnessExpectedEffort(modelId: string): string | null { if (CODEX_HARNESS_THINKING === "off") { return null; } - // Independent oracle for the pinned Codex model catalog. Lower requested - // levels choose the nearest advertised effort; Ultra remains explicit. + // Codex preserves Ultra in config but intentionally sends Max to the model. + // Compare the request-facing lifecycle event to that wire contract. const candidates = CODEX_HARNESS_THINKING === "ultra" ? supported : supported.filter((effort) => effort !== "ultra"); const requestedRank = CODEX_HARNESS_REASONING_EFFORTS.indexOf(CODEX_HARNESS_THINKING); - return ( + const configuredEffort = candidates.find( (effort) => CODEX_HARNESS_REASONING_EFFORTS.indexOf( @@ -304,8 +304,8 @@ function resolveCodexHarnessExpectedEffort(modelId: string): string | null { ) >= requestedRank, ) ?? candidates.at(-1) ?? - null - ); + null; + return configuredEffort === "ultra" ? "max" : configuredEffort; } function logCodexLiveStep(step: string, details?: Record): void { @@ -846,7 +846,7 @@ function recordCodexAttemptIdentity(params: { expect(turnStarting?.data).toMatchObject({ model: expectedModel }); const actualEffort = turnStarting?.data?.effort; const actualCollaborationEffort = turnStarting?.data?.collaborationEffort; - const expectedEffort = resolveCodexHarnessExpectedEffort(expectedModel); + const expectedEffort = resolveCodexHarnessExpectedRequestEffort(expectedModel); expect(actualEffort ?? null).toBe(expectedEffort); expect(actualCollaborationEffort ?? null).toBe(actualEffort ?? null); if (CODEX_HARNESS_FULL_CONTEXT) {