@@ -93,6 +93,67 @@ test("sessions.reset drops cached skills snapshot so /new rebuilds visible skill
9393 expect ( store [ "agent:main:main" ] ?. skillsSnapshot ) . toBeUndefined ( ) ;
9494} ) ;
9595
96+ test ( "sessions.reset clears compaction checkpoint metadata so /new starts clean" , async ( ) => {
97+ const { storePath } = await createSessionStoreDir ( ) ;
98+ testState . agentConfig = {
99+ model : {
100+ primary : "openai/gpt-test-a" ,
101+ } ,
102+ } ;
103+
104+ await writeSessionStore ( {
105+ entries : {
106+ main : sessionStoreEntry ( "sess-compacted" , {
107+ compactionCount : 2 ,
108+ compactionCheckpoints : [
109+ {
110+ checkpointId : "11111111-1111-4111-8111-111111111111" ,
111+ sessionKey : "agent:main:main" ,
112+ sessionId : "sess-compacted" ,
113+ createdAt : Date . now ( ) ,
114+ reason : "auto-threshold" ,
115+ tokensBefore : 123456 ,
116+ summary : "stale summary" ,
117+ preCompaction : {
118+ sessionId : "sess-compacted" ,
119+ sessionFile : path . join ( path . dirname ( storePath ) , "sess-compacted.jsonl" ) ,
120+ } ,
121+ postCompaction : {
122+ sessionId : "sess-compacted" ,
123+ sessionFile : path . join ( path . dirname ( storePath ) , "sess-compacted.jsonl" ) ,
124+ } ,
125+ } ,
126+ ] ,
127+ } ) ,
128+ } ,
129+ } ) ;
130+
131+ const reset = await directSessionReq < {
132+ ok : true ;
133+ key : string ;
134+ entry : {
135+ sessionId : string ;
136+ compactionCount ?: number ;
137+ compactionCheckpoints ?: unknown [ ] ;
138+ } ;
139+ } > ( "sessions.reset" , { key : "main" } ) ;
140+
141+ expect ( reset . ok ) . toBe ( true ) ;
142+ expect ( reset . payload ?. entry . sessionId ) . not . toBe ( "sess-compacted" ) ;
143+ expect ( reset . payload ?. entry . compactionCount ) . toBeUndefined ( ) ;
144+ expect ( reset . payload ?. entry . compactionCheckpoints ) . toBeUndefined ( ) ;
145+
146+ const store = JSON . parse ( await fs . readFile ( storePath , "utf-8" ) ) as Record <
147+ string ,
148+ {
149+ compactionCount ?: number ;
150+ compactionCheckpoints ?: unknown [ ] ;
151+ }
152+ > ;
153+ expect ( store [ "agent:main:main" ] ?. compactionCount ) . toBeUndefined ( ) ;
154+ expect ( store [ "agent:main:main" ] ?. compactionCheckpoints ) . toBeUndefined ( ) ;
155+ } ) ;
156+
96157test ( "sessions.reset preserves legacy explicit model overrides without modelOverrideSource" , async ( ) => {
97158 const { storePath } = await createSessionStoreDir ( ) ;
98159 testState . agentConfig = {
0 commit comments