Intermediate 25 min

Testing, Limits, and Next Steps

Testing Your Agent

Try these test cases:

Test CaseExpected Behavior
”Add two tasks then list”Should add both, then list them
”Mark a non-existing ID complete”Should handle gracefully
”What tasks do I have?”Should call listTodos
”I need to remember dentist on Tuesday”Should extract date and add

Current Limits

  • In-memory store only - Resets on restart
  • No authentication - Anyone can use it
  • Simple tools only - Just the three basic operations
  • No error recovery - Fails if API is down

Suggested Extensions

Here are ideas to make it better:

  1. Persist to database - Use SQLite or PostgreSQL
  2. Add more tools - remindLater, updateTodo, searchTodos
  3. Add fields - Priority, tags, notes
  4. Streaming responses - Show responses as they generate
  5. Better error handling - Retry logic, fallbacks

Challenge

Try adding a new tool: clearCompleted().

  1. Add the function to tools.ts
  2. Add the tool schema to agent.ts
  3. Handle it in the tool execution loop
  4. Test it with: “Clear all completed tasks”

Summary

What You Built

You built a working AI agent with:

  • Tools - Three functions for managing todos
  • LLM Integration - Function calling with OpenAI
  • Agent Loop - The core loop that calls tools and responds
  • Memory - In-memory state that persists across turns
  • Basic UI - A simple web interface

Key Takeaways

  1. Agents are loops - They process messages, call tools, and loop until done
  2. Tools are functions - Simple JavaScript functions that the LLM can call
  3. Function calling - The LLM decides which tools to use based on schemas
  4. Memory matters - State needs to persist across turns

The Mental Model

Agent = Model + Tools + Memory + Loop

  • Model: The LLM that makes decisions
  • Tools: Functions the agent can call
  • Memory: State that persists
  • Loop: The process that ties it all together

What’s Next?

  • Build more complex agents with multiple tools
  • Add persistent storage
  • Create production-ready UIs
  • Explore agent frameworks (LangChain, AutoGPT, etc.)

You’ve got the fundamentals. Now go build something cool!


Final Knowledge Check

Let’s make sure you understand everything:



Congratulations! You’ve built your first AI agent. You now understand how agents work, how to define tools, and how to wire them to an LLM.

Keep experimenting, and happy building! 🚀