@@ -1070,6 +1070,73 @@ describe("ProviderRuntimeIngestion", () => {
10701070 ) . toBe ( false ) ;
10711071 } ) ;
10721072
1073+ it ( "settles a streamed reasoning activity when the completion has no detail" , async ( ) => {
1074+ const harness = await createHarness ( ) ;
1075+
1076+ // An orphan settle — no streamed row, no detail — must not create a row.
1077+ // Emitted first so the wait below proves it was processed and dropped.
1078+ harness . emit ( {
1079+ type : "item.completed" ,
1080+ eventId : asEventId ( "evt-reasoning-orphan-completed" ) ,
1081+ provider : ProviderDriverKind . make ( "codex" ) ,
1082+ createdAt : "2026-01-01T00:00:00.000Z" ,
1083+ threadId : asThreadId ( "thread-1" ) ,
1084+ turnId : asTurnId ( "turn-reasoning" ) ,
1085+ itemId : asItemId ( "item-orphan" ) ,
1086+ payload : {
1087+ itemType : "reasoning" ,
1088+ status : "completed" ,
1089+ } ,
1090+ } ) ;
1091+ harness . emit ( {
1092+ type : "content.delta" ,
1093+ eventId : asEventId ( "evt-reasoning-nodetail-delta" ) ,
1094+ provider : ProviderDriverKind . make ( "claudeAgent" ) ,
1095+ createdAt : "2026-01-01T00:00:01.000Z" ,
1096+ threadId : asThreadId ( "thread-1" ) ,
1097+ turnId : asTurnId ( "turn-reasoning" ) ,
1098+ itemId : asItemId ( "item-nodetail" ) ,
1099+ payload : {
1100+ streamKind : "reasoning_text" ,
1101+ delta : "Weighing options" ,
1102+ } ,
1103+ } ) ;
1104+ // Completion without a detail string (codex reasoning items usually carry
1105+ // none) must still flip the streamed activity out of its live state.
1106+ harness . emit ( {
1107+ type : "item.completed" ,
1108+ eventId : asEventId ( "evt-reasoning-nodetail-completed" ) ,
1109+ provider : ProviderDriverKind . make ( "claudeAgent" ) ,
1110+ createdAt : "2026-01-01T00:00:02.000Z" ,
1111+ threadId : asThreadId ( "thread-1" ) ,
1112+ turnId : asTurnId ( "turn-reasoning" ) ,
1113+ itemId : asItemId ( "item-nodetail" ) ,
1114+ payload : {
1115+ itemType : "reasoning" ,
1116+ status : "completed" ,
1117+ } ,
1118+ } ) ;
1119+
1120+ const thread = await waitForThread ( harness . readModel , ( entry ) =>
1121+ entry . activities . some (
1122+ ( activity : ProviderRuntimeTestActivity ) =>
1123+ activity . id === "reasoning:thread-1:item-nodetail" &&
1124+ ( activity . payload as { streaming ?: boolean } ) . streaming === false ,
1125+ ) ,
1126+ ) ;
1127+ expect (
1128+ thread . activities . find (
1129+ ( activity : ProviderRuntimeTestActivity ) =>
1130+ activity . id === "reasoning:thread-1:item-nodetail" ,
1131+ ) ?. payload ,
1132+ ) . toMatchObject ( { detail : "Weighing options" , streaming : false } ) ;
1133+ expect (
1134+ thread . activities . some (
1135+ ( activity : ProviderRuntimeTestActivity ) => activity . id === "reasoning:thread-1:item-orphan" ,
1136+ ) ,
1137+ ) . toBe ( false ) ;
1138+ } ) ;
1139+
10731140 it ( "merges streamed reasoning into one persisted activity and settles it" , async ( ) => {
10741141 const harness = await createHarness ( ) ;
10751142
0 commit comments