Source: https://hatchery.build/docs/jobs

# Jobs and evidence

A **job** runs trials against a task or dataset. Each **trial** is one attempt by an agent. The verifier grades the outcome and assigns a reward. **Coverage** is the share of planned trials that produced valid measurements.

Click a robot to toggle pass or fail. The average reward updates as the trial rewards change.

```concept-demo
trials
```

Before continuing, [connect the CLI](quickstart.md#connect-the-cli). The Quickstart saves the selected project in `hello/hatchery.json`. The commands below run from the directory that contains `hello`, so set `HATCHERY_PROJECT` to the `project` value already recorded in that file. Uploaded results and hosted jobs will go to that project.

## Run locally

`hatchery run` runs on your computer by default. Closing your computer interrupts work in progress. This example runs the `hello` task from its local directory, reads `OPENAI_API_KEY` from your shell, creates three independent trials, and saves the job under `results`.

```sh
export OPENAI_API_KEY="..."
hatchery run --path hello --agent codex \
  --model openai/gpt-5.6-sol --n-attempts 3 --output results
```

`--path` names the directory containing the task package. Local runs use the Python bridge configured in the Quickstart and start task containers with Docker. Agent credentials come from your local environment. If the task configuration refers to a host environment variable, add `--yes` to allow the runtime to pass that value into the task.

With `HATCHERY_PROJECT` set, the run uploads each completed trial to your project and keeps the original result on disk. A successful run prints the local job location. If an upload fails, the command exits with a nonzero status and leaves the result available so you can resume the upload.

To use an existing job configuration, pass its path from your current directory. The file supplies its own task or dataset paths.

```sh
hatchery run --config ./job.json --output results
```

The source can also be an exact revision stored in Hatchery. This command downloads the verified task revision and still runs it on your computer:

```sh
hatchery run --task TASK_ID --revision 1 \
  --agent codex --model openai/gpt-5.6-sol \
  --n-attempts 3 --output results
```

Use `--path` for a local directory and `--task` or `--dataset` with `--revision` for stored source. To submit a single task to Hatchery, add `--remote` to the path or task form.

For a local job on a stored dataset revision, use `--include-task-name` (`-i`) and `--exclude-task-name` (`-x`) to select tasks by package name. Repeat either option for more patterns. `--task-names-file` reads additional include patterns, one per line. Patterns match the full package name, such as `legalenv/le-26`. If no include pattern matches, the job fails before trials start. The job plan and coverage count only the selected tasks.

```sh
hatchery run --dataset DATASET_ID --revision 1 \
  --include-task-name 'legalenv/le-2*' \
  --exclude-task-name 'legalenv/le-27' \
  --task-names-file selected-tasks.txt \
  --agent codex
```

Local or remote describes where the evaluation job runs. The agent can use a remote service in either case.

## Run on Hatchery

These native hosted submission examples target `htchry@0.2.0`. Hatchery runs the job through its native Harbor driver on Daytona. Run dataset jobs locally.

Store the model credential as a write-only project secret. Name it when starting the hosted job so Hatchery passes it only to that run.

```sh
hatchery push hello
printf %s "$OPENAI_API_KEY" | \
  hatchery secrets set OPENAI_API_KEY

hatchery hosted start --task TASK_ID --revision REVISION \
  --agent codex --model openai/gpt-5.6-sol \
  --n-attempts 3 --secret OPENAI_API_KEY
```

Use the task ID and numeric revision from `hatchery push`. Add `--wait` to `hatchery hosted start` to wait for completion. Alternatively, `hatchery run --path hello --remote` pushes, submits the resulting revision, and waits. The job continues if you disconnect or stop waiting. Use `hatchery hosted status JOB_ID` to read its state and `hatchery hosted cancel JOB_ID` to stop it.

Hatchery retains results and historical hosted jobs in the project and never displays saved secret values.

### Hosted migration for 0.2.0

Use the native commands above in place of `hatchery runner` and its `HATCHERY_RUN_ENV` setup. Hatchery selects the sandbox; `--env` applies to local runs. In place of `hatchery check --hosted`, run `hatchery check DATASET_DIRECTORY` locally or in CI to upload results to the [checks board](checks.md).

With `htchry@0.2.0`, `hosted start`, `run --remote`, and `run --server` print a generated submission key to stderr before sending the request, leaving `--json` stdout unchanged. An explicit `--idempotency-key KEY` suppresses that line. Harbor `run --server --dry-run` sends and prints no key.

In scripts, save an explicit key before submitting and use a new key for each intended job. If the response is lost, repeat the exact request on the same endpoint and project with `--idempotency-key KEY`, using the saved or printed key. Keep the numeric task revision and inputs fixed, or reuse the unchanged Harbor JobConfig with its pinned revision. Submitting again without the original key requests a new job. Native replay returns the original job; Harbor reports a duplicate with the original job ID, which `--wait` follows.

If you use `htchry@0.1.0`, native hosted submissions cannot send a key. Use `hatchery run --server URL --config job.json --idempotency-key KEY` with a supported Harbor JobConfig. Set `URL` to `https://hatchery.build/api/projects/PROJECT_ID/harbor-api` and supply the project credential through `HARBOR_API_KEY`.

## Read the result

Job, task, and trial IDs are opaque. Copy them from command output or Studio. List the project's jobs, then inspect the job and its trials:

```sh
hatchery jobs
hatchery jobs JOB_ID
hatchery trials JOB_ID
hatchery trials JOB_ID TRIAL_ID
hatchery open JOB_ID --kind jobs
```

The job view shows execution status, agent and model, planned trials, valid coverage, and aggregate rewards. Open a trial to see its validity, rewards, retained result files, and source. `hatchery open` prints the Studio URL for the same evidence. For a hosted run, Studio also shows selected secret names, attempt progress, logs, and cancellation control.

An average reward of `0.8` with `2/3` coverage summarizes two valid trials. The third planned trial is missing or invalid and contributes no reward.

## Configure a hosted environment

Each hosted trial runs in the managed Daytona environment. Hatchery supplies the sandbox infrastructure and credentials. Your task defines the files, tools, and network access the agent needs.

Use a supported `environment/Dockerfile` and pin its base image by tag or digest. See [Hosted sandboxes](hosted-sandbox.md) for the task and operator requirements.

Unsupported execution plans, receive the published HTTP `501 NotImplemented` problem before execution. To use `tardigrade-cloud` with Harbor locally, follow the [local agent guide](../getting-started.md#run-a-tardigrade-agent) and configure an explicit HTTPS workspace URL if needed.
