
































@@ -1,24 +1,37 @@
11import fs from "node:fs/promises";
22import os from "node:os";
33import path from "node:path";
4-import { afterEach, beforeEach, describe, expect, it } from "vitest";
4+import { clearRuntimeAuthProfileStoreSnapshots } from "openclaw/plugin-sdk/agent-runtime";
5+import { upsertAuthProfile } from "openclaw/plugin-sdk/provider-auth";
6+import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
57import {
68readCodexAppServerBinding,
79writeCodexAppServerBinding,
810} from "./app-server/session-binding.js";
911import {
1012setCodexConversationFastMode,
13+setCodexConversationModel,
1114setCodexConversationPermissions,
1215} from "./conversation-control.js";
13161417let tempDir: string;
151819+const sharedClientMocks = vi.hoisted(() => ({
20+getSharedCodexAppServerClient: vi.fn(),
21+}));
22+23+vi.mock("./app-server/shared-client.js", () => sharedClientMocks);
24+1625describe("codex conversation controls", () => {
1726beforeEach(async () => {
1827tempDir = await fs.mkdtemp(path.join(os.tmpdir(), "openclaw-codex-control-"));
28+vi.stubEnv("OPENCLAW_STATE_DIR", tempDir);
29+sharedClientMocks.getSharedCodexAppServerClient.mockReset();
1930});
20312132afterEach(async () => {
33+vi.unstubAllEnvs();
34+clearRuntimeAuthProfileStoreSnapshots();
2235await fs.rm(tempDir, { recursive: true, force: true });
2336});
2437@@ -47,4 +60,46 @@ describe("codex conversation controls", () => {
4760sandbox: "workspace-write",
4861});
4962});
63+64+it("does not persist public OpenAI provider after model changes on native auth bindings", async () => {
65+const sessionFile = path.join(tempDir, "session.jsonl");
66+upsertAuthProfile({
67+profileId: "work",
68+credential: {
69+type: "oauth",
70+provider: "openai-codex",
71+access: "access-token",
72+refresh: "refresh-token",
73+expires: Date.now() + 60_000,
74+},
75+});
76+await writeCodexAppServerBinding(sessionFile, {
77+threadId: "thread-1",
78+cwd: tempDir,
79+authProfileId: "work",
80+model: "gpt-5.4",
81+modelProvider: "openai",
82+});
83+sharedClientMocks.getSharedCodexAppServerClient.mockResolvedValue({
84+request: vi.fn(async () => ({
85+thread: { id: "thread-1", cwd: tempDir },
86+model: "gpt-5.5",
87+modelProvider: "openai",
88+})),
89+});
90+91+await expect(setCodexConversationModel({ sessionFile, model: "gpt-5.5" })).resolves.toBe(
92+"Codex model set to gpt-5.5.",
93+);
94+95+const raw = await fs.readFile(`${sessionFile}.codex-app-server.json`, "utf8");
96+const binding = await readCodexAppServerBinding(sessionFile);
97+expect(raw).not.toContain('"modelProvider": "openai"');
98+expect(binding).toMatchObject({
99+threadId: "thread-1",
100+authProfileId: "work",
101+model: "gpt-5.5",
102+});
103+expect(binding?.modelProvider).toBeUndefined();
104+});
50105});
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。