|
| 1 | +import { describe, expect, test } from "bun:test" |
| 2 | +import { SystemPrompt } from "../../src/session/system" |
| 3 | + |
| 4 | +describe("MITO linearity", () => { |
| 5 | + describe("system prompt stability", () => { |
| 6 | + test("environment() does not contain 'Today's date:'", async () => { |
| 7 | + // SystemPrompt.environment requires Instance to be initialized, so we check |
| 8 | + // the source directly — the date line was removed from system.ts |
| 9 | + const source = await Bun.file( |
| 10 | + new URL("../../src/session/system.ts", import.meta.url).pathname, |
| 11 | + ).text() |
| 12 | + expect(source).not.toContain("Today's date") |
| 13 | + expect(source).not.toContain("toDateString") |
| 14 | + }) |
| 15 | + |
| 16 | + test("provider() returns stable output across calls", () => { |
| 17 | + const model = { |
| 18 | + api: { id: "claude-sonnet-4-20250514" }, |
| 19 | + } as any |
| 20 | + const first = SystemPrompt.provider(model) |
| 21 | + const second = SystemPrompt.provider(model) |
| 22 | + expect(first).toEqual(second) |
| 23 | + }) |
| 24 | + }) |
| 25 | + |
| 26 | + describe("text content preservation", () => { |
| 27 | + test("processor does not trimEnd text content", async () => { |
| 28 | + const source = await Bun.file( |
| 29 | + new URL("../../src/session/processor.ts", import.meta.url).pathname, |
| 30 | + ).text() |
| 31 | + // Neither text-end nor reasoning-end should trimEnd |
| 32 | + expect(source).not.toContain("trimEnd()") |
| 33 | + }) |
| 34 | + }) |
| 35 | + |
| 36 | + describe("tool call repair does not lowercase", () => { |
| 37 | + test("experimental_repairToolCall does not lowercase tool names", async () => { |
| 38 | + const source = await Bun.file( |
| 39 | + new URL("../../src/session/llm.ts", import.meta.url).pathname, |
| 40 | + ).text() |
| 41 | + // The lowercasing branch should be removed |
| 42 | + expect(source).not.toContain("toolName.toLowerCase()") |
| 43 | + }) |
| 44 | + }) |
| 45 | +}) |
0 commit comments