How to Build an Agent (Ampcode)

Thorsten Ball (Amp) writes a step-by-step tutorial building a code-editing agent in <400 lines of Go. Subtitle: “The Emperor Has No Clothes.”

Key Claims

  • “It’s an LLM, a loop, and enough tokens” — there’s no secret behind agent behavior
  • Agent definition: “an LLM with access to tools, giving it the ability to modify something outside the context window”
  • Tools are just structured “wink if you want me to X” — models are trained and fine-tuned for this
  • The entire agent is: conversation loop → tool definitions → tool execution → result feedback → continue
  • A fully functional code-editing agent needs just 3 tools: read_file, list_files, edit_file
  • “The rest, the stuff that makes Amp so addictive? Elbow grease.”

Tutorial Structure

  1. Basic chat loop (90 lines) — conversation management
  2. Tool definitions — name, description, input schema, function
  3. Tool use loop — when model’s stop_reason is tool_use, execute and continue
  4. Three tools build a capable agent

Takeaways

  • The “emperor has no clothes” framing: agents look magical but the core loop is simple
  • The server is stateless — all state management is on the client side
  • Models are “very eager” to use tools — they “know” they can get more information
  • The complexity is in the tooling, prompt engineering, and edge case handling, not the loop itself
  • This is the Amp team’s philosophy: simplicity first

Connections