From d9bd010e5e6f837a3e03e952182c0574f824ef3f Mon Sep 17 00:00:00 2001 From: Peter Steinberger Date: Sat, 25 Apr 2026 02:15:28 +0100 Subject: [PATCH] test: cover codex harness session history pinning --- .../auth-profile-runtime-contract.test.ts | 30 ++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/src/agents/auth-profile-runtime-contract.test.ts b/src/agents/auth-profile-runtime-contract.test.ts index a7709644a90..4d1888e6630 100644 --- a/src/agents/auth-profile-runtime-contract.test.ts +++ b/src/agents/auth-profile-runtime-contract.test.ts @@ -115,6 +115,7 @@ async function runAuthContractAttempt(params: { authProfileProvider: string; authProfileOverride: string; cfg?: OpenClawConfig; + sessionHasHistory?: boolean; }) { const cfg = params.cfg ?? ({} as OpenClawConfig); const sessionEntry: SessionEntry = { @@ -154,7 +155,7 @@ async function runAuthContractAttempt(params: { authProfileProvider: params.authProfileProvider, sessionStore, storePath: params.storePath, - sessionHasHistory: false, + sessionHasHistory: params.sessionHasHistory ?? false, }); return { @@ -403,4 +404,31 @@ describe("Auth profile runtime contract - Pi and CLI adapter", () => { authProfileId: AUTH_PROFILE_RUNTIME_CONTRACT.openAiCodexProfileId, }); }); + + it("preserves configured Codex harness when a skeleton session entry is considered history", async () => { + await runAuthContractAttempt({ + tmpDir, + storePath, + providerOverride: AUTH_PROFILE_RUNTIME_CONTRACT.openAiProvider, + authProfileProvider: AUTH_PROFILE_RUNTIME_CONTRACT.openAiCodexProvider, + authProfileOverride: AUTH_PROFILE_RUNTIME_CONTRACT.openAiCodexProfileId, + sessionHasHistory: true, + cfg: { + agents: { + list: [ + { + id: "main", + embeddedHarness: { runtime: "codex", fallback: "none" }, + }, + ], + }, + } as OpenClawConfig, + }); + + expect(runEmbeddedPiAgentMock).toHaveBeenCalledTimes(1); + expect(runEmbeddedPiAgentMock.mock.calls[0]?.[0]).toMatchObject({ + agentHarnessId: "codex", + authProfileId: AUTH_PROFILE_RUNTIME_CONTRACT.openAiCodexProfileId, + }); + }); });