@@ -1846,7 +1846,7 @@ describe("compactEmbeddedAgentSession hooks (ownsCompaction engine)", () => {
18461846 } ) ;
18471847 } ) ;
18481848
1849- it ( "keeps selected Codex harness queued compaction on canonical OpenAI context" , async ( ) => {
1849+ it ( "runs selected Codex harness queued compaction on canonical OpenAI context" , async ( ) => {
18501850 resolveAgentHarnessPolicyMock . mockReturnValue ( { runtime : "codex" } ) ;
18511851 maybeCompactAgentHarnessSessionMock . mockResolvedValueOnce ( {
18521852 ok : true ,
@@ -1874,7 +1874,16 @@ describe("compactEmbeddedAgentSession hooks (ownsCompaction engine)", () => {
18741874 ) ;
18751875
18761876 expect ( result . ok ) . toBe ( true ) ;
1877- expect ( maybeCompactAgentHarnessSessionMock ) . not . toHaveBeenCalled ( ) ;
1877+ expect ( contextEngineCompactMock ) . toHaveBeenCalledTimes ( 1 ) ;
1878+ expect ( maybeCompactAgentHarnessSessionMock ) . toHaveBeenCalledTimes ( 1 ) ;
1879+ expect ( maybeCompactAgentHarnessSessionMock ) . toHaveBeenCalledWith (
1880+ expect . objectContaining ( {
1881+ provider : "openai" ,
1882+ model : "gpt-5.5" ,
1883+ agentHarnessId : "codex" ,
1884+ } ) ,
1885+ { nativeCompactionRequest : "after_context_engine" } ,
1886+ ) ;
18781887 const compactArg = mockCallArg ( contextEngineCompactMock ) as {
18791888 runtimeContext ?: Record < string , unknown > ;
18801889 } ;
@@ -1915,7 +1924,15 @@ describe("compactEmbeddedAgentSession hooks (ownsCompaction engine)", () => {
19151924 ) ;
19161925
19171926 expect ( result . ok ) . toBe ( true ) ;
1918- expect ( maybeCompactAgentHarnessSessionMock ) . not . toHaveBeenCalled ( ) ;
1927+ expect ( contextEngineCompactMock ) . toHaveBeenCalledTimes ( 1 ) ;
1928+ expect ( maybeCompactAgentHarnessSessionMock ) . toHaveBeenCalledTimes ( 1 ) ;
1929+ expect ( maybeCompactAgentHarnessSessionMock ) . toHaveBeenCalledWith (
1930+ expect . objectContaining ( {
1931+ provider : "openai" ,
1932+ model : "gpt-5.5" ,
1933+ } ) ,
1934+ { nativeCompactionRequest : "after_context_engine" } ,
1935+ ) ;
19191936 const compactArg = mockCallArg ( contextEngineCompactMock ) as {
19201937 runtimeContext ?: Record < string , unknown > ;
19211938 } ;
@@ -1968,7 +1985,7 @@ describe("compactEmbeddedAgentSession hooks (ownsCompaction engine)", () => {
19681985 } ) ;
19691986 } ) ;
19701987
1971- it ( "keeps concrete Codex pins on canonical OpenAI for queued compaction" , async ( ) => {
1988+ it ( "uses concrete Codex pins on canonical OpenAI for queued compaction" , async ( ) => {
19721989 resolveAgentHarnessPolicyMock . mockReturnValue ( {
19731990 runtime : "auto" ,
19741991 runtimeSource : "model" ,
@@ -1999,7 +2016,16 @@ describe("compactEmbeddedAgentSession hooks (ownsCompaction engine)", () => {
19992016 ) ;
20002017
20012018 expect ( result . ok ) . toBe ( true ) ;
2002- expect ( maybeCompactAgentHarnessSessionMock ) . not . toHaveBeenCalled ( ) ;
2019+ expect ( contextEngineCompactMock ) . toHaveBeenCalledTimes ( 1 ) ;
2020+ expect ( maybeCompactAgentHarnessSessionMock ) . toHaveBeenCalledTimes ( 1 ) ;
2021+ expect ( maybeCompactAgentHarnessSessionMock ) . toHaveBeenCalledWith (
2022+ expect . objectContaining ( {
2023+ provider : "openai" ,
2024+ model : "gpt-5.5" ,
2025+ agentHarnessId : "codex" ,
2026+ } ) ,
2027+ { nativeCompactionRequest : "after_context_engine" } ,
2028+ ) ;
20032029 const compactArg = mockCallArg ( contextEngineCompactMock ) as {
20042030 runtimeContext ?: Record < string , unknown > ;
20052031 } ;
@@ -2068,7 +2094,10 @@ describe("compactEmbeddedAgentSession hooks (ownsCompaction engine)", () => {
20682094 config : {
20692095 models : {
20702096 providers : {
2071- openai : { models : [ { id : "gpt-5.5" , contextWindow : 350_000 } ] } ,
2097+ openai : {
2098+ baseUrl : "https://example.test/v1" ,
2099+ models : [ { id : "gpt-5.5" , contextWindow : 350_000 } ] ,
2100+ } ,
20722101 } ,
20732102 } ,
20742103 } ,
@@ -2125,7 +2154,7 @@ describe("compactEmbeddedAgentSession hooks (ownsCompaction engine)", () => {
21252154 expect ( contextEngineCompactMock ) . not . toHaveBeenCalled ( ) ;
21262155 } ) ;
21272156
2128- it ( "uses context-engine compaction when no Codex native binding is selected " , async ( ) => {
2157+ it ( "keeps context-engine compaction successful when Codex native binding is missing " , async ( ) => {
21292158 resolveAgentHarnessPolicyMock . mockReturnValue ( { runtime : "codex" } ) ;
21302159 maybeCompactAgentHarnessSessionMock . mockResolvedValueOnce ( {
21312160 ok : false ,
@@ -2146,8 +2175,25 @@ describe("compactEmbeddedAgentSession hooks (ownsCompaction engine)", () => {
21462175 expect ( result . ok ) . toBe ( true ) ;
21472176 expect ( result . compacted ) . toBe ( true ) ;
21482177 expect ( result . result ?. summary ) . toBe ( "engine-summary" ) ;
2149- expect ( maybeCompactAgentHarnessSessionMock ) . not . toHaveBeenCalled ( ) ;
21502178 expect ( contextEngineCompactMock ) . toHaveBeenCalledTimes ( 1 ) ;
2179+ expect ( maybeCompactAgentHarnessSessionMock ) . toHaveBeenCalledTimes ( 1 ) ;
2180+ expect ( maybeCompactAgentHarnessSessionMock ) . toHaveBeenCalledWith (
2181+ expect . objectContaining ( {
2182+ provider : "openai" ,
2183+ model : "gpt-5.4" ,
2184+ agentHarnessId : "codex" ,
2185+ } ) ,
2186+ { nativeCompactionRequest : "after_context_engine" } ,
2187+ ) ;
2188+ const details = result . result ?. details as
2189+ | { codexNativeCompaction ?: Record < string , unknown > }
2190+ | undefined ;
2191+ expect ( details ?. codexNativeCompaction ) . toMatchObject ( {
2192+ ok : false ,
2193+ compacted : false ,
2194+ reason : "no codex app-server thread binding" ,
2195+ failure : { reason : "missing_thread_binding" } ,
2196+ } ) ;
21512197 } ) ;
21522198
21532199 it ( "keeps owning context-engine compaction primary for legacy Codex native sessions" , async ( ) => {
0 commit comments