The loop at a glance
One pass through the loop: a requirement gap goes in, a validated and reviewed fix comes out, then the next gap starts it again.
Before the loop
relai init seeds, locally validates, and registers the simulator
harness that lets RELAI run your git-tracked agent project. Run it once per
project, before the first pass. If it pauses for input, approval, an external
action, or an interruption, continue with relai init --resume.
The loop, step by step
Each pass moves through four stages: a requirement gap is found, the expected behavior is defined, a fix is optimized and validated, and the improvement is shipped for review. Then the loop repeats.Requirement gap
Every pass starts with a real signal: a failure in production, or any gap between how the agent behaves and the business requirements it should meet. You bring the case that fell short and the outcome you expected, and the rest of the loop turns it into a fix.
Define expectations
Define the behavior you expect so RELAI has something concrete to target. You can express it three ways:
- Learning environments are the unit of behavior: a repeatable scenario RELAI can simulate and optimize against. Create one from a prompt, or from a real run log plus your feedback, with
relai learning-env. - Benchmarks are reusable evaluation suites built from a CSV, so you measure against the same cases on every pass. Register and list them with
relai benchmark. - Evaluators score agent behavior, so the loop has a number to act on instead of a pass-or-fail judgment. Scope one to an environment or a benchmark, or register it globally so it applies across runs, with
relai evaluator.
Optimize & validate
Measure where the agent stands, then let RELAI improve it and prove the improvement held.
- Simulate runs your agent against the environments or benchmarks you select and reports the evaluator scores. It does not change your agent; it shows where the agent stands today. Run it with
relai simulate. Simulating first is optional — optimize runs its own before-and-after evaluation. - Optimize runs its own before-and-after evaluation, then proposes improvements to prompts, configs, and structure and validates the result. Run it with
relai optimize.
Review improvements
Accepted changes are committed to a separate local optimizer branch. When GitHub CLI is available and authenticated, RELAI can push that branch and open a pull request; otherwise, review and publish it yourself. Once the change merges, the next gap you spot becomes a new learning environment, and the loop runs again. Optimize’s before-and-after evaluation pass provides the attached proof, and memory carries forward, so each pass builds on what earlier ones learned.
Memory and tags
Memory and tags shape the whole loop rather than a single stage. Memory is markdown guidance RELAI considers during later generation and optimization, scoped to an agent, tag, component, or evaluator. Tags group learning environments into a reusable suite you can select by name when you simulate and optimize. Manage both withrelai tag & memory.
Related pages
Quickstart
Run init, simulate, and optimize on your own project in 5 minutes.
All commands
Every
relai command with flags, examples, and failure modes.