Build an Autonomous Agent Using This Simple Recipe! The ability of large language models to carry out multiple steps autonomously makes it possible to build a capable agent in a few lines of code.

Published
Reading time
2 min read
Screenshot showing Python code generating a playable Snake game and the modern Snake game interface running on the right side.
Loading the Elevenlabs Text to Speech AudioNative Player...

Dear friends,

If you have not yet built an agentic workflow, I encourage you to try doing so, using the simple recipe I’ll share here! With a few lines of code, you can now build a highly autonomous, moderately capable, and highly unreliable agent.

The ability of frontier LLMs to carry out multiple steps autonomously makes this possible. Specifically, you can give an LLM a tool such as disk access (or web search), instruct it via a prompt to perform a high-level task such as creating a game and saving it as an HTML file (or carrying out deep research on a topic), and let it loose and see what it does.

Important caveat: Hardly any of today’s many practical, commercially valuable agentic workflows were built using this simple approach. Today’s agents need much more scaffolding — that is, code that guides its step-by-step actions — rather than just letting an LLM have access to some tools and fully autonomously decide what to do. Building a reliable agent today requires much more scaffolding to guide it; but as LLMs become more capable, we will see successful agents built with less scaffolding.

If you want to build practical agents, our Agentic AI course is the best way to learn how. But you can still have fun playing with this simple but less practical recipe!

A quick way to implement this recipe is to use the open source aisuite package (pip install "aisuite[all]") that Rohit Prasad and I have been working on. This package makes it easy to switch LLM providers and also to get an LLM to use tools (function calls) without needing to write a massive amount of code.

Aisuite started as a weekend project when I was trying to solve my personal pain point of wanting an easy way to switch LLM providers. After building a workflow using a specific LLM, I often want to quickly try out alternatives to see if they perform better in accuracy, latency, or cost. Routing my LLM API calls through aisuite makes these swaps much easier. Many members of the open-source community have been contributing to this, and Rohit recently added MCP support, which makes it easy to build basic agentic workflows.

You can see the entirety of the code needed to generate a snake game in the image above, and access it in this Jupyter notebook. After writing a prompt instructing an LLM to create an HTML file with a snake game, the two steps are: 

  • Initialize the MCP-based file-system tool to let it write files.
  • Let loose a frontier model (such as GPT-5.1, Claude Sonnet 4.5, or Gemini 3).

This (usually) results in the LLM creating a snake game and using the MCP server to save a file snake_game.html, which you can open in a web browser. (The parameter max_turns=5 means that it will alternate between calling the LLM and letting the LLM execute a tool up to 5 times before exiting.)

For another example, here’s a second notebook that demonstrates giving an LLM access to a web search tool and letting it autonomously decide when and how much to search the web to compile a report or HTML dashboard on the weather in multiple cities or some other topic of your choice.

If you have not yet built an agent, I hope this simple recipe lets you build your first one. Please run pip install "aisuite[all]" and have fun!

Keep building!

Andrew 

Share

Subscribe to The Batch

Stay updated with weekly AI News and Insights delivered to your inbox