WhoBuilt

Lets Build An Agent from Scratch

Feb 22, 2025· 19 min· 47K views·Watch on YouTube

Speaker

Kam Lasater of AI Engineer explains how to build a basic LLM agent from scratch, using code examples and tools to show how its components work.

Define the agent’s building blocks

Lasater describes an agent as an LLM with memory, planning, tools, and a loop. He breaks memory into read and write operations, and the loop into conditions and repetition, then starts with a standard chat completion call.

Add a condition and search tools

He adds an LLM judge that checks whether an answer fully addresses the question, then introduces Google Search through SerpApi. The client code must handle tool calls and their arguments, return tool results to the conversation, and call the LLM again. A location validation error shows that tool inputs must meet the API’s requirements.

Support parallel tool calls

Lasater refactors the tool loop into a utility that can run multiple calls, including repeated calls to the same tool with different inputs. Each result is linked to its request with a tool call ID. He suggests thinking of tools as text transformations, often taking parameters and returning a string.

Use a to-do list for planning

He adds tools to create and complete to-dos, inspect the list, and check whether the goal is done. The agent’s instructions tell it to make a plan before working, use available tools, and report its actions. A web-browsing tool fetches a URL and converts its content to Markdown; a sample run researches how to build agents without a framework.

See what the simple agent can do

Lasater demonstrates the agent planning a date with activities and dinner, while noting that it is imperfect. He describes the progression from an LLM call through conditions, tools, and to-do-list planning as a way to build a more capable system. Possible next steps include adding a vector database or a RAG system.

Takeaways

  • Build an agent incrementally: start with an LLM call, then add conditions, tools, and planning.
  • The client code must execute tool calls and pass each result back to the LLM.
  • Use tool schemas to define valid inputs, and handle API validation errors explicitly.
  • Add a limit on tool iterations so the agent cannot loop indefinitely.
  • A to-do list can give the agent explicit steps and a way to track completed work.

Mentioned in this talk

Search inside this talk

What was claimed 8

Related talks