Skip to content

Task Runs

Experimental

Task runs are new. The task file and the routes on this page can still change.

A task run is an evaluation that you define as containers and the permissions between them. It has no Inspect task and no Inspect runner. Each container runs in its own pod, and Hawk runs a gateway for the run. A container can reach only the gateway, unless a permission allows more. It asks the gateway to run a command in another container, to call a model or to record a score, and the gateway checks each request against the container's permissions. The gateway writes every command, file copy, model call and event to the run's Inspect log, so a task needs no logging code.

Use a task run to evaluate a program that is not an Inspect solver, for example a coding agent's command-line tool, and to keep the scoring in a container that the agent cannot reach. Use an eval set for an Inspect task, or when you need many samples, epochs or resume. A task run has one sample and cannot be resumed.

Run the example

hawk/examples/simple.task.yaml has two containers. task has a question and its answer: it writes a small program into agent, runs it there, compares its output with the answer, records a score and ends the run. agent can call a model and never receives the answer.

hawk task-run start hawk/examples/simple.task.yaml model=claude-haiku-5-5

The deployment must have restricted credentials and task runs enabled. The model is one from hawk models that you may call and that Hawk calls through Anthropic's Messages API. The command prints the run's ID and a link to its log. Hawk stores a task run as an eval set, so hawk status, hawk logs -f, hawk web, hawk download, hawk stop and hawk delete accept the ID, and hawk watch shows a row for each container. Hawk deletes a container's pod when the container or the run ends, and the pod's output can be lost with it, so post anything you want to keep as an event.

The task file

Key Meaning
name Required. The run's name. Hawk builds the run's ID from it and uses it as the name of the log's task and of its one sample.
params The file's parameters, each with its default. Give a parameter that has no default on the command line as NAME=VALUE. Hawk replaces ${name} in every string value of the file, a program in command included. Write $$ for a literal $. A value is text: quote it where a key takes a number (time_limit_seconds: "${seconds}").
limits.time_limit_seconds Required. Wall-clock seconds from the moment every container is ready. See What ends a run.
model The model name in the log's header. Required only when the containers list more than one model.
containers Required. The containers, by name. A name is a DNS label that starts with a letter, and is the container's host name inside the run.
tags, metadata A list of tags and a dictionary, as in an eval set. They are the log's eval.tags and eval.metadata, where Hawk's own keys (eval_set_id, created_by) replace the same keys given here. Use them to mark the runs of one batch. Metadata is stored as plain text: put no secrets in it.

Each container has these keys:

Key Meaning
image Required. The image to run, with a digest or a tag other than latest.
entrypoint, command Lists that replace the image's entrypoint and its arguments, as in Docker Compose.
working_dir, user The directory in which the command starts, and UID or UID:GID as numbers.
environment Environment variables. Every container also gets HAWK_GATEWAY_URL, the gateway's address.
cpu, memory Kubernetes quantities, as strings: cpu: "2", not cpu: 2. The defaults are 500m and 2Gi.
secrets Secrets, declared like an eval set's runner.secrets and passed with --secret NAME or --secrets-file. Only the containers that declare a secret's name receive its value, as an environment variable. Hawk writes the value into the pod's specification, where the cluster's audit log and anyone who can read pods can see it.
permissions What the container may do, from the table below.

Every run must list at least one model. A run that calls no model lists mockllm/model, Inspect's mock model. Hawk does not restart a container whose command exits, and no more commands can run in it, which is why agent runs sleep infinity.

Permission Allows the container to
read: [NAMES] Read files in those containers. This includes their environment variables and therefore their secrets.
write: [NAMES] Run commands in those containers, write files in them and end them. Includes read.
connect: [{container: NAME, port: PORT}] Open TCP connections to that port of that container, by its name.
models: [NAMES], with an optional token_limit Call those models through the gateway, up to the limit.
internet Reach the public internet, and use Anthropic's web search and web fetch tools in model calls.
hawk:event Write Inspect events, including scores, to the run's log.
hawk:done End the run. The container that runs the task's program needs it.

The gateway identifies a container by its pod's address, so a request needs no token. connect and internet traffic does not go through the gateway and is not in the log.

A container with write on another container can do whatever that container can. So it must list, in its own permissions and secrets, every permission and secret of the other container; a container with read must list the other's secrets. In the example, task lists models for this reason. A token_limit is not copied. Hawk rejects a file that omits one, and the error lists what to add.

Writing the program in Python

hawk/examples/hawk_tasks.py is a client for the gateway: one file that uses only the standard library. Copy it, from the release of Hawk that your deployment runs, into the image of the container that runs your program, to a directory where Python finds modules (in the official Python 3.13 image, /usr/local/lib/python3.13/site-packages/).

import subprocess
import hawk_tasks as hawk

with hawk.ends_the_run():
    hawk.wait_until_ready("agent")
    try:
        hawk.run("agent", ["agent-cli", "fix the failing test"], cwd="/work", timeout=1500)
    except subprocess.TimeoutExpired:
        pass  # `run` killed the command
    tests = hawk.run("agent", ["pytest", "-q"], cwd="/work")
    hawk.score(1.0 if tests.returncode == 0 else 0.0, scorer="tests")

