diff --git a/src/config/plugin-auto-enable.core.test.ts b/src/config/plugin-auto-enable.core.test.ts index 1f397085157..cd6d49f6598 100644 --- a/src/config/plugin-auto-enable.core.test.ts +++ b/src/config/plugin-auto-enable.core.test.ts @@ -228,6 +228,94 @@ describe("applyPluginAutoEnable core", () => { expect(result.changes).toContain("codex/gpt-5.4 model configured, enabled automatically."); }); + it("does not auto-enable Codex when only the OpenAI plugin is explicitly enabled", () => { + const result = applyPluginAutoEnable({ + config: { + plugins: { + allow: ["openai"], + entries: { + openai: { enabled: true }, + }, + }, + }, + env, + manifestRegistry: makeRegistry([ + { id: "openai", channels: [], providers: ["openai", "openai-codex"] }, + { + id: "codex", + channels: [], + providers: ["codex"], + activation: { onAgentHarnesses: ["codex"] }, + }, + ]), + }); + + expect(result.config.plugins?.entries?.codex).toBeUndefined(); + expect(result.config.plugins?.allow).toEqual(["openai"]); + expect(result.changes).toEqual([]); + }); + + it("keeps OpenAI Codex OAuth model refs owned by the OpenAI plugin", () => { + const result = applyPluginAutoEnable({ + config: { + agents: { + defaults: { + model: "openai-codex/gpt-5.5", + }, + }, + }, + env, + manifestRegistry: makeRegistry([ + { id: "openai", channels: [], providers: ["openai", "openai-codex"] }, + { + id: "codex", + channels: [], + providers: ["codex"], + activation: { onAgentHarnesses: ["codex"] }, + }, + ]), + }); + + expect(result.config.plugins?.entries?.openai?.enabled).toBe(true); + expect(result.config.plugins?.entries?.codex).toBeUndefined(); + expect(result.changes).toEqual([ + "openai-codex/gpt-5.5 model configured, enabled automatically.", + ]); + }); + + it("auto-enables Codex only for the native Codex harness with OpenAI model refs", () => { + const result = applyPluginAutoEnable({ + config: { + agents: { + defaults: { + model: "openai/gpt-5.5", + embeddedHarness: { + runtime: "codex", + fallback: "none", + }, + }, + }, + }, + env, + manifestRegistry: makeRegistry([ + { id: "openai", channels: [], providers: ["openai", "openai-codex"] }, + { + id: "codex", + channels: [], + providers: ["codex"], + activation: { onAgentHarnesses: ["codex"] }, + }, + ]), + }); + + expect(result.config.plugins?.entries?.openai?.enabled).toBe(true); + expect(result.config.plugins?.entries?.codex?.enabled).toBe(true); + expect(result.changes).toEqual([ + "openai/gpt-5.5 model configured, enabled automatically.", + "codex agent harness runtime configured, enabled automatically.", + ]); + }); + it("auto-enables an opt-in plugin when an embedded agent harness runtime is configured", () => { const result = applyPluginAutoEnable({ config: {