Migrate compaction plugin test (#26736)

This commit is contained in:
Kit Langton
2026-05-10 19:42:44 -04:00
committed by GitHub
parent ca8a42c973
commit a658e43eeb

View File

@@ -1202,48 +1202,37 @@ describe("session.compaction.process", () => {
{ git: true }, { git: true },
) )
test("allows plugins to disable synthetic continue prompt", async () => { itProcess.instance(
await using tmp = await tmpdir() "allows plugins to disable synthetic continue prompt",
await WithInstance.provide({ Effect.gen(function* () {
directory: tmp.path, const ssn = yield* SessionNs.Service
fn: async () => { const session = yield* ssn.create({})
const session = await svc.create({}) const msg = yield* createUserMessage(session.id, "hello")
const msg = await user(session.id, "hello") const msgs = yield* ssn.messages({ sessionID: session.id })
const rt = runtime("continue", autocontinue(false), wide())
try {
const msgs = await svc.messages({ sessionID: session.id })
const result = await rt.runPromise(
SessionCompaction.Service.use((svc) =>
svc.process({
parentID: msg.id,
messages: msgs,
sessionID: session.id,
auto: true,
}),
),
)
const all = await svc.messages({ sessionID: session.id }) const result = yield* SessionCompaction.use.process({
const last = all.at(-1) parentID: msg.id,
messages: msgs,
sessionID: session.id,
auto: true,
})
expect(result).toBe("continue") const all = yield* ssn.messages({ sessionID: session.id })
expect(last?.info.role).toBe("assistant") const last = all.at(-1)
expect(
all.some( expect(result).toBe("continue")
(msg) => expect(last?.info.role).toBe("assistant")
msg.info.role === "user" && expect(
msg.parts.some( all.some(
(part) => (msg) =>
part.type === "text" && part.synthetic && part.text.includes("Continue if you have next steps"), msg.info.role === "user" &&
), msg.parts.some(
(part) => part.type === "text" && part.synthetic && part.text.includes("Continue if you have next steps"),
), ),
).toBe(false) ),
} finally { ).toBe(false)
await rt.dispose() }).pipe(Effect.provide(compactionProcessLayer({ plugin: autocontinue(false) }))),
} )
},
})
})
it.instance( it.instance(
"replays the prior user turn on overflow when earlier context exists", "replays the prior user turn on overflow when earlier context exists",