@@ -1587,6 +1587,46 @@ describe("dispatchTelegramMessage draft streaming", () => {
15871587 expect ( answerDraftStream . update ) . toHaveBeenCalledWith ( "Answer" ) ;
15881588 } ) ;
15891589
1590+ it ( "flushes buffered final answers after a skipped reasoning segment" , async ( ) => {
1591+ deliverInboundReplyWithMessageSendContext
1592+ . mockResolvedValueOnce ( { status : "handled_no_send" } )
1593+ . mockResolvedValueOnce ( {
1594+ status : "handled_visible" ,
1595+ delivery : { messageIds : [ "1001" ] , visibleReplySent : true } ,
1596+ } ) ;
1597+ dispatchReplyWithBufferedBlockDispatcher . mockImplementation ( async ( { dispatcherOptions } ) => {
1598+ await dispatcherOptions . deliver (
1599+ { text : "<think>Hidden reasoning</think>Visible answer" } ,
1600+ { kind : "final" } ,
1601+ ) ;
1602+ return { queuedFinal : true } ;
1603+ } ) ;
1604+
1605+ await dispatchWithContext ( {
1606+ context : createContext ( {
1607+ ctxPayload : {
1608+ SessionKey : "agent:main:telegram:direct:123" ,
1609+ ChatType : "direct" ,
1610+ } as unknown as TelegramMessageContext [ "ctxPayload" ] ,
1611+ } ) ,
1612+ cfg : { agents : { defaults : { reasoningDefault : "on" } } } ,
1613+ streamMode : "off" ,
1614+ telegramDeps : telegramDepsForTest ,
1615+ } ) ;
1616+
1617+ expect ( deliverInboundReplyWithMessageSendContext ) . toHaveBeenCalledTimes ( 2 ) ;
1618+ expectRecordFields ( mockCallArg ( deliverInboundReplyWithMessageSendContext , 0 ) , {
1619+ info : { kind : "final" } ,
1620+ } ) ;
1621+ expectRecordFields ( mockCallArg ( deliverInboundReplyWithMessageSendContext , 0 ) . payload , {
1622+ text : "Reasoning:\n_Hidden reasoning_" ,
1623+ } ) ;
1624+ expectRecordFields ( mockCallArg ( deliverInboundReplyWithMessageSendContext , 1 ) . payload , {
1625+ text : "Visible answer" ,
1626+ } ) ;
1627+ expect ( deliverReplies ) . not . toHaveBeenCalled ( ) ;
1628+ } ) ;
1629+
15901630 it ( "suppresses reasoning-only finals without raw text fallback" , async ( ) => {
15911631 setupDraftStreams ( { answerMessageId : 2001 , reasoningMessageId : 3001 } ) ;
15921632 dispatchReplyWithBufferedBlockDispatcher . mockImplementation ( async ( { dispatcherOptions } ) => {
0 commit comments