rewardkit
Original:🇺🇸 English
Translated
Write Harbor task verifiers using Reward Kit. Use when creating or editing a task's tests/ directory, adding grading criteria, setting up LLM/agent judges, or designing verifiers that produce a reward score.
220installs
Sourceharbor-framework/harbor
Added on
NPX Install
npx skill4agent add harbor-framework/harbor rewardkitTags
Translated version includes tags in frontmatterSKILL.md Content
View Translation Comparison →Help the user write task verifiers with Reward Kit. Reward Kit is a lightweight Python
package that turns a directory of criteria files into a reward score. Each criterion is a
Python function call or a TOML judge file; folders become separate rewards.
Setup in a Harbor task
Put criteria alongside in the task's directory:
test.shtests/tests/
├── test.sh
├── checks.py # programmatic criteria
└── judge.toml # optional LLM/agent judgetests/test.shbash
#!/bin/bash
uvx --from 'harbor-rewardkit==0.1.*' rewardkit /testsThis runs all criteria in against the workspace at and writes
. Defaults match Harbor's conventions — no extra config needed.
/tests//app/logs/verifier/reward.jsonIf judge criteria need API keys, pass them through :
task.tomltoml
[verifier.env]
ANTHROPIC_API_KEY = "${ANTHROPIC_API_KEY}"Ask whether Reward Kit should run in the agent's shared environment or in a
separate verifier environment. Prefer a separate verifier environment when judge
prompts, grading dependencies, API keys, or clean-room checks should not be
available to the agent:
toml
[environment]
network_mode = "no-network" # Agent env baseline — offline during agent.run()
[verifier]
environment_mode = "separate"
[verifier.environment]
network_mode = "public" # Verifier env baseline — LLM judge API calls
docker_image = "python:3.12-slim"In shared mode, the verifier runs in the agent container and inherits
. Put only when verify()
needs different network access than the agent phase (a phase override, not a
baseline). If agent and verifier need different baselines without runtime
switching, use and set
.
[environment].network_mode[verifier].network_modeenvironment_mode = "separate"[verifier.environment].network_modeJudge criteria that call external APIs need a baseline or allowlist on
the verifier environment. Programmatic checks that only read local files can use
.
publicno-networkIn separate mode, is the verifier image build context and must provide
at runtime; Harbor does not upload into the running
verifier container.
tests//tests/test.shtests/Programmatic criteria
Call built-ins from any file in :
.pytests/python
import rewardkit as rk
rk.file_exists("output.txt")
rk.file_contains("output.txt", "hello")
rk.command_succeeds("python main.py", weight=2.0)
rk.json_key_equals("result.json", "status", "ok")All criteria accept (default ) and (default , runs in
overlayfs so side effects don't leak).
weight1.0isolatedFalseAvailable built-ins
- Files: ,
file_exists,file_not_exists,file_contains,file_contains_regex,file_matches,files_equaldiff_ratio - Commands: ,
command_succeeds,command_output_contains,command_output_matches(30s default timeout, optionalcommand_output_matches_regex)cwd - Data: ,
json_key_equals,json_path_equals,csv_cell_equals(needsxlsx_cell_equalsextra),[office]sqlite_query_equals - HTTP: ,
http_status_equalshttp_response_contains - Images: ,
image_similarity(needsimage_size_equalsextra)[image] - Trajectory: ,
trajectory_tool_used,trajectory_tool_not_usedtrajectory_turn_count
For extras, install with .
uv tool install harbor-rewardkit[all]Custom criteria
Use the decorator. First parameter is always . Returns
or :
@criterionworkspace: Pathboolfloatpython
from pathlib import Path
from rewardkit import criterion
@criterion
def has_valid_output(workspace: Path) -> bool:
return (workspace / "output.txt").read_text().strip() != ""Zero-parameter criteria auto-register. Criteria with extra args must be called via :
rkpython
@criterion(description="output has at least {n} lines")
def has_n_lines(workspace: Path, n: int) -> bool:
return len((workspace / "output.txt").read_text().splitlines()) >= n
rk.has_n_lines(10, weight=2.0)
rk.has_n_lines(50, weight=1.0)For criteria shared across reward subdirs, define with in a root-level file
and call from subdirs.
shared=TrueJudge criteria (LLM or agent-as-a-judge)
For subjective checks (quality, readability, edge cases), create a TOML file:
toml
[judge]
judge = "anthropic/claude-sonnet-4-6" # LiteLLM model string
files = ["/app/main.py"]
[[criterion]]
description = "Is the code correct?"
type = "binary"
[[criterion]]
description = "How readable is the code?"
type = "likert"
points = 5
weight = 2.0Criterion types:
- — yes/no → 1.0 or 0.0
binary - — 1..points, normalized to [0, 1]
likert - — min..max, normalized to [0, 1]
numeric
Agent judges
Agent judges shell out to a CLI and can explore the filesystem:
toml
[judge]
judge = "claude-code"
model = "anthropic/claude-sonnet-4-6"
isolated = true
[[criterion]]
description = "Does the solution handle edge cases?"
type = "binary"Slower and more expensive than LLM judges, but they can run commands and inspect files.
Useful [judge]
options
[judge]timeoutreasoning_effortlowmediumhighreferenceatif-trajectoryweightprompt_template{criteria}Scoring aggregation (within one judge TOML)
toml
[scoring]
aggregation = "all_pass" # weighted_mean | all_pass | any_pass | threshold
threshold = 0.7 # only for thresholdOnly affects how this file's own criteria combine. To aggregate across
dimensions, see Aggregating dimensions.
Multi-reward tasks
Put criteria in subdirectories — each becomes a separate reward:
tests/
├── test.sh
├── correctness/
│ └── check.py
├── structure/
│ └── files_exist.py
└── quality/
└── quality.tomlProduces:
json
{ "correctness": 0.75, "structure": 1.0, "quality": 0.6 }Aggregating dimensions
To add aggregated scores on top of the per-dimension keys, add a root-level
with one or more tables. Each adds one key to
, aggregating the dimensions with the same modes as :
tests/reward.toml[[reward]]reward.json[scoring]toml
# tests/reward.toml
[[reward]]
name = "reward"
aggregation = "all_pass" # weighted_mean | all_pass | any_pass | threshold
# threshold = 0.7 # only for thresholdjson
{ "correctness": 0.75, "structure": 1.0, "quality": 0.6, "reward": 0.0 }The per-dimension scores stay; aggregated keys are added alongside them (a
may not collide with a dimension). Each dimension is weighted by the sum
of its criteria weights; keeps the full breakdown.
namereward-details.jsonOutput files
- — per-reward scores
/logs/verifier/reward.json - — per-criterion results, judge reasoning, errors
/logs/verifier/reward-details.json
Multi-step tasks
In a multi-step task, each step has its own under
, and the verifier runs once per step. Reward Kit behaves
the same as in a single-step task: for each step it reads , runs the
criteria against , and writes for that step.
Harbor then aggregates per-step results into a trial-level reward via
in — aggregation happens outside
Reward Kit, so don't try to encode cross-step logic in your criteria.
tests/steps/{name}/tests//tests/app/logs/verifier/reward.jsonmulti_step_reward_strategytask.tomlA task-level directory (at the task root) is uploaded to
first, then the step's own is layered on top (same-name files win).
Put shared helpers (common functions with , fixture
files, a fallback ) at the task level, and step-specific criteria
under each step.
tests//teststests/checks.pyshared=Truetest.shMulti-reward subdirectories still work within a step:
can contain , , — each produces a
separate reward key for that step, and
averages each key across steps. Use when the last step is an
end-to-end check whose rewards already represent the full task.
steps/foo/tests/correctness/structure/quality/multi_step_reward_strategy = "mean""final"When to reach for what
- Use built-ins for file existence, string matches, command output, JSON/CSV checks, HTTP probes.
- Use when logic is task-specific but still programmatic.
@criterion - Use LLM judges for subjective quality dimensions (readability, correctness of prose).
- Use agent judges when the rubric requires exploring the filesystem or running code (e.g. "does the test suite actually pass?").
- Use subdirectories when you want separate scores (correctness vs structure vs quality) rather than one blended number.
- Use for any criterion that runs mutating commands, so it doesn't corrupt the workspace for other criteria.
isolated=True
Working example
See in the Harbor repo.
examples/tasks/reward-kit-example/