Checks on an output file
How to have Cerevisor run a command on a file an agent wrote, and send the agent back once if the command fails.
An agent can say a file is finished when it is not. A check is a command that Cerevisor runs on the file after the agent writes it, so the answer does not depend on what the agent says. If the command fails, the agent is sent back to fix the file.
What a check is
A check is one command, written the way you would type it in a terminal. Cerevisor puts the full path of the file where you write {file}:
python check_script.py {file}
The check passes when the command ends with exit code 0. Any other exit code is a failure, and so is a command that runs out of time.
Cerevisor reads the line as a program and its arguments. It does not run it as one line of shell text, so pipes (|), &&, > and variables do not work in a check. To use them, put them in a script and run the script. Use quotes to keep words together as one argument, for example python "my checks.py" {file}. The file's path always reaches the command as one argument, even when it has spaces in it.
Adding one
- Open the agent and go to Output Files.
- Under the file, open Contract.
- Type the command in Checks Cerevisor runs on this file. Write one command per line, up to 3.
The field saves when you click out of it. Blank lines and repeated lines are dropped, and so is a line longer than 500 characters. A line Cerevisor cannot read is not marked in the field. You find out during the run, where the check shows as not run, with the reason (see below).
A check only runs on a file the agent wrote or changed in this run. A file that was never created gets the usual "not created" message instead.
What happens
- Where and how long. The command runs in the workflow's working folder, and may take 5 minutes at most. Checks run one at a time: if a test run or a build is already going in Cerevisor, a check waits for its turn.
- What you see. The run window lists each check as it finishes: Check passed on the file, Check failed on the file, or Check not run on the file.
- A failure. The agent is sent back once. It is told which command failed and how, with the end of what the command printed. If the agent rewrites the file, the check runs again on the new version.
- A second failure. The step fails, and by default the whole workflow stops. That is the Halt workflow on contract failure setting. With it off, the agent's On Failure setting decides what the next step gets. If the file's contract is advisory, which is how the chat builder marks a rule it suggested, a second failure only shows a warning and the file is kept.
- Strict output contracts off. The check still runs and its result is shown, but a failure does not send the agent back and does not fail the step.
When checks do not run
A check that does not run is not counted as a failure, and the agent is not sent back. It shows as Check not run, with one of these reasons:
- This workflow does not allow commands. The workflow's Bash execution permission is off, or the run was started with commands turned off. A run can only narrow what the workflow allows, never widen it.
- Cerevisor could not read the command. A quote is never closed, the line has a line break or a hidden character, it uses a
%sign, it names no program, or an argument is empty. The same applies when the file's own location has a%sign or a hidden character in it. - The run was stopped. You stopped the agent or the run before the check finished.
Each check that did not run, and each check whose last result was a failure, is also listed when the run ends, under the run's results. A run that would have been Complete finishes as Finished, needs attention instead. See Needs attention. A run that was stopped gets no such list.
Safety
- You approve a new check. Once you have run and approved a workflow, a check that is new or changed is listed in the summary before the next run you start, and the run waits for you to approve it. A new agent that comes with checks is listed too. Removing a check asks for nothing. This needs Ask me before running a workflow that gained new powers to be on in Settings, and it covers runs you start yourself, not a Power or a later pipeline step that a run starts for you. A workflow Cerevisor has not approved yet runs its checks without asking, so read the checks of a workflow file you did not write before you run it.
- A shared workflow never carries checks. When you share a workflow, its checks are left out. Opening a shared file that contains one is refused, with the reason: "This shared workflow contains a command to run on your computer. Shared workflows can't carry one." See Sharing a workflow.
- The chat builder cannot write checks. Only you can add or change one, in the field above.
- Checks get no Vault secrets. A check runs with a reduced set of environment variables: the ones a program needs to run on your computer, your network settings (proxy and certificate), and a setting that tells test tools to run once and exit. No Vault secret and no provider API key is added.
- A check still runs as you. It can read and change whatever you can. Only write commands you trust.
See also
- Attach markdown files: input and output files, and the contract on an output file.
- Add and configure agents: every field on an agent.
- Run and monitor: what the run window says when a check failed or did not run.