File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -1110,7 +1110,7 @@ const layer = Layer.effect(
11101110
11111111 if (
11121112 lastAssistant ?. finish &&
1113- ! [ "tool-calls" ] . includes ( lastAssistant . finish ) &&
1113+ ! [ "tool-calls" , "unknown" ] . includes ( lastAssistant . finish ) &&
11141114 ! hasToolCalls &&
11151115 lastAssistant . parentID === lastUser . id
11161116 ) {
Original file line number Diff line number Diff line change @@ -850,6 +850,34 @@ it.instance("loop continues when finish is tool-calls", () =>
850850 } ) ,
851851)
852852
853+ it . instance ( "loop continues when finish is unknown" , ( ) =>
854+ Effect . gen ( function * ( ) {
855+ const { llm } = yield * useServerConfig ( providerCfg )
856+ const prompt = yield * SessionPrompt . Service
857+ const sessions = yield * Session . Service
858+ const session = yield * sessions . create ( {
859+ title : "Pinned" ,
860+ permission : [ { permission : "*" , pattern : "*" , action : "allow" } ] ,
861+ } )
862+ yield * prompt . prompt ( {
863+ sessionID : session . id ,
864+ agent : "build" ,
865+ noReply : true ,
866+ parts : [ { type : "text" , text : "hello" } ] ,
867+ } )
868+ yield * llm . push ( reply ( ) )
869+ yield * llm . text ( "second" )
870+
871+ const result = yield * prompt . loop ( { sessionID : session . id } )
872+ expect ( yield * llm . calls ) . toBe ( 2 )
873+ expect ( result . info . role ) . toBe ( "assistant" )
874+ if ( result . info . role === "assistant" ) {
875+ expect ( result . parts . some ( ( part ) => part . type === "text" && part . text === "second" ) ) . toBe ( true )
876+ expect ( result . info . finish ) . toBe ( "stop" )
877+ }
878+ } ) ,
879+ )
880+
853881it . instance ( "glob tool keeps instance context during prompt runs" , ( ) =>
854882 Effect . gen ( function * ( ) {
855883 const { dir, llm } = yield * useServerConfig ( providerCfg )
You can’t perform that action at this time.
0 commit comments