Fly.ioTutorial
You Should Write An Agent
Summary
Thomas Ptacek argues that people should build an LLM agent before forming strong opinions about the technology, because implementation reveals how simple and surprising the underlying system can be. The example starts with a Python loop around the OpenAI Responses API, storing user and assistant messages in a context list to simulate conversation with a stateless model. Adding a JSON-defined ping function and a tool-calling loop lets the model choose and execute multiple network checks, demonstrating behavior not explicitly hard-coded in the loop. The discussion extends this pattern to coding agents, contexts persisted in SQLite, sub-agents, and design choices involving nondeterminism, ground truth, interchange formats, and token costs. It concludes that these remain open software-engineering problems whose practical behavior can be understood by building and iterating on agents.
Context
The author presents LLM agents as a major computing idea whose practical behavior is difficult to understand abstractly. Building one is framed as a way to form sharper opinions, including informed criticism, while investigating unresolved engineering questions around agent design.
Approach / What changed
A Python implementation uses the OpenAI Responses API, a context array, and a loop for multi-turn interaction. A JSON-defined ping tool is added through function calls, with the agent repeatedly processing tool outputs. The discussion then considers extensions including bash, SQLite-backed context, alternative languages, and sub-agents.
Takeaways
The LLM is described as a stateless black box; multi-turn conversation comes from replaying stored user and assistant messages on every call.
Tool use requires a tool definition, a function that executes the requested operation, and a loop that returns function-call outputs to the model until no further calls are requested.
Agent design involves balancing explicit control against useful nondeterminism, connecting outputs to ground truth, coordinating intermediate forms, and containing token costs.
Source and freshness
- Source
- fly.io
- Published
- Added to Yomu
- Last updated
Summaries are generated from the original by a language model. Check the original before relying on it.
Keep reading
Related reading
The Good Stuff
Paid picks we use ourselves. Links carry a referral code — a subscription through one earns us a commission at no extra cost to you.
The best engineering reads, once a week
One useful email. Unsubscribe anytime.