@@ -1740,24 +1740,36 @@ describe("maybeCompactCodexAppServerSession", () => {
17401740 } ) ;
17411741 }
17421742
1743- for ( let index = 0 ; index < 4_097 ; index += 1 ) {
1743+ // Fill exactly the advertised 4,096-entry cap: every distinct key warns once.
1744+ for ( let index = 0 ; index < 4_096 ; index += 1 ) {
17441745 await runWithIgnoredOverrides ( index ) ;
17451746 }
1747+ expect ( warn ) . toHaveBeenCalledTimes ( 4_096 ) ;
17461748
1747- expect ( warn ) . toHaveBeenCalledTimes ( 4_097 ) ;
1749+ // At exactly 4,096 entries the oldest key is still retained, so a duplicate stays suppressed.
1750+ await runWithIgnoredOverrides ( 0 ) ;
1751+ expect ( warn ) . toHaveBeenCalledTimes ( 4_096 ) ;
1752+
1753+ // The 4,097th distinct key pushes past the cap and evicts the LRU entry. The duplicate
1754+ // check on key 0 refreshed its recency, so the evicted key is 1.
17481755 await runWithIgnoredOverrides ( 4_096 ) ;
17491756 expect ( warn ) . toHaveBeenCalledTimes ( 4_097 ) ;
17501757
1751- await runWithIgnoredOverrides ( 0 ) ;
1758+ // The evicted key warns again on reappearance.
1759+ await runWithIgnoredOverrides ( 1 ) ;
1760+ expect ( warn ) . toHaveBeenCalledTimes ( 4_098 ) ;
1761+
1762+ // A recent duplicate stays suppressed.
1763+ await runWithIgnoredOverrides ( 4_096 ) ;
17521764 expect ( warn ) . toHaveBeenCalledTimes ( 4_098 ) ;
17531765 expect ( warn . mock . calls . at ( - 1 ) ) . toEqual ( [
17541766 "ignoring OpenClaw compaction overrides for Codex app-server compaction; Codex uses native server-side compaction" ,
17551767 {
1756- sessionId : "session-0 " ,
1757- sessionKey : "agent:cap-0 :session-0 " ,
1768+ sessionId : "session-1 " ,
1769+ sessionKey : "agent:cap-1 :session-1 " ,
17581770 ignoredConfig : [
1759- "agents.list.cap-0 .compaction.model" ,
1760- "agents.list.cap-0 .compaction.provider" ,
1771+ "agents.list.cap-1 .compaction.model" ,
1772+ "agents.list.cap-1 .compaction.provider" ,
17611773 ] ,
17621774 } ,
17631775 ] ) ;
0 commit comments