File tree Expand file tree Collapse file tree 2 files changed +18
-2
lines changed
packages/agent-runtime/src Expand file tree Collapse file tree 2 files changed +18
-2
lines changed Original file line number Diff line number Diff line change @@ -14,7 +14,6 @@ export const TOOLS_WHICH_WONT_FORCE_NEXT_STEP = [
1414 'add_message' ,
1515 'update_subgoal' ,
1616 'create_plan' ,
17- 'write_todos' ,
1817]
1918
2019// List of all available tools
Original file line number Diff line number Diff line change @@ -368,8 +368,25 @@ export const runAgentStep = async (
368368 toolResults . filter (
369369 ( result ) => ! TOOLS_WHICH_WONT_FORCE_NEXT_STEP . includes ( result . toolName ) ,
370370 ) . length === 0
371+
372+ // Exception: if the only tool call is write_todos and all todos are completed, then end turn.
373+ let hasOnlyFinishedTodos = false
374+ if ( toolCalls . length === 1 && toolCalls [ 0 ] . toolName === 'write_todos' ) {
375+ const todos = toolCalls [ 0 ] . input . todos as
376+ | {
377+ task : string
378+ completed : boolean
379+ } [ ]
380+ | undefined
381+ if ( todos && todos . every ( ( todo ) => todo . completed ) ) {
382+ hasOnlyFinishedTodos = true
383+ }
384+ }
385+
371386 let shouldEndTurn =
372- toolCalls . some ( ( call ) => call . toolName === 'end_turn' ) || hasNoToolResults
387+ toolCalls . some ( ( call ) => call . toolName === 'end_turn' ) ||
388+ hasNoToolResults ||
389+ hasOnlyFinishedTodos
373390
374391 agentState = {
375392 ...agentState ,
You can’t perform that action at this time.
0 commit comments