liveBook · Manning

Chapter 2: Getting started improving agents

What you will learn in chapter 2 of Self-Improving Agents

The chapter introduces an offline improvement loop for a RAG agent’s prompt instruction and previews the tools used to build it.

After this chapter you will be able to

What it builds on

Section by section

Introduction

The chapter introduces an offline improvement loop for a RAG agent’s prompt instruction and previews the tools used to build it.

2.1 Building the agent and text prompt artifact

This introduction previews the agent setup, model choices, and archive needed before improvement can begin.

2.1.1 Introducing the RAG agent

Introduces a RAG agent as the example for improving a prompt instruction, and explains why the example can work with different document collections.

Key terms: RAG (Retrieval Augmented Generation) agent, prompt instruction, prompt artifact, self-improving agent, Helix, document corpus

2.1.2 Running the code and picking LLMs

This section explains the LLM access needed to run the examples and why the book usually favors inexpensive, available models over cutting-edge ones.

Key terms: improvement loop, signal and search methods, rate limits, cutting-edge model, LLM API, commercial service, open-weight models, local/cloud options

2.1.3 Discovering layer 0 – the helix framework

This section explains why Helix is used and how its basic RAG agent is assembled and run.

Key terms: Helix, hooks, tracking, improvement patterns, RAG agent, build_retrieval_tool(), harness, model, prompt, tools

2.1.4 Connecting the prompt artifact archive

The section connects a RAG agent’s system prompt to an artifact archive and explains how the archive records, selects, and promotes prompt versions.

Key terms: artifact archive, measured signals, best(), promote(), SQLite archive, system prompt, genesis, prompt Artifact

2.2 Measuring the signal

The section explains why measuring an agent’s performance starts with defining what a good response contains.

Key terms: signal, standard, evaluation

2.2.1 Establishing what good is

This section explains ways to judge an agent’s output and how to choose an evaluation signal by balancing precision against availability.

Key terms: gold set, rubric, LLM-as-Judge, programmatic, human evaluator, signal, precision, availability

2.2.2 Producing the signal gap measurement

This section defines the signal as an interchangeable way to measure the gap between an agent’s output and a standard of good, while keeping its inputs and output format fixed.

Key terms: signal, agent's output, gap, LLM-as-Judge, GapMeasurement, score, preference, feedback, confidence, Search

2.2.3 Implementing LLM-as-Judge for signal measurement

This section shows how a pairwise LLM judge uses an ordered rubric and a swap-and-agree check to produce a more reliable comparison signal.

Key terms: LLM-as-Judge, pairwise evaluation, position bias, swap-and-agree, TIE, rubric, system prompt, reference answer, factual accuracy, grounded in the sources

2.3 Searching for artifact variants

Search seeks better artifact candidates for self-improvement rather than retrieving an answer the agent already has.

Key terms: Search, candidate, archive

2.3.1 Selecting the search method

This section explains how search uses a measured signal to propose and select improved prompt artifacts, and why the chapter starts with a simple search method.

Key terms: signal, search, system prompt, artifact, judge, current best artifact, live-champion prompt, variants, parent pointer, lineage

2.3.2 Search cost versus reach

This section maps search methods by cost and reach, then gives a rule for choosing a method without paying for unnecessary power.

Key terms: cost, reach, rising frontier, SPO, GEPA, DGM, search, landscape, cheapest search

2.3.3 Inside the search

Search repeatedly proposes, measures, and selects artifact variants, with search methods differing in how they propose variants.

Key terms: Propose, Measure, Select, signal, artifact, pluggable slot, SPO, GEPA

2.3.4 Understanding SPO (Self-Supervised Prompt Optimization)

Explains how SPO improves a prompt by comparing outputs rather than grading them against labeled answers, and why that makes the search cheap but limited.

Key terms: Self-Supervised Prompt Optimization, self-supervision, pairwise judge, labeled answer key, Mutate, Score, Accept, hill climb, current best, sample questions

2.3.5 Implementing SPO search

This section shows how a small SPO implementation proposes, scores, and accepts prompt improvements using a pairwise judge without correct answers.

Key terms: propose_mutation, score, SPO, mutate, score, accept, swap-and-agree judge, proposer, rubric, judge, grounding, pairwise judge

2.4 Putting it together with Helix

Helix packages the self-improvement loop’s previously hand-built pieces as objects that can be composed instead of rebuilt.

Key terms: Helix, artifact in an archive, pairwise judge, SPO search, primitives

2.4.1 Understanding the helix components

This section shows how Helix combines offline evaluation and search while keeping changes to the live agent behind a deliberate promotion gate.

Key terms: Signal, Search, SPO, OfflineImprover, SQLiteArchive, eval set, Live, archive, deploy gate, promote()

2.4.2 The OfflineImprover

This section shows how OfflineImprover runs one offline improvement round and tests a candidate prompt without changing the original agent.

Key terms: OfflineImprover, Agent, artifact ID, Search, Signal, Archive, Propose, Measure, Record, agent.with_artifacts(candidate)

2.4.3 The ImproverPolicy

The ImproverPolicy configures when improvement rounds run, how much they can cost, and when a candidate qualifies as a winner.

Key terms: ImproverPolicy, OfflineImprover, MANUAL, INTERVAL, CONTINUOUS, trigger_round(), eval questions, budget, per-question caps, promote_threshold_win_rate

2.4.4 The code

This section shows how a short Helix script runs offline prompt improvement while keeping measured candidates separate from the prompt the agent serves.

Key terms: main_async, archive, seed, four primitives, improver, rounds, offline improvement, measured candidates, genesis prompt, deploy gate

2.5 Exercises

Five exercises have the reader establish a RAG-agent baseline, verify its prompt archive, test judge biases, and promote an improved prompt.

2.6 Summary

This summary brings together how an offline loop improves a RAG agent’s prompt by measuring outputs, searching prompt variants, and deliberately promoting a winner.

Where this is used later

Concepts explained in this chapter

← Chapter 1: Foundations of self-improving agents Chapter 3: The Gödel Machine, and the importance of signal →

These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.