@@ -1941,10 +1941,16 @@ export class Task extends EventEmitter<TaskEvents> implements TaskLike {
19411941 }
19421942
19431943 switch ( chunk . type ) {
1944- case "reasoning" :
1944+ case "reasoning" : {
19451945 reasoningMessage += chunk . text
1946- await this . say ( "reasoning" , reasoningMessage , undefined , true )
1946+ // Add line breaks before **Title** patterns for better formatting
1947+ const formattedReasoning = reasoningMessage . replace (
1948+ / ( [ ^ \n ] ) \* \* ( [ ^ * \n ] + ) \* \* / g,
1949+ "$1\n\n**$2**" ,
1950+ )
1951+ await this . say ( "reasoning" , formattedReasoning , undefined , true )
19471952 break
1953+ }
19481954 case "usage" :
19491955 inputTokens += chunk . inputTokens
19501956 outputTokens += chunk . outputTokens
@@ -2238,7 +2244,7 @@ export class Task extends EventEmitter<TaskEvents> implements TaskLike {
22382244 // Note: updateApiReqMsg() is now called from within drainStreamInBackgroundToFindAllUsage
22392245 // to ensure usage data is captured even when the stream is interrupted. The background task
22402246 // uses local variables to accumulate usage data before atomically updating the shared state.
2241- await this . persistGpt5Metadata ( reasoningMessage )
2247+ await this . persistGpt5Metadata ( )
22422248 await this . saveClineMessages ( )
22432249 await this . providerRef . deref ( ) ?. postStateToWebview ( )
22442250
@@ -2824,10 +2830,11 @@ export class Task extends EventEmitter<TaskEvents> implements TaskLike {
28242830 }
28252831
28262832 /**
2827- * Persist GPT-5 per-turn metadata (previous_response_id, instructions, reasoning_summary )
2833+ * Persist GPT-5 per-turn metadata (previous_response_id, instructions)
28282834 * onto the last complete assistant say("text") message.
2835+ * Note: reasoning_summary is no longer persisted as reasoning is now sent as separate delta blocks.
28292836 */
2830- private async persistGpt5Metadata ( reasoningMessage ?: string ) : Promise < void > {
2837+ private async persistGpt5Metadata ( ) : Promise < void > {
28312838 try {
28322839 const modelId = this . api . getModel ( ) . id
28332840 if ( ! modelId || ! modelId . startsWith ( "gpt-5" ) ) return
@@ -2848,7 +2855,7 @@ export class Task extends EventEmitter<TaskEvents> implements TaskLike {
28482855 ...( msg . metadata . gpt5 ?? { } ) ,
28492856 previous_response_id : lastResponseId ,
28502857 instructions : this . lastUsedInstructions ,
2851- reasoning_summary : ( reasoningMessage ?? "" ) . trim ( ) || undefined ,
2858+ // reasoning_summary is no longer stored as reasoning is sent as separate blocks
28522859 }
28532860 msg . metadata . gpt5 = gpt5Metadata
28542861 }
0 commit comments