prompt-variant.test.ts 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. import { describe, expect, test } from "bun:test"
  2. import { Instance } from "../../src/project/instance"
  3. import { Session } from "../../src/session"
  4. import { SessionPrompt } from "../../src/session/prompt"
  5. import { tmpdir } from "../fixture/fixture"
  6. describe("session.prompt agent variant", () => {
  7. test("applies agent variant only when using agent model", async () => {
  8. await using tmp = await tmpdir({
  9. git: true,
  10. config: {
  11. agent: {
  12. build: {
  13. model: "openai/gpt-5.2",
  14. variant: "xhigh",
  15. },
  16. },
  17. },
  18. })
  19. await Instance.provide({
  20. directory: tmp.path,
  21. fn: async () => {
  22. const session = await Session.create({})
  23. const other = await SessionPrompt.prompt({
  24. sessionID: session.id,
  25. agent: "build",
  26. model: { providerID: "opencode", modelID: "kimi-k2.5-free" },
  27. noReply: true,
  28. parts: [{ type: "text", text: "hello" }],
  29. })
  30. if (other.info.role !== "user") throw new Error("expected user message")
  31. expect(other.info.variant).toBeUndefined()
  32. const match = await SessionPrompt.prompt({
  33. sessionID: session.id,
  34. agent: "build",
  35. noReply: true,
  36. parts: [{ type: "text", text: "hello again" }],
  37. })
  38. if (match.info.role !== "user") throw new Error("expected user message")
  39. expect(match.info.model).toEqual({ providerID: "openai", modelID: "gpt-5.2" })
  40. expect(match.info.variant).toBe("xhigh")
  41. const override = await SessionPrompt.prompt({
  42. sessionID: session.id,
  43. agent: "build",
  44. noReply: true,
  45. variant: "high",
  46. parts: [{ type: "text", text: "hello third" }],
  47. })
  48. if (override.info.role !== "user") throw new Error("expected user message")
  49. expect(override.info.variant).toBe("high")
  50. await Session.remove(session.id)
  51. },
  52. })
  53. })
  54. })