Improve rendering of ToDo lists. (#11315)

This commit is contained in:
Tommaso Sciortino
2025-10-16 16:06:43 -07:00
committed by GitHub
parent c71b749185
commit 9a4211b610
7 changed files with 161 additions and 12 deletions
+12 -1
View File
@@ -541,7 +541,18 @@ export function hasCycleInSchema(schema: object): boolean {
return traverse(schema, new Set<string>(), new Set<string>());
}
export type ToolResultDisplay = string | FileDiff | AnsiOutput;
export interface TodoList {
todos: Todo[];
}
export type ToolResultDisplay = string | FileDiff | AnsiOutput | TodoList;
export type TodoStatus = 'pending' | 'in_progress' | 'completed' | 'cancelled';
export interface Todo {
description: string;
status: TodoStatus;
}
export interface FileDiff {
fileDiff: string;
+2 -2
View File
@@ -86,7 +86,7 @@ describe('WriteTodosTool', () => {
};
const result = await tool.buildAndExecute(params, signal);
expect(result.llmContent).toBe('Successfully cleared the todo list.');
expect(result.returnDisplay).toBe('Successfully cleared the todo list.');
expect(result.returnDisplay).toEqual({ todos: [] });
});
it('should return a formatted todo list on success', async () => {
@@ -103,7 +103,7 @@ describe('WriteTodosTool', () => {
2. [in_progress] Second task
3. [pending] Third task`;
expect(result.llmContent).toBe(expectedOutput);
expect(result.returnDisplay).toBe(expectedOutput);
expect(result.returnDisplay).toEqual(params);
});
});
});
+2 -8
View File
@@ -9,6 +9,7 @@ import {
BaseDeclarativeTool,
BaseToolInvocation,
Kind,
type Todo,
type ToolResult,
} from './tools.js';
import { WRITE_TODOS_TOOL_NAME } from './tool-names.js';
@@ -79,13 +80,6 @@ The agent did not use the todo list because this task could be completed by a ti
</example>
`;
export type TodoStatus = 'pending' | 'in_progress' | 'completed' | 'cancelled';
export interface Todo {
description: string;
status: TodoStatus;
}
export interface WriteTodosToolParams {
/**
* The full list of todos. This will overwrite any existing list.
@@ -123,7 +117,7 @@ class WriteTodosToolInvocation extends BaseToolInvocation<
return {
llmContent,
returnDisplay: llmContent,
returnDisplay: { todos },
};
}
}