AI Agents Book

Primitive of the day · 2026-09-30

opro-history-overflow-trim-oldest

When the (prompt, score) history overflows the optimizer model's context, trim the oldest pairs first — preserve the recent trajectory rather than truncating arbitrarily.

When this applies

A long-running LLM-as-optimizer loop whose accumulated history approaches the model's context window.

Preconditions

Do this

Drop the oldest (prompt, score) pairs first when the assembled optimizer prompt would overflow context, keeping the recent trajectory intact.

What you should see

The loop keeps running with the most decision-relevant history retained.

How it fails if ignored

Context overflow aborts or silently truncates mid-pair, corrupting the optimizer's view of the trajectory.

Do not use when

Short runs that fit comfortably in context; setups that summarize history instead of passing raw pairs.

Kind: gotcha-fix. Part of the skill OPRO LLM as optimizer. Free to reuse in your own agent skills.

Get the whole skill

All 5 primitives of this skill as one package, with the order to apply them.

Buy only the primitives you need

Each primitive is 1 credit (≈ €0.10). Pick them from the list above — the button is next to each one.

Upgrade your own skill

Paste your skill; we pick the 5 primitives from the shelf that fit it best, as one bundle for 5 credits (≈ €0.50).

Upgrade my skill

Register interest

Interest only — no payment, no order, no reservation. After you confirm by email we send you one free sample primitive.