The example runs its tests inside agent, so it trusts what the agent left there. run takes a container's name and a command, waits for the command to end and returns a subprocess.CompletedProcess with its output as text. As subprocess.run does, it raises CalledProcessError with check=True, and after timeout seconds it kills the command and raises TimeoutExpired. Popen starts a command and returns at once; it has poll, wait, read, stdout_lines and kill. ends_the_run() ends the run when its block ends, and writes the error to the log first if the block raised. end ends containers and waits until the gateway no longer lists them: an agent's command-line tool can leave processes running, so end its container before you read a score that those processes could change. The gateway deletes the pod straight after, and nothing reports when that is done. The module also has read_file, write_file, info and event. The example task does not use the module, so that it runs from a public image with no build.

Gateway routes

A program in another language sends plain HTTP requests to $HAWK_GATEWAY_URL itself.

Route Permission Result
GET /permissions none The caller's name and permissions.
GET /containers none {"containers": {NAME: {"ready": true}}} for the containers the caller has read or write on.
POST /containers/{name}/exec write Starts a command and returns {"id": ID}. The body has cmd (a list; no shell reads it) and optionally input, cwd, env and user (a user name; it needs a container that runs as root).
GET /containers/{name}/exec/{id}?stdout_offset=&stderr_offset= write What the command wrote since those byte offsets, the next offsets, the status and the exit_code. It answers at once, so poll it.
DELETE /containers/{name}/exec/{id} write Kills the command if it is still running, and deletes its output.
GET /containers/{name}/files?path= read The file's bytes, or a 404.
PUT /containers/{name}/files?path= write Writes the body to the file, as the user the container runs as.
DELETE /containers/{name} write Ends that container: its commands are killed and its pod is deleted. Within about a second GET /containers no longer lists it.
POST /events hawk:event Writes the body, one Inspect event as JSON, to the log.
POST /done hawk:done Ends the run.
POST /models/anthropic/v1/messages models Forwards the request to the model and streams the response back. .../count_tokens is forwarded too, and is neither counted nor logged.

A request without the required permission gets a 403, and the rejection is in the log. A 503 means the request can be sent again, except a POST .../exec whose connection dropped: the command may be running, and a second request starts a second one. Once the run has ended, every write gets a 503, so stop after some tries. A command's status is running until the caller has read both output streams to the end; then it is exited, or unknown if the gateway lost its connection to the container.

Model calls

The model route is Anthropic's Messages API. A program that uses an Anthropic client sets ANTHROPIC_BASE_URL to $HAWK_GATEWAY_URL/models/anthropic and sends any API key: the gateway replaces the key with a token that is valid only for the container's models, so the containers hold no credential. Hawk sets neither variable; the program that starts the agent passes them.

A model that the container does not list gets a 404, and a container at its token_limit gets a 403. The errors are in the Anthropic API's format and say nothing about Hawk, because the model under evaluation can read them; the reason is in the log. A coding agent's command-line tool often calls more models than the one you chose (a small one for background work, subagents), so list them all or point the tool's settings for them at the one model. token_limit counts input, output, cache-read and cache-write tokens, and cache reads are most of a coding agent's count.

What ends a run

Event When the run ends Log status
A container calls POST /done immediately success
The time limit passes, or you run hawk stop 15 minutes later, unless a container calls POST /done first success
You run hawk stop --error within seconds error
Before the run starts, a container in the file cannot start, exits or is ended immediately error
You run hawk delete immediately cancelled

The gateway does not tell a container when the limit passes or when you run hawk stop, and a container cannot read the limit. A task that must stop its agent on time measures the time itself, from the moment the other containers are ready, then scores and ends the run.

After the run starts, a container that exits or is ended is recorded and the run continues. So if the program that scores crashes, the agent can go on calling models, up to its token_limit, until the time limit plus 15 minutes. A program should catch its own failure, post an info event that says what failed, and still end the run; hawk_tasks.ends_the_run() does this.

Events in the log

In the run In the log
A container was started or asked to end, its pod changed phase, the gateway rejected a request, or a container reached a token_limit An info event with the source hawk. Its data has a type that names the record.
A container posted an event That event, as a new event with the gateway's timestamp. Its metadata has the container's name.
A command, or a file read or write One sandbox event: the command and its exit code, or the path and size, with up to 4 KiB of the content. A command whose end is not in the log when the run ends is completed then, with the status unknown.
A model call One model event and one tool event for each tool call in the response, in a span named for the container. A call still open when the run ends is completed then, with an error that says so.
The time limit passed, or hawk stop A sample_limit event

The sample's scores are the last score event posted for each scorer name, except events marked intermediate; a score event without a scorer is not one of them. The sample's token usage is the sum over the model calls that the gateway forwarded.

The gateway sees an agent's model calls, not what the agent's harness does around them. A harness can add that to the log, for example from a coding agent's hooks: give its container hawk:event and post info events with a source of your own, not tool events, which the gateway already writes. hawk:event allows any event, a score included. If the model controls that container, end it before the task posts its final score, so that it cannot replace that score. A score it already posted under a scorer name of its own stays in the sample: where every score must be trusted, give no container that the model controls hawk:event.

Limits

  • Only Anthropic's Messages API goes through the gateway, and hawk_tasks.py is the only client.
  • The gateway counts tokens after a response, so the request that crosses a token_limit completes, and concurrent requests can exceed it. It keeps the counts in memory, so a gateway that restarts counts from zero.
  • The wait before every container is ready has no limit: a run whose pod cannot be scheduled continues until you run hawk stop --error or hawk delete.
  • A command has no time limit of its own, and the gateway keeps its output on disk until the command is deleted or its container ends.
  • Task pods are not hardened yet: an eval set's isolation levels do not apply. A run cannot start a container or change permissions after it starts, Hawk does not create a lost pod again, and internet cannot be limited to specific domains.