session-compaction.test.ts 623 B

123456789101112131415161718
  1. import { expect, test } from "bun:test"
  2. import { SessionCompaction } from "@opencode-ai/core/session/compaction"
  3. test("compaction describes tool media without embedding base64", () => {
  4. const base64 = "iVBORw0KGgoAAAANSUhEUgAAAAEAAAAB"
  5. const serialized = SessionCompaction.serializeToolContent([
  6. { type: "text", text: "Image read successfully" },
  7. {
  8. type: "file",
  9. uri: `data:image/png;base64,${base64}`,
  10. mime: "image/png",
  11. name: "pixel.png",
  12. },
  13. ])
  14. expect(serialized).toBe("Image read successfully\n[Attached image/png: pixel.png]")
  15. expect(serialized).not.toContain(base64)
  16. })