Intermediate 25 min

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:

  1. addTodo - Add a new task

    • Parameters: text (required), dueDate (optional)
    • Returns: The created todo
  2. listTodos - List all tasks

    • Parameters: None
    • Returns: Array of all todos
  3. completeTodo - Mark a task as done

    • Parameters: id (required)
    • Returns: The completed todo

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 tasks
  • updateTodo() - Edit an existing task
  • searchTodos() - Find tasks by keyword

We’ll stick with the three basic tools for now. Ready to implement them?