Skip to main content
By the end of this guide you have a workflow in which an agent fixes your code, your own test command runs, and the agent tries again until the command exits 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

1

Create the workflow file

.reliant/workflows/fix-until-green.yaml
  • test is a run node. A non-zero exit does not fail it: exit_code, stdout and stderr are outputs you route on.
  • attempts is a loop node. The body declares exit_code and test_output as outputs, so while can read them after each round. Loops are do-while: the first round always runs, and iter.iteration is the number of finished rounds when while is checked (CEL loop conditions).
  • fix gets the previous round’s test output in its prompt from round 2 on. memo: true keeps 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 to passed and anything else to gave_up, and their outcome: 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
Lint also flags a 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:
.reliant/workflows/fix-until-green/scenarios/green_on_third_try.yaml
Add 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_attempts agent rounds run. The input’s max: 5 refuses 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.
A single round is not capped. 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_publish node 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

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.
-i reads true, false, null and numbers as JSON values. Quote the value to send it as text: -i 'test_command="false"'.
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.