Coding agent in 94 lines of Ruby

https://news.ycombinator.com/rss Hits: 15
Summary

“It’s not that hard to build a fully functioning, code-editing agent.”Thorsten BallAn article floated into my reading list: How to Build an Agent, or: The Emperor Has No Clothes. The author, Thorsten Ball, claims building a coding agent isn’t hard, then builds one in ~400 lines of Go. While reading the code, I kept thinking that a lot of it is boilerplate. My keen suspicion received confirmation when the author wrote: “… most of which is boilerplate”.Boilerplate? Ruby excels at eliminating boilerplate, leaving just the essence. I thought: creating this in Ruby must be even more straightforward. So I tried it. And straightforward it was!Doing the exercise in Ruby gave me two interesting realisations which I’ll share at the end of the article.The good news is that the end of this article really isn’t far because of how straightforward the agent was! This is some top notch drama here.Interested in trying out the final agent? Find the full code on GitHub: radanskoric/coding_agent. It includes a handy one-line command for building and running it through Docker.Building the agentA coding agent, stripped to its bones, is simply an AI chat agent with tool access.Most modern LLMs, especially those from large vendors, can use tools. Under the hood, tools are simply functions with descriptions of their purpose and expected parameters, formatted in LLM-recognizable ways.The basis of an AI chat agent is a chat loop:Read a user prompt.Feed the prompt to the LLM.Print the LLM response to the user.Repeat until the user finds something better to do.To make it an agent, you give it some tools. It turns out that for a very simple coding agent you need just 3 tools:Read file: given a file, return the content of the file.List files: given a directory, return a list of files in the directory.Edit file: given a file, original string and new string, update the file by replacing the original with new string.Remarkably, adding just these 3 tools to an LLM-connected chat loop transforms the p...

First seen: 2025-05-16 22:45

Last seen: 2025-05-17 12:47