@@ -692,15 +692,14 @@ it.instance("loop completes end-to-end recovery after a recoverable length finis
692692 const result = yield * prompt . loop ( { sessionID : chat . id } )
693693 expect ( yield * llm . hits ) . toHaveLength ( 2 )
694694 expect ( result . info ) . toMatchObject ( { role : "assistant" , finish : "stop" } )
695- expect ( result . parts ) . toEqual (
696- expect . arrayContaining ( [ expect . objectContaining ( { type : "text" , text : "complete" } ) ] ) ,
697- )
695+ expect ( result . parts ) . toEqual ( expect . arrayContaining ( [ expect . objectContaining ( { type : "text" , text : "complete" } ) ] ) )
698696 } ) ,
699697)
700698
701699it . instance ( "loop surfaces reasoning-only length finish as an error" , ( ) =>
702700 Effect . gen ( function * ( ) {
703701 const { llm } = yield * useServerConfig ( providerCfg )
702+ const events = yield * EventV2Bridge . Service
704703 const prompt = yield * SessionPrompt . Service
705704 const sessions = yield * Session . Service
706705 const chat = yield * sessions . create ( { title : "Pinned" } )
@@ -711,9 +710,22 @@ it.instance("loop surfaces reasoning-only length finish as an error", () =>
711710 parts : [ { type : "text" , text : "hello" } ] ,
712711 } )
713712
713+ const errors : NonNullable < SessionV1 . Assistant [ "error" ] > [ ] = [ ]
714+ const expected = {
715+ name : "MessageOutputLengthError" ,
716+ data : { } ,
717+ } satisfies NonNullable < SessionV1 . Assistant [ "error" ] >
718+ const off = yield * events . listen ( ( event ) => {
719+ if ( event . type !== Session . Event . Error . type ) return Effect . void
720+ const data = event . data as typeof Session . Event . Error . data . Type
721+ if ( data . sessionID === chat . id && data . error ) errors . push ( data . error )
722+ return Effect . void
723+ } )
724+
714725 yield * llm . push ( reply ( ) . reason ( "unfinished reasoning" ) . length ( ) )
715726 const result = yield * prompt . loop ( { sessionID : chat . id } )
716727 const stored = yield * MessageV2 . get ( { sessionID : chat . id , messageID : result . info . id } )
728+ yield * off
717729 expect ( yield * llm . hits ) . toHaveLength ( 1 )
718730 expect ( result . info . role ) . toBe ( "assistant" )
719731 if ( result . info . role === "assistant" ) {
@@ -723,6 +735,7 @@ it.instance("loop surfaces reasoning-only length finish as an error", () =>
723735 } )
724736 expect ( stored . info ) . toMatchObject ( { error : result . info . error } )
725737 }
738+ expect ( errors ) . toContainEqual ( expected )
726739 expect ( result . parts ) . toEqual (
727740 expect . arrayContaining ( [ expect . objectContaining ( { type : "reasoning" , text : "unfinished reasoning" } ) ] ) ,
728741 )
0 commit comments