goals.yaml
The goal critic holds every attempt of a skill’s subagent to this file. Read this page to write acceptance criteria, or to understand why a result was rejected.
goals.yaml defines when the skill’s result is accepted. The file is optional; unknown keys are rejected.
| Key | Type | Default | Rules |
|---|---|---|---|
max_attempts |
integer | 3 | 1 to 10. How many times the subagent may try. |
checks |
list | none | Commands run in the sandbox, in order. |
checks[].name |
string | required | Unique within the file. |
checks[].run |
string | required | A shell command, run from the repository root. |
checks[].timeout |
duration | 10m |
Go duration syntax: 90s, 15m, 1h. |
checks[].expect_failure |
boolean | false | The command must exit non-zero. |
checks[].skip_if_unset |
boolean | false | Skip the check while a ${NAME} it uses has no value. |
checks[].on_base |
boolean | false | Run the check on the code from before the pull request, with the session’s changes on top. See below. |
constraints.max_changed_lines |
integer | 0 | Cap on added plus removed lines. 0 means no cap. |
constraints.forbidden_paths |
list of globs | none | Files the skill must not change. |
constraints.required_paths |
list of globs | none | At least one changed file must match one of them. |
constraints.allowed_paths |
list of globs | none | Every changed file must match one: added, modified, deleted, and both sides of a rename. @tests matches test files. |
constraints.no_changes |
boolean | false | The workspace must be left untouched. Cannot be combined with required_paths. |
judge.rubric |
string | required with judge |
What a model grades the result against. |
judge.model_tier |
string | strong |
The tier of the judge. |
Checks
Each check is a command that must exit 0. All checks run after every attempt, in file order; a failed check does not stop the ones after it. The last 4000 characters of a failed check’s output go back to the subagent with the verdict.
expect_failure: true inverts a check: it passes when the command exits non-zero. The built-in reproduce-bug skill uses it to require that the new test fails before any fix exists. A command that hits its timeout never passes, whether or not failure was expected.
Checks against the code from before the pull request
on_base: true runs a check on the code the pull request started from, with the session’s own changes on top. With expect_failure: true it means “fails without the change”: the built-in write-tests skill uses it to require that its new tests fail on the code from before the pull request and so actually test the change.
The check runs in the workspace itself, not in a separate checkout, so installed dependencies, virtual environments and generated files are still there and a new test cannot fail on the base for want of them. For the run, the goal critic:
- Takes the files the pull request changed that the session did not change.
- Checks them out at the pull request’s merge base, and deletes the ones the pull request added.
- Runs the check with
KOJO_ON_BASE=1set. - Restores those files from the pull request’s head, where the workspace started.
- Checks that the workspace’s tree is the one from before the check. If it is not, for example because the check left a build artefact that
.gitignoredoes not cover, the goal fails as an error that names the files.
The files are restored after a timeout or a failed run too. A file the session changed keeps the session’s version during the run. Linked repositories are not swapped.
Before a skill with an on_base check runs on a pull request, kōjō finds the pull request’s merge base in the sandbox: it fetches the base branch, up to 200 commits, and asks git for the merge base with the pull request’s head. When the base branch moved more than that, it fetches the commit the forge names as the pull request’s base and up to 200 more commits of the head, and tries again. The result, or the reason there is none, is kept for the rest of the session. In an eval case the base is the case’s pull request diff applied in reverse.
KOJO_PR_BASE holds the merge base’s commit, in every exec of the subagent and every check, once it is known. A subagent can read the pull request’s change to a file with git diff "$KOJO_PR_BASE" -- <path>.
What the check reports when it cannot run:
- Skipped on a session without a pull request, such as
kojo run --skill write-testswith a task. It does not count as passed or failed. - Unverified on a pull request whose merge base was not found. The attempt is not rejected, since the subagent cannot fix that, but the result is published only as a draft, with the reason in its description.
- A check with
skip_if_unset: truewhose value is unset is skipped as any other check is, before any of this.
flowchart TD
C["on_base check, value set"] --> PR{"Session on a pull request?"}
PR -- no --> S["Reported skipped"]
PR -- yes --> MB{"Merge base found?"}
MB -- no --> U["Reported unverified: the pull request stays a draft"]
MB -- yes --> SW["Files the pull request changed and the session did not: checked out at the merge base, added ones deleted"]
SW --> RUN["Run with KOJO_ON_BASE=1"]
RUN --> RS["Those files restored from the pull request's head"]
RS --> T{"Tree as before?"}
T -- no --> E["The goal fails as an error"]
T -- yes --> R["Pass or fail as any check; expect_failure inverts"]
Values in checks
${NAME} in a run command is replaced by a value. Values come from, in rising priority:
- The
inputsof the request:kojo run --input NAME=value, theinputsof an API request, or an eval case, see Evals. Names starting withKOJO_are reserved, and an input namedreference.<name>is a reference repository. - What earlier skills of the same session recorded, for the names they declare in
outputs. A value an earlier skill recorded without declaring it is shown to later skills but never reaches their checks, so a value a model chose, such astrue, cannot pass another skill’s check. - What this skill recorded with
set_outputduring the run being checked.
How a value is placed depends on the command:
- When the whole command is one variable, as in
run: ${TEST_CMD}, the value runs as written. This grants nothing new: it runs in the sandbox the subagent already has a shell in. - When the variable is part of a longer command, as in
run: go test -run ${TEST_NAME} ./..., the value is quoted for the shell and stays a single argument.
When a variable has no value, the check fails without running, and the subagent is told which value it did not record. With skip_if_unset: true the check is skipped instead and counts as passed. Use it for commands not every repository has, such as a linter.
Constraints
Constraints bound the diff of one run of the skill: what changed in the workspace since this skill started, not since the session started. Files hidden by .gitignore are not part of the diff.
forbidden_pathsandrequired_pathsare globs where**crosses directories:.github/**,**/*_test.go.- A
forbidden_pathsentry may contain${NAME}, for example"${REPRO_TEST}". While that value is unset the entry is skipped. required_pathsis met by a file that was added or modified, not by a deletion.allowed_pathsis the other way round: every changed file must match one of its entries, whether it was added, modified or deleted. A renamed file is a deletion and an addition, so both its old and its new path must be allowed. An entry may be a glob, a glob with${NAME}in it, or@tests.@testsmatches test files: files under a directory namedtest,tests,__tests__,spec,specs,testdata,e2e,__snapshots__or__mocks__(and a few more), and files named as the common languages name tests, such as*_test.go,test_*.py,*_test.py,conftest.py,*.test.ts,*.spec.js,*_spec.rb,*Test.java,*_test.shand*.bats. The full rules are in internal/testpaths/testpaths.go; history evals use the same rules.- An
allowed_pathsentry whose${NAME}has no value matches nothing, and the failure names the value. A list whose entries all name unset values allows no change at all. no_changes: truealso changes how the skill is classified: a skill withno_changescounts as read-only even if it listsexec. Requests from actors who may not trigger write actions only reach read-only skills. See Who may trigger what.
Constraints and checks need a sandbox. A skill that lists no sandbox tool and has no checks runs without one, and its constraints are not evaluated.
The judge
judge adds a rubric that a model grades the result against. It runs only when every deterministic criterion has passed, so no model call is spent on work that already failed. The judge sees the rubric, the task, the subagent’s final report, the recorded values, how many comments were posted, the names and states of the checks, the diff, and, for a session on a pull request, the pull request’s own diff (at most 60 KiB; a longer one loses its middle), so it can tell whether the work follows the pull request’s change. It is told to fail anything it cannot verify from that evidence and to trust the diff over the report.
Write rubric items as statements that can be checked against the report and the diff. One item per line.
How the goal critic uses it
After every attempt the goal critic checks, in order: that each declared output has a value and there is a final report; the constraints on the diff; the checks; then the judge. If anything is unmet, the same subagent receives the list of unmet criteria and the failing output and tries again, up to max_attempts. The result of the last attempt is delivered either way, with the report of what is unmet. A subagent that uses all its max_steps is not retried. The place of the critic in a session is described in Concepts.
One skill run, from the first attempt to the verdict that is delivered:
flowchart TD
A["The subagent ends an attempt"] --> D["Outputs and report, constraints, every check"]
D --> E{"All met?"}
E -- no --> F{"Attempts left, and max_steps not used up?"}
E -- "yes, no judge" --> OK["Accepted"]
E -- "yes, with a judge" --> J{"Judge's verdict"}
J -- pass --> OK
J -- "unmet rubric items" --> F
J -- "no verdict, twice" --> ER["The skill run ends with an error"]
F -- yes --> R["Unmet criteria and failing output go back to the same subagent"]
R --> A
F -- no --> X["Rejected: delivered with the report"]