liveBook · Manning

Hill climbing

As explained in Self-Improving Agents

An iterative search method that makes local changes to a candidate and retains changes that improve its score.

Suppose an agent’s prompt scores 0.63 on a task. You ask for a rewrite, run the agent again, and keep the rewrite only if its score is higher. Repeat from the best prompt so far. That is hill-climbing: a cheap, single-threaded search that turns a measurement into a series of local changes. section 3.4.2 section 1.4.2

The ratchet has one decision per round:

  • Propose one rewrite of the current best artifact, using its score and feedback. section 3.4.2
  • Measure the candidate and record its result and lineage. section 3.4.1
  • Advance the current best only when the candidate’s score is strictly higher; otherwise, try another rewrite from the existing best. section 3.4.2

When the ratchet does not move

On a revenue-policy task, the starting prompt scored 0.63. Ten proposed rewrites failed to beat it, leaving a net gain of zero. Improving all six rules required accepting a worse intermediate prompt, but this hill-climber could not take that step. It had reached a local peak, not necessarily the best prompt available. section 3.4.2

Listing 3.7 The ratchet inside HillClimb (`helix/search/hillclimb.py`)
for round_idx in range(self.rounds):
    new_content, _ = await self._generate(current_best, current_score,
                                          current_feedback)    #A
    variant = Variant(
        artifact=current_best.mutate(new_content=new_content, ...),    #B
        parent=current_best,
        search_method=self.kind.value,
    )
    yield variant    #C
 
    if variant.measurement is not None:
        score = variant.measurement.score
        if score is not None and (current_score is None
                                  or score > current_score):    #D
            current_best = variant.artifact    #E
            current_score = score
            current_feedback = variant.measurement.feedback

The implementation shows the acceptance gate: a measured variant replaces the current best only when its score is strictly greater. section 3.4.2

Hill-climbing is a search component, not the whole improvement system. The surrounding loop can still measure a starting artifact, record rejected variants, and apply a separate deployment gate. A pairwise judge can supply the accept-or-reject signal instead of an absolute score, as in SPO. Neither version can cross a valley by retaining a worse candidate as its new best; an archive search can preserve those candidates for later exploration. section 3.4.1 section 2.3.4 section 4.3.4

How Self-Improving Agents covers it

How deep it goes
Works through the propose-measure-accept rule and its implementation, then demonstrates why a strict ratchet stalls at local peaks.
Examples
Tests ten revenue-policy rewrites against a 0.63 baseline and contrasts a greedy climber with archive search on a toy landscape.
What it assumes
Assumes familiarity with agent runs and prompts while explaining the score-driven acceptance rule directly.
What you can do after
Build it from scratch as a strict-improvement loop and recognize when a local peak calls for broader search.
How it connects
Connects hill-climbing to evaluation signals, prompt optimization, pairwise judging, local optima, and evolutionary archive search.

Also explained in

Compare how 3 books explain hill climbing →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Self-Improving Agents. The section links point to the parts of the book it draws on.