perf(compaction): reuse message update parts for no-text tails

Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
This commit is contained in:
YeonGyu-Kim
2026-04-28 17:59:50 +09:00
parent ece8fd4f25
commit eb722aa977
4 changed files with 34 additions and 1 deletions
@@ -192,4 +192,28 @@ describe("preemptive-compaction post-compaction degradation monitor", () => {
// then
expect(ctx.client.session.summarize).not.toHaveBeenCalled()
})
it("uses message update parts without refetching session messages", async () => {
// given
const sessionHistory: AssistantHistoryMessage[] = []
const ctx = createMockCtx(sessionHistory)
const hook = createPreemptiveCompactionHook(ctx as never, {} as never)
const sessionID = "ses_tail_update_parts"
const stepOnlyParts = [{ type: "step-start" }, { type: "step-finish" }]
await hook.event({
event: {
type: "session.compacted",
properties: { sessionID },
},
})
// when
await hook.event(buildAssistantUpdate({ sessionID, id: "msg_1", parts: stepOnlyParts }))
await hook.event(buildAssistantUpdate({ sessionID, id: "msg_2", parts: stepOnlyParts }))
// then
expect(ctx.client.session.messages).not.toHaveBeenCalled()
expect(ctx.client.session.summarize).not.toHaveBeenCalled()
})
})