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

Chapter 30: Self-Improving Agents and the Future

Central questionWhen can an agent legitimately be called self-improving? And how do we prevent adaptation from silently becoming regression, reward hacking, or uncontrolled self-modification?

Lecture

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

Chapter principle

The chapter ends with a set of contrasts. More memory is not better memory. More reflection is not better reasoning. More reward is not a better objective. More autonomy is not a better system. And more change is not improvement. Here is the final chapter principle. Improvement is measured change, not change itself.

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 57: Improving its own prompt

Can an agent improve its own prompt, and how do we know it really improved?

A real model sorts support requests into BILLING or TECHNICAL. A house rule says that a payment problem caused by a bug in the app is TECHNICAL, but the first prompt does not say so. The model then rewrites the prompt from the cases it got wrong. A second candidate simply lists the four development cases. All three prompts are scored on the development cases, on validation cases and on test cases that no candidate was written from. The winner is chosen on validation, and promoted only if it does better on the test cases without getting worse on either label. This is a recorded run of a real model. A new run may score differently.

Experiment 58: Learning from experience

How should an agent turn past tasks into lessons?

An agent has six records of past tasks: what went wrong, what it did, and whether it recovered. A rate-limit error (API-X 429) recovered with exponential backoff three times out of three. A timeout recovered with an immediate retry once and failed twice. Two learners turn these records into lessons. The naive one makes every success a global rule. The validated one promotes a lesson only with enough evidence, keeps its scope, and cites its source tasks. A real agent then handles three new problems, once with each set of lessons. This is a recorded run of a real model. A new run may choose differently.

Experiment 59: Reward hacking

What happens when an agent is optimized for a reward that only approximates the goal?

Support tickets are scored two ways. The proxy reward gives +1 for closing a ticket and costs 0.1 per action. The true objective rewards only a ticket that is fixed and then closed, and penalizes closing an unsolved one. First a real model is told the proxy reward and works one ticket. Then a simple search scores three behaviors over ten tickets: solve then close, close immediately, and the model's own. The search runs against the proxy, against the true objective, and against the proxy plus a hard rule: a ticket can only be closed after a verified fix. This is a recorded run of a real model. Its choices may differ in a new run.

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

This is Chapter 30 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 29: Computer-Use and Multimodal Agents