@@ -4608,6 +4608,92 @@ async fn auto_compact_preserves_reasoning_header_for_next_pre_turn_check() {
46084608 ) ;
46094609}
46104610
4611+ #[ tokio:: test( flavor = "multi_thread" , worker_threads = 2 ) ]
4612+ async fn auto_compact_restores_reasoning_header_after_resume ( ) {
4613+ skip_if_no_network ! ( ) ;
4614+
4615+ let server = start_mock_server ( ) . await ;
4616+
4617+ let pre_last_reasoning_content = "a" . repeat ( 2_400 ) ;
4618+ let post_last_reasoning_content = "b" . repeat ( 4_000 ) ;
4619+
4620+ let first_turn = sse ( vec ! [
4621+ ev_reasoning_item( "pre-reasoning" , & [ "pre" ] , & [ & pre_last_reasoning_content] ) ,
4622+ ev_completed_with_tokens( "r1" , /*total_tokens*/ 10 ) ,
4623+ ] ) ;
4624+ let second_turn = sse ( vec ! [
4625+ ev_reasoning_item( "post-reasoning" , & [ "post" ] , & [ & post_last_reasoning_content] ) ,
4626+ ev_completed_with_tokens( "r2" , /*total_tokens*/ 80 ) ,
4627+ ] ) ;
4628+ let third_turn = sse ( vec ! [
4629+ ev_assistant_message( "m4" , FINAL_REPLY ) ,
4630+ ev_completed_with_tokens( "r4" , /*total_tokens*/ 1 ) ,
4631+ ] ) ;
4632+
4633+ let responses = vec ! [
4634+ sse_response( first_turn) . insert_header( "X-Reasoning-Included" , "true" ) ,
4635+ sse_response( second_turn) . insert_header( "X-Reasoning-Included" , "true" ) ,
4636+ sse_response( third_turn) . insert_header( "X-Reasoning-Included" , "true" ) ,
4637+ ] ;
4638+ mount_response_sequence ( & server, responses) . await ;
4639+
4640+ let compact_mock = mount_compact_json_once (
4641+ & server,
4642+ serde_json:: json!( {
4643+ "output" : [ {
4644+ "type" : "compaction" ,
4645+ "encrypted_content" : "UNEXPECTED_COMPACTION" ,
4646+ } ] ,
4647+ } ) ,
4648+ )
4649+ . await ;
4650+
4651+ let configure = |config : & mut Config | {
4652+ set_test_compact_prompt ( config) ;
4653+ config. model_auto_compact_token_limit = Some ( 300 ) ;
4654+ let _ = config. features . disable ( Feature :: RemoteCompactionV2 ) ;
4655+ } ;
4656+ let mut builder = test_codex ( )
4657+ . with_auth ( CodexAuth :: create_dummy_chatgpt_auth_for_testing ( ) )
4658+ . with_config ( configure) ;
4659+ let initial = builder. build ( & server) . await . expect ( "build codex" ) ;
4660+ let home = Arc :: clone ( & initial. home ) ;
4661+ let rollout_path = initial
4662+ . session_configured
4663+ . rollout_path
4664+ . clone ( )
4665+ . expect ( "rollout path" ) ;
4666+
4667+ for user in [ "SERVER_INCLUDED_FIRST" , "SERVER_INCLUDED_SECOND" ] {
4668+ initial
4669+ . submit_turn ( user)
4670+ . await
4671+ . expect ( "submit initial turn" ) ;
4672+ }
4673+ initial
4674+ . codex
4675+ . shutdown_and_wait ( )
4676+ . await
4677+ . expect ( "shutdown initial thread" ) ;
4678+
4679+ let mut resume_builder = test_codex ( )
4680+ . with_auth ( CodexAuth :: create_dummy_chatgpt_auth_for_testing ( ) )
4681+ . with_config ( configure) ;
4682+ let resumed = resume_builder
4683+ . resume ( & server, home, rollout_path)
4684+ . await
4685+ . expect ( "resume codex" ) ;
4686+ resumed
4687+ . submit_turn ( "SERVER_INCLUDED_THIRD" )
4688+ . await
4689+ . expect ( "submit resumed turn" ) ;
4690+
4691+ assert ! (
4692+ compact_mock. requests( ) . is_empty( ) ,
4693+ "resume should restore the previous response's reasoning-included signal"
4694+ ) ;
4695+ }
4696+
46114697#[ tokio:: test( flavor = "multi_thread" , worker_threads = 2 ) ]
46124698async fn auto_compact_runs_when_reasoning_header_clears_between_turns ( ) {
46134699 skip_if_no_network ! ( ) ;
0 commit comments