Agentic Engineering from First Principles All chaptersLecturesLabDownload the book
Part VI · Advanced Agentic Engineering

Chapter 28: Coding Agents

Central questionWhat changes when an agent can inspect software, modify it, execute it, observe failures, and iteratively repair its own proposed solution?

Lecture

The narrated lecture for this chapter is coming soon on the YouTube channel.

Chapter principle

Executable feedback changes the game. Coding agents are powerful not because code models never make mistakes, but because candidate actions can often be executed, tested, observed, repaired, rolled back, and constrained.

Key takeaways

Experiments

Every experiment in the book is small, runnable and printed with its real output. In the Lab you can replay a recorded real run of each one, with no programming, and watch what the model and the agent do.

Experiment 53: The smallest coding agent

What is the smallest agent that can fix a bug in code?

A tiny project has one bug: add(a, b) returns a − b, so its one test fails. A real model gets four tools: list the files, read a file, replace one exact piece of text in a file, and run the tests. It is told to make the tests pass by fixing the code, not the tests. The loop ends when the tests pass, not when the model says it is done. Afterwards the program checks that the file tools refuse a path outside the project folder. This is a recorded run of a real model. A new run may take different steps.

Experiment 54: Iterative repair

Can test failures guide an agent to working code?

A real model must write parse_price(text), which turns a price such as “$1,234.50” into a whole number of cents. The harness owns four tests the model never sees: a dollar amount, a plain number, a euro price with a decimal comma (“3,50 EUR”) and an empty string. After each attempt the whole test suite runs, and only the failures go back to the model. It gets at most four attempts. This is a recorded run of a real model. A new run may fail different cases, or none.

All the code for this chapter: github.com/agentic-engineering-book/code

This is Chapter 28 of Agentic Engineering from First Principles: thirty chapters, a case study and fifty-nine executable experiments, from a single model call to controlled, self-improving agents.
Download the bookBrowse all chapters
← Chapter 27: Budgets and StoppingChapter 29: Computer-Use and Multimodal Agents →