@@ -96,4 +96,52 @@ describe('ask(): system prompt flags', () => {
9696 expect ( captured ?. systemPromptOverride ) . toBe ( '' )
9797 expect ( captured ?. appendSystemPrompt ) . toBe ( 'APPEND' )
9898 } )
99+
100+ test ( 'returns text content when a thinking block comes first' , async ( ) => {
101+ const out = await ask (
102+ {
103+ commands : [ ] as any ,
104+ tools : [ ] as any ,
105+ hasPermissionsToUseTool : ( ( ) => ( { result : true } ) ) as any ,
106+ messageLogName : 'test' ,
107+ prompt : 'what is 2+2?' ,
108+ cwd : '/tmp' ,
109+ } ,
110+ {
111+ setCwd : async ( ) => { } ,
112+ getCurrentOutputStyleDefinition : ( ) => null ,
113+ buildSystemPromptForSession : async ( ) => [ 'DEFAULT' ] ,
114+ getContext : async ( ) => ( { } ) ,
115+ getMaxThinkingTokens : async ( ) => 0 ,
116+ query : async function * ( ) {
117+ yield {
118+ type : 'assistant' ,
119+ uuid : 'assistant-uuid' ,
120+ message : {
121+ content : [
122+ {
123+ type : 'thinking' ,
124+ thinking :
125+ 'The user asked a simple arithmetic question; answer directly.' ,
126+ signature : '' ,
127+ } ,
128+ { type : 'text' , text : '4' } ,
129+ ] ,
130+ } ,
131+ } as any
132+ } ,
133+ createUserMessage : ( prompt : string ) =>
134+ ( {
135+ type : 'user' ,
136+ uuid : 'user-uuid' ,
137+ message : { content : [ { type : 'text' , text : prompt } ] } ,
138+ } ) as any ,
139+ getMessagesPath : ( ) => 'messages.json' ,
140+ overwriteLog : ( ) => { } ,
141+ getTotalCost : ( ) => 0 ,
142+ } ,
143+ )
144+
145+ expect ( out . resultText ) . toBe ( '4' )
146+ } )
99147} )
0 commit comments