AI Agents Book

Primitive of the day · 2026-11-10

reflection-loop-max-retry-cap

Every critic-revise (reflection) loop gets an explicit max_retry cap plus a quality bar that ends it early - never loop until 'good'.

When this applies

A generate-critique-revise loop drives quality improvement automatically.

Preconditions

Do this

Set a hard max_retry count; define the quality bar for early exit; on cap, return the best draft plus the critic trail instead of looping again.

What you should see

Loop terminates deterministically at the bar or the cap.

How it fails if ignored

Uncapped reflection loops run away on cost and API throttling; 'one more revision' never ends.

Do not use when

NOT for single-pass generation; NOT a substitute for defining the quality bar that ends the loop.

Kind: failsafe. Part of the skill Agentic design pattern selector. Free to reuse in your own agent skills.

Get the whole skill

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

Get just this primitive

This one primitive for 1 credit (≈ €0.10); the other primitives of the skill are on its page.

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.