There are big ideas in computing that are easy to get your head around. The AWS S3 API. It’s the most important storage technology of the last 20 years, and it’s like boiling water. Other technologies, you need to get your feet on the pedals first.
Overview
Thomas Ptacek argues that every developer should build an LLM agent to truly understand the technology, demonstrating through progressive Python code examples that a functional agent with tool use can be built in surprisingly few lines of code. The article demystifies agents by showing they're essentially loops around stateless LLM API calls with context management, and makes the case that context engineering is a legitimate programming problem worth exploring.
What You'll Learn
How to build a functional LLM agent from scratch using the OpenAI API in under 50 lines of Python
How LLM context windows work mechanically as arrays of strings replayed with each API call
How to implement tool calling in an agent loop so the LLM can autonomously invoke external commands
Why context engineering is a real programming problem involving token allocation, sub-agents, and context segregation
Why MCP is unnecessary when building your own agent and how it limits architectural flexibility
Prerequisites & Requirements
- Basic understanding of Python programming
- Familiarity with HTTP APIs and JSON
- OpenAI API access and Python SDK
- General awareness of what LLMs are and how they generate text
Key Questions Answered
How do you build an LLM agent from scratch without a framework?
What is an LLM context window and how does it actually work in code?
What is the difference between an LLM chatbot and an LLM agent?
How does tool calling work in the OpenAI API for agents?
Why is MCP unnecessary for building LLM agents?
What is context engineering and why does it matter for LLM agents?
How do sub-agents work in LLM agent architectures?
Can an LLM agent autonomously decide which tools to use and how many times?
Technologies & Tools
Some links below are affiliate links. We may earn a commission if you make a purchase.
Key Actionable Insights
1Build your own LLM agent rather than relying solely on Claude Code or Cursor. The agent loop itself is trivially simple—just a context array, an API call function, and a tool-handling loop. Building it yourself gives you full control over architecture, security boundaries, and context management that pre-built tools abstract away.The article demonstrates the entire agent can be built in under 50 lines of Python, making the barrier to entry extremely low for any developer with API access.
2Implement segregated contexts with specific tools for each context rather than cramming all tools into a single context window. This approach solves both the token budget problem (too many tool descriptions eating into available space) and security concerns (limiting what each agent context can access).The article notes that early adopters became bearish on tools because one context window with many tool descriptions left insufficient token space. Segregated contexts are trivial to implement—just create additional context arrays.
3Skip MCP and implement tools directly as JSON schemas in your own agent code. MCP only saves a couple dozen lines of code while removing your ability to control agent architecture, and many security horror stories stem from dragging a single-context coding agent into inappropriate use cases via MCP plugins.This applies when building purpose-built agents for specific tasks like vulnerability scanning, customer service, or data analysis—anywhere you control both the agent and the tools.
4Treat context engineering as a real programming problem: manage your token budget by summarizing sub-agent outputs, using the LLM itself for on-the-fly compression, and building tree structures of agent interactions. The context window is a fixed resource that degrades nondeterministically when overloaded.Context engineering would be a mid-December Advent of Code problem—it's genuine programming involving data structure management, not the mystical 'prompt engineering' of crafting personality descriptions.
5Let the LLM decide strategy rather than writing explicit control flow for every scenario. The ping example shows the agent autonomously chose to test multiple Google properties without any explicit loop. Balance explicit control against LLM-driven exploration—too explicit and you lose emergent problem-solving, too loose and results become unpredictable.This design tension—titrating the right amount of nondeterminism—is one of the key open engineering problems in agent design that you can only develop intuition for by building agents yourself.
6Use ground truth verification to prevent agents from lying to themselves about having solved a problem and early-exiting their loops. Connect agent outputs to verifiable results (test suites, actual command outputs, database queries) rather than trusting the LLM's self-assessment.This is identified as one of the key open problems in agent design. The article's ping example naturally provides ground truth through actual network responses, illustrating the pattern.