A gate is a check on a task’s output. A task is done only when every one of its gates passed, and each
result is written to the ledger. This guide adds a rule gate to the dev-team template and shows it pass and
fail.
Diagram as text
- The worker hands in its output.
- Rule gates and test commands run first. They make no model call.
- A verifier gate runs next. It costs one model call.
- A human gate asks a person.
- The task is done only when every gate passed.
Prerequisites
Section titled “Prerequisites”- A
dev-teamfolder namedmy-teamthat runs (Start from a template). - The idea of a definition of done: Tasks and gates.
The kinds of gate
Section titled “The kinds of gate”| Kind | What checks the output |
|---|---|
rule |
fixed checks on the output: text it must or must not contain, a pattern, a length, a value at a path |
test_command |
a command, such as the project’s tests, run in the sandbox |
verifier |
another agent: Add an independent verifier |
human |
a person: Require a human approval |
The template’s team.py has a working example of each of these four.
-
Open
my-team/team.pyand find the taskfix. Itsdefinition_of_donehascriteria, the statements that must be true, andgates, the checks that give evidence for them. -
Add a criterion to the
criteriaoffix, after thefixedcriterion.Criterion(id="no-debug", text="The fix leaves no debug output behind"), -
Add a gate to the
gatesoffix, between thehas-fixgate and thetestsgate.checksnames the criterion the gate gives evidence for.GateSpec(id="no-debug",kind=GateKind.RULE,checks=("no-debug",),config={"rules": [{"criterion": "no-debug","check": {"type": "not_contains", "value": "print("},}]},), -
Run the team.
Terminal window nuramesh try my-team --fake --approve-as human:you --allow-unsandboxed --run-id gate-1
Rule checks
Section titled “Rule checks”type |
Passes when | Keys |
|---|---|---|
contains |
the text contains value |
value, case_sensitive (default true) |
not_contains |
the text does not contain value |
value, case_sensitive (default true) |
matches |
the regular expression pattern matches somewhere |
pattern |
length_between |
the text has between min and max characters |
min (default 0), max |
path_exists |
structured output has a value at path |
path |
path_equals |
structured output has exactly value at path |
path, value |
Text checks look at the output if it is text, and at its JSON form otherwise. A path is dotted keys and
[index] steps, for example files[0].name.
Check it worked
Section titled “Check it worked”The task has a new gate line:
[done] gate-1-fix-add (dana, attempts 1): Fix the failing add() test in calc.py gate has-fix (rule): passed by gate:rule gate no-debug (rule): passed by gate:rule gate tests (test_command): passed by gate:test_command gate review (verifier): passed by agent:rheaTo see a gate stop a task, change the gate’s "value": "print(" to "value": "return a + b", text the
fix must contain, and run again with a new run id:
nuramesh try my-team --fake --approve-as human:you --allow-unsandboxed --run-id gate-2Tasks: 2 cancelled, 1 needs_human [needs_human] gate-2-fix-add (dana, attempts 2): Fix the failing add() test in calc.py gate has-fix (rule): passed by gate:rule gate no-debug (rule): failed by gate:rule gate tests (test_command): passed by gate:test_command note: failed after 2 attempts: no-debugThe developer got the gate’s feedback and tried again, up to the task’s max_attempts. Then the task went to
a person. The review gate has no line: the verifier was not called, because a cheaper gate had already
failed. The command exits with code 1. Put the value back afterwards.
Troubleshooting
Section titled “Troubleshooting”| You see | Do this |
|---|---|
gate 'no-debug' checks unknown criteria |
checks names a criterion that is not in the task’s criteria. Step 2 is missing or the ids differ |
| An error that names the task and the gate, before the run starts | The gate’s config is not valid, for example an unknown check type |
| A gate fails on every attempt | Read the gate line and the note, then the check itself: Read a gate result |
| A test gate refuses to run | No container runtime was found: Run in a sandbox |
Next steps
Section titled “Next steps”- Add an independent verifier: a gate checked by another agent.
- Require a human approval: a gate decided by a person.
- Read a gate result.
Was this page helpful?