Skip to content

An AI-powered search engine with a generative UI

refactor: remove todoRead tool and use todoWrite response for verification

Yoshiki Miurac8edd749fd1a
diff --git a/components/artifact/artifact-content.tsx b/components/artifact/artifact-content.tsx
index 9fd7df33..349c17ec 100644
--- a/components/artifact/artifact-content.tsx
+++ b/components/artifact/artifact-content.tsx
@@ -9,8 +9,8 @@ import { ToolInvocationContent } from './tool-invocation-content'
// Type guard for Todo tool parts
function isTodoToolPart(
part: Part
-): part is ToolPart<'todoWrite'> | ToolPart<'todoRead'> {
- return part.type === 'tool-todoWrite' || part.type === 'tool-todoRead'
+): part is ToolPart<'todoWrite'> {
+ return part.type === 'tool-todoWrite'
}
export function ArtifactContent({ part }: { part: Part | null }) {
@@ -22,7 +22,6 @@ export function ArtifactContent({ part }: { part: Part | null }) {
case 'tool-askQuestion':
return <ToolInvocationContent part={part} />
case 'tool-todoWrite':
- case 'tool-todoRead':
if (isTodoToolPart(part)) {
return <TodoInvocationContent part={part} />
}
diff --git a/components/artifact/todo-invocation-content.tsx b/components/artifact/todo-invocation-content.tsx
index 0ab40fdf..95a4dc61 100644
--- a/components/artifact/todo-invocation-content.tsx
+++ b/components/artifact/todo-invocation-content.tsx
@@ -5,7 +5,7 @@ import type { ToolPart } from '@/lib/types/ai'
import TodoListContent from '../todo-list-content'
interface TodoInvocationContentProps {
- part: ToolPart<'todoWrite'> | ToolPart<'todoRead'>
+ part: ToolPart<'todoWrite'>
}
export function TodoInvocationContent({ part }: TodoInvocationContentProps) {
@@ -21,15 +21,15 @@ export function TodoInvocationContent({ part }: TodoInvocationContentProps) {
)
}
- const summaryOrMessage =
- (part.output && 'message' in part.output && part.output.message) ||
- (part.output && 'summary' in part.output && part.output.summary) ||
- undefined
+ const message =
+ part.output && 'message' in part.output
+ ? (part.output.message as string | undefined)
+ : undefined
return (
<TodoListContent
todos={todos}
- message={summaryOrMessage}
+ message={message}
completedCount={completedCount}
totalCount={totalCount}
showSummary={true}
diff --git a/components/inspector/inspector-panel.tsx b/components/inspector/inspector-panel.tsx
index 7b770b34..0aa8442a 100644
--- a/components/inspector/inspector-panel.tsx
+++ b/components/inspector/inspector-panel.tsx
@@ -31,7 +31,6 @@ export function InspectorPanel() {
title: toolName
}
case 'tool-todoWrite':
- case 'tool-todoRead':
return {
icon: <ListTodo size={18} />,
title: 'Todo List'
diff --git a/components/tool-section.tsx b/components/tool-section.tsx
index baa491c0..97ef557e 100644
--- a/components/tool-section.tsx
+++ b/components/tool-section.tsx
@@ -111,22 +111,6 @@ export function ToolSection({
isLast={isLast}
/>
)
- case 'tool-todoRead':
- return (
- <ToolTodoDisplay
- tool="todoRead"
- state={tool.state}
- input={tool.input}
- output={tool.output}
- errorText={tool.errorText}
- toolCallId={tool.toolCallId}
- isOpen={isOpen}
- onOpenChange={onOpenChange}
- borderless={borderless}
- isFirst={isFirst}
- isLast={isLast}
- />
- )
default:
return null
}
diff --git a/components/tool-todo-display.tsx b/components/tool-todo-display.tsx
index 7f8b65cf..278331bc 100644
--- a/components/tool-todo-display.tsx
+++ b/components/tool-todo-display.tsx
@@ -9,7 +9,7 @@ import ProcessHeader from './process-header'
import TodoListContent from './todo-list-content'
interface ToolTodoDisplayProps {
- tool: 'todoWrite' | 'todoRead'
+ tool: 'todoWrite'
state:
| 'input-streaming'
| 'input-available'
@@ -58,9 +58,8 @@ export function ToolTodoDisplay({
const openInspector = () => {
if (!(state === 'output-available' && output)) return
- const partType = tool === 'todoWrite' ? 'tool-todoWrite' : 'tool-todoRead'
const part: Part = {
- type: partType as 'tool-todoWrite' | 'tool-todoRead',
+ type: 'tool-todoWrite',
toolCallId,
state,
input: { todos: output.todos || [] },
@@ -78,18 +77,8 @@ export function ToolTodoDisplay({
<ListTodo className="size-4 text-muted-foreground shrink-0" />
<span className="truncate">
{state === 'output-available' && output
- ? tool === 'todoRead'
- ? (typeof output === 'object' &&
- 'summary' in output &&
- typeof output.summary === 'string'
- ? output.summary
- : null) ||
- output.message ||
- 'Todo list'
- : output.message || 'Updated tasks'
- : tool === 'todoWrite'
- ? 'Updating tasks...'
- : 'Reading tasks...'}
+ ? output.message || 'Updated tasks'
+ : 'Updating tasks...'}
</span>
</span>
}
@@ -157,16 +146,7 @@ export function ToolTodoDisplay({
{state === 'output-available' ? (
<TodoListContent
todos={output?.todos}
- message={
- tool === 'todoRead'
- ? (output &&
- typeof output === 'object' &&
- 'summary' in output &&
- typeof output.summary === 'string'
- ? output.summary
- : undefined) || output?.message
- : output?.message
- }
+ message={output?.message}
completedCount={completedCount}
totalCount={totalCount}
showSummary={false}
diff --git a/lib/agents/prompts/search-mode-prompts.ts b/lib/agents/prompts/search-mode-prompts.ts
index 13c89f3b..7941da7c 100644
--- a/lib/agents/prompts/search-mode-prompts.ts
+++ b/lib/agents/prompts/search-mode-prompts.ts
@@ -227,9 +227,9 @@ TASK MANAGEMENT (todoWrite tool):
- Never remove completed tasks from the list
- Always preserve the full task history with updated statuses
- This provides transparency and shows the complete progress
-- **Before composing the final answer: you MUST call todoRead and verify completedCount equals totalCount**
-- If not all tasks are completed: continue executing remaining tasks or adjust the plan with todoWrite, then verify again with todoRead
-- Only proceed to write the final answer after confirming all tasks are completed
+- **Before composing the final answer: verify that the todoWrite response shows completedCount equals totalCount**
+- If not all tasks are completed: continue executing remaining tasks or adjust the plan with todoWrite
+- Only proceed to write the final answer after confirming all tasks are completed (check completedCount in the todoWrite response)
Example task patterns:
- "Research [topic] from multiple sources"
diff --git a/lib/agents/researcher.ts b/lib/agents/researcher.ts
index 5026d258..2bb6120c 100644
--- a/lib/agents/researcher.ts
+++ b/lib/agents/researcher.ts
@@ -124,7 +124,7 @@ export function createResearcher({
activeToolsList = ['search', 'fetch']
// Only enable todo tools for quality model type
if (writer && 'todoWrite' in todoTools && modelType === 'quality') {
- activeToolsList.push('todoWrite', 'todoRead')
+ activeToolsList.push('todoWrite')
}
console.log(
`[Researcher] Adaptive mode: maxSteps=50, modelType=${modelType}, tools=[${activeToolsList.join(', ')}]`
diff --git a/lib/tools/todo.ts b/lib/tools/todo.ts
index afed331f..096f0491 100644
--- a/lib/tools/todo.ts
+++ b/lib/tools/todo.ts
@@ -26,21 +26,13 @@ export const todoWriteInputSchema = z.object({
.describe('A brief message about the current progress')
})
-// Schema for todo read tool
-export const todoReadOutputSchema = z.object({
- todos: z.array(todoItemSchema),
- summary: z.string().describe('Summary of current progress'),
- completedCount: z.number(),
- totalCount: z.number()
-})
-
// Create todo tools with session-scoped storage
export function createTodoTools() {
// Session-scoped todos storage - isolated per tool instance
let sessionTodos: TodoItem[] = []
const todoWrite = tool({
description:
- 'Create or update todos to track progress on complex tasks. Use this to maintain a list of action items.',
+ 'Create or update todos to track progress on complex tasks. Use this to maintain a list of action items. The response includes completedCount and totalCount to verify task completion.',
inputSchema: todoWriteInputSchema,
execute: async ({ todos, progressMessage }) => {
// Update session todos - ensure priority is always set
@@ -63,26 +55,5 @@ export function createTodoTools() {
}
})
- const todoRead = tool({
- description: 'Read the current list of todos and their status',
- inputSchema: z.object({}),
- execute: async () => {
- const completedCount = sessionTodos.filter(
- (t: TodoItem) => t.status === 'completed'
- ).length
- const totalCount = sessionTodos.length
-
- return {
- todos: sessionTodos,
- summary:
- totalCount > 0
- ? `${completedCount} of ${totalCount} tasks completed`
- : 'No tasks created yet',
- completedCount,
- totalCount
- }
- }
- })
-
- return { todoWrite, todoRead }
+ return { todoWrite }
}
diff --git a/lib/types/agent.ts b/lib/types/agent.ts
index c9b888aa..8668a1c5 100644
--- a/lib/types/agent.ts
+++ b/lib/types/agent.ts
@@ -50,9 +50,6 @@ export type QuestionToolInvocation = UIToolInvocation<
export type TodoWriteToolInvocation = UIToolInvocation<
ResearcherTools['todoWrite']
>
-export type TodoReadToolInvocation = UIToolInvocation<
- ResearcherTools['todoRead']
->
// Union type for all tool invocations
export type ResearcherToolInvocation =
@@ -60,7 +57,6 @@ export type ResearcherToolInvocation =
| FetchToolInvocation
| QuestionToolInvocation
| TodoWriteToolInvocation
- | TodoReadToolInvocation
// Helper type to extract tool names
export type ResearcherToolName = keyof ResearcherTools
diff --git a/lib/types/ai.ts b/lib/types/ai.ts
index 889a1e67..ab3d2975 100644
--- a/lib/types/ai.ts
+++ b/lib/types/ai.ts
@@ -52,7 +52,6 @@ export type UITools = {
fetch: InferUITool<typeof fetchTool>
askQuestion: InferUITool<typeof askQuestionTool>
todoWrite: InferUITool<typeof todoTools.todoWrite>
- todoRead: InferUITool<typeof todoTools.todoRead>
// Dynamic tools will be added at runtime
[key: string]: any
}