fix(core): make V2 reads media-aware and binary-safe (#31038)
This commit is contained in:
parent
f750deaa3e
commit
83dca45dd5
26 changed files with 1709 additions and 120 deletions
18
packages/core/test/session-compaction.test.ts
Normal file
18
packages/core/test/session-compaction.test.ts
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
import { expect, test } from "bun:test"
|
||||
import { SessionCompaction } from "@opencode-ai/core/session/compaction"
|
||||
|
||||
test("compaction describes tool media without embedding base64", () => {
|
||||
const base64 = "iVBORw0KGgoAAAANSUhEUgAAAAEAAAAB"
|
||||
const serialized = SessionCompaction.serializeToolContent([
|
||||
{ type: "text", text: "Image read successfully" },
|
||||
{
|
||||
type: "file",
|
||||
source: { type: "data", data: base64 },
|
||||
mime: "image/png",
|
||||
name: "pixel.png",
|
||||
},
|
||||
])
|
||||
|
||||
expect(serialized).toBe("Image read successfully\n[Attached image/png: pixel.png]")
|
||||
expect(serialized).not.toContain(base64)
|
||||
})
|
||||
Loading…
Add table
Add a link
Reference in a new issue