@@ -2,7 +2,7 @@ import type { AssistantMessage, Context, Model } from "@openclaw/llm-core";
22import { describe , expect , it } from "vitest" ;
33import {
44 buildAnthropicReplayPlan ,
5- captureAnthropicCompaction ,
5+ createCompactionCapture ,
66 isAnthropicReplayRejection ,
77 suppressAnthropicCompaction ,
88} from "./anthropic-compaction-replay.js" ;
@@ -46,9 +46,20 @@ function assistant(texts: string[]): AssistantMessage {
4646 } ;
4747}
4848
49+ function captureCheckpoint (
50+ message : AssistantMessage ,
51+ summary : string ,
52+ replayIndex : number ,
53+ options = replayOptions ,
54+ ) : void {
55+ const capture = createCompactionCapture ( message , model , options ) ;
56+ capture . begin ( 0 , { type : "compaction" , content : summary } , replayIndex ) ;
57+ capture . complete ( 0 ) ;
58+ }
59+
4960function contextWithCheckpoint ( summary = "summary of the earlier conversation" ) : Context {
5061 const checkpoint = assistant ( [ "before checkpoint" , "after checkpoint" ] ) ;
51- captureAnthropicCompaction ( checkpoint , summary , 1 , model , replayOptions ) ;
62+ captureCheckpoint ( checkpoint , summary , 1 ) ;
5263 return {
5364 messages : [
5465 { role : "user" , content : "old question" , timestamp : 0 } ,
@@ -96,7 +107,7 @@ describe("Anthropic compaction replay", () => {
96107 it ( "uses the newest matching checkpoint" , ( ) => {
97108 const context = contextWithCheckpoint ( "older summary" ) ;
98109 const newest = assistant ( [ "latest answer" ] ) ;
99- captureAnthropicCompaction ( newest , "newest summary" , 0 , model , replayOptions ) ;
110+ captureCheckpoint ( newest , "newest summary" , 0 ) ;
100111 context . messages . push ( { role : "user" , content : "middle" , timestamp : 3 } , newest , {
101112 role : "user" ,
102113 content : "latest question" ,
0 commit comments