Run cases in containers with Harbor
Run each test case in its own container with Harbor, with its test environment applied inside, and Judgment's judges as Harbor's reward.
Harbor runs each task in a fresh container and
scores it with a verifier. judgeval test run --harbor turns each case of
your test suites into a Harbor task:
- Container: each case runs in its own container, built from your agent's
Dockerfile. - Test environment: the case's seed data and canned tool results apply
inside that container, as they do with
judgeval test run. - Score: Judgment's judges score the case's trace, and the result becomes
Harbor's reward:
1for a pass,0for a fail. A case that is never scored gets no reward, and Harbor marks its trial as an error.
At the end of this guide, judgeval test run --harbor plays your suites one
container per case and prints the same report as judgeval test run.
Run your test suites with Harbor using your coding agent
Paste it into your agent from your repo's root.
Test environments are covered on three pages. If you are a coding agent, read all three before you add or change an environment:
- Run cases in a test environment: the definition format, the files in
.judgment/environments/and howrun.pyapplies them. - Design a test environment: guidelines so a case fails only when the agent's behavior changes.
- Run cases with Harbor (this page): each case in its own container, with its environment applied inside.
Prerequisites:
- A repo set up for tests:
judgeval test runalready passes from its.judgment/folder. - judgeval 1.12.0 or later.
- Docker on the machine that runs the command.
- Harbor, or uv. Without a
harborcommand, judgeval fetches Harbor withuvx. - A personal API key
from a member with the Developer role or higher, in
JUDGMENT_API_KEY, and your organization's ID inJUDGMENT_ORG_ID.
Add a Dockerfile
Put a Dockerfile in the agent's root folder, next to .judgment/. It must:
- set
WORKDIRto the folder it copies the agent into; - install your agent's dependencies, with judgeval as a main dependency, not a dev one;
- copy the whole agent folder,
.judgment/included; - put the
judgevalcommand onPATH.
FROM python:3.13-slim
COPY --from=ghcr.io/astral-sh/uv:latest /uv /usr/local/bin/uv
WORKDIR /app
COPY pyproject.toml uv.lock ./
RUN uv sync --frozen --no-dev --no-install-project
COPY . .
ENV PATH="/app/.venv/bin:$PATH"Keep credentials and local files out of the image:
.env
.venv
.judgment/harborRun the suites
A test run spends Judgment Units on its judge evaluations, as it does without
--harbor.
judgeval test run --harborThe command builds the image, starts a run of each suite in
.judgment/judgment.json, and gives every case its own Harbor trial. Harbor
shows its own progress while the containers run. When a suite's cases are
scored, the command prints the suite's result:
Baseline: 10 passed, 1 failed, 11 total
FAILED Mediterranean for 50 when the menu is down
Confirmation ask: expected eq Asked to confirm, got Did not ask
Run: https://app.judgmentlabs.ai/org/.../offline-tests/.../runs/...| Exit code | Meaning |
|---|---|
0 | Every case passed. |
1 | At least one case failed. |
2 | The suites could not be run, or a case was never scored. The reason is printed. |
--suite and --candidate work as they do without --harbor.
--concurrency (default 4) sets how many containers run at once. --retry-failures
does not work with --harbor.
Inspect a trial
Harbor writes its job logs to .judgment/harbor/jobs, which judgeval keeps
out of git. Each trial's folder holds its logs and its reward. To browse them:
uvx --from harbor harbor view .judgment/harbor/jobsCredentials in the container
Each container gets JUDGMENT_API_KEY, JUDGMENT_ORG_ID, JUDGMENT_API_URL
and every variable named in the agent's .env file, such as your model
provider's key. The values come from the environment you run the command in,
or else from the agent's .env. A variable set in neither isn't passed on, so
an unset JUDGMENT_API_URL leaves the container on judgeval's default.
Harbor's task files name the variables but never hold their values.
Test environments in the container
A test environment
applies inside the container, so .judgment/run.py and tools marked
@mockable need no changes. run(case, environment) receives the case's
environment, and a @mockable tool answers from its canned results.
A @mockable tool must run in the agent's own Python process. A tool served
by another process, such as an MCP server, runs for real.
How each case runs
judgeval test run --harbor writes one Harbor task per case under
.judgment/harbor/tasks and runs them with Harbor's built-in oracle agent.
These are the main files in each task:
| Task file | What it does |
|---|---|
instruction.md | The case's input. |
task.toml | Names the agent's image and the variables the container gets, and gives the verifier time to wait for the score. |
solution/solve.sh | Runs judgeval test play on the case: your agent runs through .judgment/run.py in the case's test environment, and its trace is tagged with the case. |
tests/test.sh | Runs judgeval test result, which waits for Judgment to score the case, and writes Harbor's reward. |
Use your own Harbor tasks
If you already run your agent with Harbor, keep your tasks and play Judgment's cases inside them:
judgeval test start --out cases/starts a run of each suite and writes one<case ID>.jsonper case, with its test environment. Use a new or empty folder.- Put the case's file where both the agent step and the verifier can read
it, such as the task's
solution/andtests/folders. Where your task starts the agent, runjudgeval test play <file>from the agent's root folder, the image'sWORKDIR. It runs the agent on that case through.judgment/run.py. - In the verifier, from the same folder, run
judgeval test result <file>. It waits for the score and exits0for a pass,1for a fail, and2if the case was not scored in time or couldn't be checked.
Both commands read .judgment/ from the folder they run in, and read the
file from JUDGMENT_TEST_CASE when you don't pass one. Name
JUDGMENT_API_KEY, JUDGMENT_ORG_ID and your provider keys under
[environment.env] in task.toml, as NAME = "${NAME:-}".
A verifier in its own container, with environment_mode = "separate" as
harbor task init sets it, doesn't get [environment.env]. Name
JUDGMENT_API_KEY and JUDGMENT_ORG_ID under [verifier.env] as well, and
give its image judgeval and the agent's .judgment/ folder.
judgeval test result waits up to 900 seconds, and Harbor stops a verifier
after 600 by default. Raise the verifier's limit in task.toml:
[verifier]
timeout_sec = 960This verifier turns the exit code into Harbor's reward:
#!/bin/bash
judgeval test result /tests/case.json
code=$?
[ $code -le 1 ] && echo $((1 - code)) > /logs/verifier/reward.txt
exit 0If something goes wrong
| Symptom | Fix |
|---|---|
--harbor needs a Dockerfile in <folder> | Add a Dockerfile to the agent's root folder, next to .judgment/. |
--harbor needs Harbor | Install Harbor with uv tool install harbor, or install uv. |
--harbor needs Docker | Install Docker and start it. |
N of M cases were not scored | A container failed before the agent produced a trace. Open the trial's logs in .judgment/harbor/jobs: a missing dependency in the image, a WORKDIR that isn't the agent's root, or a provider key that isn't set where you ran the command or in .env are the usual causes. |
No .judgment/judgment.json in <folder> inside a trial's logs | The image doesn't hold .judgment/ in its WORKDIR. Check that WORKDIR is the folder COPY . . copies into, and that .dockerignore doesn't exclude .judgment/. |
judgeval: command not found inside a trial's logs | The judgeval command isn't on the image's PATH. With uv, add ENV PATH="/app/.venv/bin:$PATH". |
Next steps
- Design a test environment so cases fail only when the agent's behavior changes.
- Run your agent on a test suite for what a run returns.