Skip to content

Commit 1149d1f

Browse files
committed
Reinstate write_todos as a tool forces a next step, but with exception
1 parent 7983b0c commit 1149d1f

File tree

2 files changed

+18
-2
lines changed

2 files changed

+18
-2
lines changed

common/src/tools/constants.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff 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

packages/agent-runtime/src/run-agent-step.ts

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff 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,

0 commit comments

Comments
 (0)