Apply new style to Todos (#11607)

This commit is contained in:
Tommaso Sciortino
2025-10-21 15:40:45 -07:00
committed by GitHub
parent 16f5f767b2
commit 519bd57e55
5 changed files with 215 additions and 193 deletions
+10 -3
View File
@@ -14,6 +14,13 @@ import {
} from './tools.js';
import { WRITE_TODOS_TOOL_NAME } from './tool-names.js';
const TODO_STATUSES = [
'pending',
'in_progress',
'completed',
'cancelled',
] as const;
// Inspired by langchain/deepagents.
export const WRITE_TODOS_DESCRIPTION = `This tool can help you list out the current subtasks that are required to be completed for a given user request. The list of subtasks helps you keep track of the current task, organize complex queries and help ensure that you don't miss any steps. With this list, the user can also see the current progress you are making in executing a given task.
@@ -152,7 +159,7 @@ export class WriteTodosTool extends BaseDeclarativeTool<
status: {
type: 'string',
description: 'The current status of the task.',
enum: ['pending', 'in_progress', 'completed'],
enum: TODO_STATUSES,
},
},
required: ['description', 'status'],
@@ -179,8 +186,8 @@ export class WriteTodosTool extends BaseDeclarativeTool<
if (typeof todo.description !== 'string' || !todo.description.trim()) {
return 'Each todo must have a non-empty description string';
}
if (!['pending', 'in_progress', 'completed'].includes(todo.status)) {
return 'Each todo must have a valid status (pending, in_progress, or completed)';
if (!TODO_STATUSES.includes(todo.status)) {
return `Each todo must have a valid status (${TODO_STATUSES.join(', ')})`;
}
}