How to build a production-shaped agent in ~150 lines of Python — no LangChain, no CrewAI, nothing you cannot read line by line.
A startup founder asked me a question I hear constantly: "Why are we paying for an agent framework when our feature is basically 'call the model, call an API, retry'?" He was not being cheap. He had watched a demo where a framework "did everything," then spent two weeks fighting its abstractions when his workflow did not fit the framework's opinion of how agents should work. The framework was not wrong. It was just a guess about his problem, and his problem was more specific than the guess.
So I did what I always do when a framework is in the way: I built the agent by hand. Around 150 lines of Python, no dependencies beyond an OpenAI-compatible HTTP client. When I opened the file for him, every token was traceable — he could see exactly what went into the context, what the model returned, and when the loop decided to stop. He shipped it to production the following week, and it is still running.
This article is that build, step by step. You will end with an agent that takes a goal, uses tools, has working memory, respects budgets, and escalates when it is out of its depth — and you will understand every line of it. Once you have built one of these by hand, every framework stops being magic and becomes a set of opinions you can evaluate.







