NorthGradient
Start reading

Short course · intro

Introduction to LLM Agents

Build a working agent from scratch in plain Python, one piece at a time: a tool, the reasoning step, the call, and the loop. Then see where plain loops break and why frameworks exist.

0 of 7 read · 7 parts · ~31 min

  1. 1 Your first tool A tool is a Python function the agent can call to interact with the world, and its docstring is as important as its code. 4 min
  2. 2 The reasoning step The reasoning step gives the LLM a task and a list of tools, and the LLM responds not with an answer but with a decision about which tool to call. 5 min
  3. 3 Calling the tool Once the LLM has decided which tool to call, your code dispatches that decision to the actual Python function and collects the result. 4 min
  4. 4 Closing the loop Feeding the tool result back to the LLM closes the loop and produces the final answer, completing a working agent in one compact, readable loop. 5 min
  5. 5 When things go wrong The three failures beginners hit most often: a tool crash that kills the run, a loop that never stops, and an LLM that ignores the tools entirely. 5 min
  6. 6 Remembering context The OpenAI API has no memory of its own. Context is preserved by building a message list and sending the full conversation history on every call. 5 min
  7. 7 Where to go next Plain Python handles simple agents well, but falls apart as agents grow. Graph-based frameworks solve the problems that plain loops cannot. 3 min