0. A cap on attempts ends a run that cannot succeed, so it does not keep spending.
The agent does not decide when it is done. A run node executes your test command, and the loop and the final edge route on its exit_code.
Before you begin
- Read Write your first multi-agent workflow for the basics of a workflow file,
validate,lintand scenarios. This guide does not repeat them. - A git repository with a test command that fails today. This guide uses a Python
slug.pywhose three unittest tests fail. - For running it live: a signed-in CLI (Sign in and tokens) and a connected machine that holds the repository (Run a machine from the terminal).
1
Create the workflow file
.reliant/workflows/fix-until-green.yaml
testis arunnode. A non-zero exit does not fail it:exit_code,stdoutandstderrare outputs you route on.attemptsis aloopnode. The body declaresexit_codeandtest_outputas outputs, sowhilecan read them after each round. Loops are do-while: the first round always runs, anditer.iterationis the number of finished rounds whenwhileis checked (CEL loop conditions).fixgets the previous round’s test output in its prompt from round 2 on.memo: truekeeps the agent’s own conversation across rounds, so it knows what it already tried.- The final edge is a CEL condition on the loop’s last
exit_code. It sends a green run topassedand anything else togave_up, and theiroutcome:sets the run’s verdict.
2
Check the cap with lint
while has two halves. outputs.exit_code != 0 ends the loop when the tests pass, and iter.iteration < inputs.max_attempts ends it when they never do. Lint warns when the second half is missing. With it removed:terminal
run node with no timeout: (run-no-timeout). And it flags a timeout: on the agent node, which bounds nothing (timeout-ignored). With the file as written, reliant workflow validate reports ✅ All workflows valid and lint reports 0 lint error(s), 0 warning(s).3
Test every ending with scenarios
A scenario mocks the agent and the test command by node path, so you check the loop without spending tokens. This one fails twice and passes on round 3:Add
.reliant/workflows/fix-until-green/scenarios/green_on_third_try.yaml
green_first_try.yaml, with one fix and one exit_code: 0, expecting _iterations: 1. Then add gives_up_at_max.yaml, with inputs: {max_attempts: 2}, two failing rounds, and expect: {outcome: failed, completed: [attempts, gave_up]}. That one proves the cap stops the run:terminal
4
Run it on your repository
Commit first, so
git diff shows only what the agent changed:terminal
--follow exits 0 when the run succeeds and 1 when it fails, so a script can act on the verdict.5
Verify the result
terminal
test ran once, so the first fix passed. To watch the cap work, give the loop a command that can never pass. -i 'test_command="exit 1"' -i max_attempts=2 ended after two rounds at gave_up, with Outcome: ✗ FAILURE and test listed as 2 runs, 2 failed.What bounds the cost
- The attempt cap. At most
max_attemptsagent rounds run. The input’smax: 5refuses a higher value before the run starts:input 'max_attempts' must be <= 5. - The exit condition. The loop stops at the first green round, so a fix that works on round 1 costs one round.
- The test timeout. A hung test command stops after
timeout: 5m, instead of running for the 30-day default.
builtin://agent works until it finishes its turn, and a timeout: on that node bounds nothing.
What this does not do
- It does not stop the agent from editing tests. The prompt asks it not to, but the gate is only your command’s exit code. Read the diff before you keep it.
- It does not commit, push or open a pull request. Add a
git_publishnode for that. - It does not review the change. Passing tests are the only check. To add a reviewer agent, lint and build gates, use Get It Right.
Troubleshooting
no machine has synced this project's workflows yet
no machine has synced this project's workflows yet
The first
reliant workflow run --project-path on a new folder creates the project before its machine has synced .reliant/workflows/. Wait about 20 seconds and run the same command again.input 'test_command' expects string, got bool
input 'test_command' expects string, got bool
-i reads true, false, null and numbers as JSON values. Quote the value to send it as text: -i 'test_command="false"'.[loop-unbounded] attempts: the loop's while never reads iter.iteration
[loop-unbounded] attempts: the loop's while never reads iter.iteration
Add
&& iter.iteration < inputs.max_attempts to while. Without it, only a passing test ends the loop.Next steps
Write your first multi-agent workflow
A planner, an implementer and a reviewer that sends work back.
Get It Right
The built-in loop with lint, test and build gates and a reviewer.
How workflows run
How loops, edges and outcomes are evaluated at run time.
CEL expressions
Every namespace a
while or edge condition can read.