diff options
| author | Aiden Cline <[email protected]> | 2026-02-09 11:25:22 -0600 |
|---|---|---|
| committer | GitHub <[email protected]> | 2026-02-09 11:25:22 -0600 |
| commit | f74c0339cc6315f7e7743e26b7eab47ce026c239 (patch) | |
| tree | 0239e7a1153d993df47ddcf987c7bdf24f51650f | |
| parent | fb94b4f8e86a2a1e7ce8586d10912d80724888da (diff) | |
| download | opencode-f74c0339cc6315f7e7743e26b7eab47ce026c239.tar.gz opencode-f74c0339cc6315f7e7743e26b7eab47ce026c239.zip | |
test: fix failing prompt test (#12847)
| -rw-r--r-- | packages/opencode/test/session/prompt-variant.test.ts | 94 |
1 files changed, 51 insertions, 43 deletions
diff --git a/packages/opencode/test/session/prompt-variant.test.ts b/packages/opencode/test/session/prompt-variant.test.ts index 16e8a2244..83ae175c6 100644 --- a/packages/opencode/test/session/prompt-variant.test.ts +++ b/packages/opencode/test/session/prompt-variant.test.ts @@ -6,55 +6,63 @@ import { tmpdir } from "../fixture/fixture" describe("session.prompt agent variant", () => { test("applies agent variant only when using agent model", async () => { - await using tmp = await tmpdir({ - git: true, - config: { - agent: { - build: { - model: "openai/gpt-5.2", - variant: "xhigh", + const prev = process.env.OPENAI_API_KEY + process.env.OPENAI_API_KEY = "test-openai-key" + + try { + await using tmp = await tmpdir({ + git: true, + config: { + agent: { + build: { + model: "openai/gpt-5.2", + variant: "xhigh", + }, }, }, - }, - }) + }) - await Instance.provide({ - directory: tmp.path, - fn: async () => { - const session = await Session.create({}) + await Instance.provide({ + directory: tmp.path, + fn: async () => { + const session = await Session.create({}) - const other = await SessionPrompt.prompt({ - sessionID: session.id, - agent: "build", - model: { providerID: "opencode", modelID: "kimi-k2.5-free" }, - noReply: true, - parts: [{ type: "text", text: "hello" }], - }) - if (other.info.role !== "user") throw new Error("expected user message") - expect(other.info.variant).toBeUndefined() + const other = await SessionPrompt.prompt({ + sessionID: session.id, + agent: "build", + model: { providerID: "opencode", modelID: "kimi-k2.5-free" }, + noReply: true, + parts: [{ type: "text", text: "hello" }], + }) + if (other.info.role !== "user") throw new Error("expected user message") + expect(other.info.variant).toBeUndefined() - const match = await SessionPrompt.prompt({ - sessionID: session.id, - agent: "build", - noReply: true, - parts: [{ type: "text", text: "hello again" }], - }) - if (match.info.role !== "user") throw new Error("expected user message") - expect(match.info.model).toEqual({ providerID: "openai", modelID: "gpt-5.2" }) - expect(match.info.variant).toBe("xhigh") + const match = await SessionPrompt.prompt({ + sessionID: session.id, + agent: "build", + noReply: true, + parts: [{ type: "text", text: "hello again" }], + }) + if (match.info.role !== "user") throw new Error("expected user message") + expect(match.info.model).toEqual({ providerID: "openai", modelID: "gpt-5.2" }) + expect(match.info.variant).toBe("xhigh") - const override = await SessionPrompt.prompt({ - sessionID: session.id, - agent: "build", - noReply: true, - variant: "high", - parts: [{ type: "text", text: "hello third" }], - }) - if (override.info.role !== "user") throw new Error("expected user message") - expect(override.info.variant).toBe("high") + const override = await SessionPrompt.prompt({ + sessionID: session.id, + agent: "build", + noReply: true, + variant: "high", + parts: [{ type: "text", text: "hello third" }], + }) + if (override.info.role !== "user") throw new Error("expected user message") + expect(override.info.variant).toBe("high") - await Session.remove(session.id) - }, - }) + await Session.remove(session.id) + }, + }) + } finally { + if (prev === undefined) delete process.env.OPENAI_API_KEY + else process.env.OPENAI_API_KEY = prev + } }) }) |
