Designing the Agent: Tools and Memory
Planning Before Coding
Before we write code, let’s plan what our agent needs.
The Tools
Our agent needs three tools:
-
addTodo- Add a new task- Parameters:
text(required),dueDate(optional) - Returns: The created todo
- Parameters:
-
listTodos- List all tasks- Parameters: None
- Returns: Array of all todos
-
completeTodo- Mark a task as done- Parameters:
id(required) - Returns: The completed todo
- Parameters:
The Memory
We’ll use a simple in-memory array. Each todo looks like this:
type Todo = {
id: number;
text: string;
done: boolean;
dueDate?: string;
};
Important Notes
- This is not long-term memory - it resets when the server restarts
- It’s enough for learning the concept
- In production, you’d use a database
Design Exercise
Think about this: What other tool could you add later?
Some ideas:
clearCompleted()- Remove all completed tasksupdateTodo()- Edit an existing tasksearchTodos()- Find tasks by keyword
We’ll stick with the three basic tools for now. Ready to implement them?
Progress 50%
Page 4 of 8
← Previous
→ Next