More Guides

Production interfaces

A deployment plugs its own infrastructure into Reef at seven points: the client, the serving runtime, the training backend, the activation rule, the sandbox, the harness adapter and the storage. This page gives the contract of each point in one form. It says what is built in, how a deployment selects it, and which base class a class of your own extends. Write a recipe covers what belongs to a recipe, and Run Reef in production is the task guide for the same choices.

The plug points of a Reef deployment around its seven services. Any client calls inference with POST /v1/chat/completions and control with POST /reef/report. A coding agent connects to the harness service with reef-client harness connect. Each plug point has a setting and a base class. Inference calls the serving runtime: inference.serving, RuntimeFactory. Control calls the activation rule: activation, ActivationRule. Training calls the training backend: training.backend, TrainingDeployment. Evaluation and training run tasks in a sandbox: evolution.executor, RemoteExecutor. The harness service gives the tree of the harness adapter: evolution.adapter, AdapterDescriptor. Every service reads and writes the stores: storage.record-backend, ScenarioStorage; storage.artifact-backend, ConfigurableRepositoryBackendFactory; storage.data-store, DataStore; storage.segment-backend, SegmentStore; storage.task-file-backend, TaskFileStore. The plug points of a Reef deployment around its seven services. Any client calls inference with POST /v1/chat/completions and control with POST /reef/report. A coding agent connects to the harness service with reef-client harness connect. Each plug point has a setting and a base class. Inference calls the serving runtime: inference.serving, RuntimeFactory. Control calls the activation rule: activation, ActivationRule. Training calls the training backend: training.backend, TrainingDeployment. Evaluation and training run tasks in a sandbox: evolution.executor, RemoteExecutor. The harness service gives the tree of the harness adapter: evolution.adapter, AdapterDescriptor. Every service reads and writes the stores: storage.record-backend, ScenarioStorage; storage.artifact-backend, ConfigurableRepositoryBackendFactory; storage.data-store, DataStore; storage.segment-backend, SegmentStore; storage.task-file-backend, TaskFileStore.

Interface

Service that calls it

Setting that selects it

Built in

Base class to write your own

The client contract

inference and control answer the client

The client's base URL and token; reef.token

Any OpenAI, Responses or Anthropic client; reef-client

None: two HTTP calls

Serving runtime

inference

inference.backend, inference.serving, inference.remote, inference.upstream-url

SGLang, vLLM, the training backend's own serving, an upstream provider

RuntimeFactory

Training backend

training

training.backend

slime, tinker, spindle_full

TrainingDeployment

Activation rule

control

activation

always, never, evaluated

ActivationRule

Sandbox

evaluation, training

environment of an evaluation; recipe.config.evolution.executor

Docker, E2B, Modal; the host, bubblewrap, Seatbelt

RemoteExecutor

Harness adapter

training, evaluation, harness

recipe.config.evolution.adapter

claude, codex, dsh, hermes, native, opencode, pi, python

An adapter.yaml, loaded as an AdapterDescriptor

Storage

Every service

storage

SQLite, PostgreSQL, a Git LFS repository, local directories

ScenarioStorage, ConfigurableRepositoryBackendFactory, DataStore, SegmentStore, TaskFileStore

How to read each section #

Each section has the same six parts, in this order: what it is, who calls it, select it, built in, write your own, limits and open gaps.

How a deployment names a class. A setting that takes a class of your own has one of these forms:

  • A built-in name, such as training.backend: tinker.

  • A reference package.module:ClassName. The module must import in every Reef process: install its package, or put its directory on PYTHONPATH.

  • A mapping with module, the reference, and config. Reef gives config to the class method from_config of the class. The activation section and the storage settings take this form.

  • The name of an installed entry point, for the two settings that have an entry point group: training.backend (reef.training_backends) and the harness adapter (reef.harness_adapters).

Reef imports the class when it starts, and checks that it inherits the base class. A reference that does not import, an abstract class, and a class of another kind each stop reef serve with a message that names the setting.

The column "Tested by". It says what the tests of this repository run:

  • Fake: a stand-in takes the place of the external service or of the GPU.

  • Real: the test calls the real program or service, and a workflow of the repository runs it.

  • Real, opt-in: the test calls the real service only when a person sets a variable or runs a command. No workflow runs it.

The client contract (HTTP) #

What it is. The two HTTP calls that make any agent or application a client of Reef: a model call, and a report on the run that the call belongs to. A client needs no Reef package.

Who calls it, and when. The client calls Reef. The inference service answers each model call, stores it as a record, and returns the record's ID: the receipt. Control answers each report, and checks it with the recipe's report type. In a split deployment the two services have their own addresses.

Select it. The client sets its base URL to Reef's address and its API key to a token of the deployment. The deployment sets the address and the tokens (external-provider.yaml):

YAML
reef:
  host: 0.0.0.0
  port: 8900
  # Use tokens: [...] to accept several credentials during rotation.
  token: ${REEF_TOKEN}

Built in.

Name

What it runs on

Install extra

Credentials (environment variables)

Limits

Tested by

Any OpenAI Chat Completions, OpenAI Responses or Anthropic Messages client

The client's host

None

The token of the deployment, as the client's API key

The client sends the scenario in a header, or uses the path form. It reads one response header.

Fake: tests/api/inference/ calls the routes over HTTP, with a stand-in for the engine

reef-client (Python)

The client's host

pip install reef-client; it has no dependency

The token, as ReefClient(url, token=...)

Reef pins version 0.4.4 or later

Fake: test_reef_client.py calls a stand-in HTTP server

reef-client harness connect

A person's machine, with Claude Code, Codex, OpenCode or pi

pip install reef-client

REEF_URL, REEF_TOKEN

A scenario of a harness recipe, and the four adapters that declare run.layer

Real: tests/smoke/ runs each real agent against a stand-in model, in the workflow harness-smoke

Write your own. A client makes the model call, keeps the receipt, and reports the run. The table is the whole contract; the HTTP API has every route.

Field

Where

Required

Meaning

POST /v1/chat/completions

Model call: the route

Yes

The body is the request body of the provider's API. /v1/responses, /v1/messages and /v1/messages/count_tokens take the Responses and the Anthropic bodies, when the model behind Reef answers that route (Connect an agent).

Authorization: Bearer <token>

Both calls: request header

Yes, when the deployment sets a token

A token of reef.token or reef.tokens. x-api-key holds it for a client that sends no Authorization header.

x-reef-scenario

Both calls: request header

Yes; the model call also has a path form

The scenario. A client that cannot send headers calls POST /reef/scenarios/{scenario}/v1/chat/completions for the model call.

model

Model call: body

As the provider's API requires

The ID of a served version selects that version. Any other value selects the active version.

x-reef-session-key, x-reef-tag-<name>

Model call: request headers

No

The session key keeps a conversation on one version of a traffic split. Reef stores each tag in the record.

x-reef-agent-record-id

Model call: response header

Reef sends it

The receipt: the ID of the stored call. A stream sends it as reef.agent_record_id in an event at its end.

x-reef-artifact-id

Model call: response header

Reef sends it

The version that answered.

POST /reef/report

Report: the route

Yes, for a run to train

Reef answers 200 with {agent_record_id, scenario, request_type}, or 400 with the name of the field that it refuses.

references

Report: body

Yes, for a run to train

A list with the receipt of the last model call of each run that the report scores.

score

Report: body

When the recipe's report type requires it

A finite number.

metadata

Report: body

When the recipe's report type has fields

An object with the other fields of the report type.

agent_record_id

Report: body

No

An ID of the report that the client chooses. The same report with the same ID is stored once.

The scenario must exist before the first model call: POST /reef/scenarios with {"name": "demo"} creates it. One run, from the call to the report:

Shell
curl -sS -i "$REEF_URL/v1/chat/completions" \
  -H "Authorization: Bearer $REEF_TOKEN" -H "x-reef-scenario: demo" -H 'Content-Type: application/json' \
  -d '{"model": "active", "messages": [{"role": "user", "content": "What is 2 + 2?"}]}'
# The response has the headers x-reef-agent-record-id: <receipt> and x-reef-artifact-id: <version>.

curl -sS "$REEF_URL/reef/report" \
  -H "Authorization: Bearer $REEF_TOKEN" -H "x-reef-scenario: demo" -H 'Content-Type: application/json' \
  -d '{"references": ["<receipt>"], "score": 1.0}'

reef-client adds no protocol. ReefClient.inference_with_record sends the headers and returns the body with the receipt, and ReefClient.report sends the report with its references (Use Reef). reef-client harness connect installs the harness that a harness recipe serves, and routes the agent's model calls through this contract (Update a coding agent's rules).

Limits and open gaps.

  • Every token opens every route. For permissions of one user or one scenario, put a gateway in front of Reef.

  • Reef has no TLS setting: it serves HTTP. Put a proxy that ends TLS in front of it.

  • A stream that fails after its first event gives no receipt, so its run cannot be reported.

Serving runtime #

What it is. The part that answers model calls with the weights of one version, and loads a new version when control activates it.

Who calls it, and when. The inference service. Each Reef process builds the runtime at startup, and only the inference service opens it. One inference process, the engine owner, calls activate_checkpoint before traffic goes to a version, and every inference process answers requests through the runtime's handler.

Select it. The inference section selects the runtime (local-sglang.yaml):

YAML
inference:
  model-path: Qwen/Qwen2.5-7B-Instruct
  backend: sglang
  tensor-parallel-size: 1

Setting

Values

Default

inference.serving

engines, trainer, none, or the reference of a RuntimeFactory

engines when an engine setting is set, else the default of the training backend

inference.backend

sglang, vllm, none

sglang

inference.remote

url and the names of two token variables: the engines run on another host

Unset: the engines run on this host

inference.upstream-url, inference.upstream-model, inference.upstream-api, inference.upstream-api-key

An HTTP provider, for a recipe that trains no weights. upstream-api is openai, responses or anthropic.

Unset

inference.serving-config

The settings of a RuntimeFactory of your own

Empty

Built in.

Name

What it runs on

Install extra

Credentials (environment variables)

Limits

Tested by

SGLang: inference.backend: sglang

The GPUs of this host

reef-infra[sglang], and SGLang from the Reef GPU image

None

Serves full weights and PEFT adapters

Fake: tests/inference/sglang/ runs CPU stand-ins for the engines. Real, opt-in: python -m tests.smoke.native_inference on a GPU host.

vLLM: inference.backend: vllm

The GPUs of this host

reef-infra[vllm], and vLLM in the GPU environment

None

Serves full weights only. One engine: inference.num-gpus equals inference.tensor-parallel-size.

Fake: tests/inference/vllm/ answers vLLM's HTTP routes with a stand-in. Real, opt-in: python -m tests.smoke.native_inference on a GPU host.

A remote GPU host: inference.remote.url

A host that runs python -m reef.inference.remote, with SGLang or vLLM

On that host: Reef and the engine

REEF_REMOTE_CONTROL_TOKEN, REEF_REMOTE_INFERENCE_TOKEN, with two different values

Each URL of inference.remote.slot-urls serves one more version, of full weights only

Fake: test_remote_inference.py runs the component over HTTP, with stand-ins for the engines

The training backend's own serving: inference.serving: trainer

Tinker's sampler, or the Spindle service

reef-infra[tinker]

TINKER_API_KEY

Tinker's sampler: text messages on /v1/chat/completions only, no tool calls, and a stream arrives as one event

Fake: test_tinker_backend.py replaces the Tinker SDK

An upstream provider: inference.upstream-url

An HTTP provider with the OpenAI, Responses or Anthropic API

None

inference.upstream-api-key

Serves no trained weights: a deployment that trains weights refuses the upstream settings

Fake: test_http.py answers as the provider

Nothing serves: inference.backend: none

No engine

None

None

Every model call is refused. The deployment trains on uploaded or imported data.

test_null_inference.py needs no external service

Write your own. Subclass RuntimeFactory (reef/inference/registry.py). Its call builds an InferenceRuntime (reef/inference/interfaces.py), which is the contract of the serving itself.

Member

Required

Called when

Returns

RuntimeFactory.__call__(config, model_path, recipe_config, environ)

Yes

A Reef process starts. config holds inference.serving-config and artifact_format, the format of the weights that the training backend saves.

An InferenceRuntime

RuntimeFactory.config_type()

No

Reef parses inference.serving-config

The dataclass of the settings, or None to get the mapping as it is

InferenceRuntime.inference_handler

Yes

An inference process answers a request

The InferenceHandler that sends the request to the engine

InferenceRuntime.activate_checkpoint(artifact, *, scenario=None)

Yes

Before traffic goes to a version: at a commit that activates it, at an activation, and at a start

The runtime load ID that serves the version. A raise reports a failed activation.

InferenceRuntime.served_artifact(artifact_id, scenario)

Yes

The inference service publishes the route of a version

ServedArtifact(artifact_id, url, model_name), or None when the runtime does not serve the weights of this version now

InferenceRuntime.endpoint_model_name(scenario)

For versions without weights, such as a harness tree

The inference service routes a version that has no weight component

The model name at base_url. The default, None, refuses such versions.

open, adopt, handler_for, stop_serving, shutdown

No

The engine owner starts, takes over after a restart, and stops

See the docstring of each in interfaces.py

The factory, as the base class declares it:

Python
class RuntimeFactory(ConfiguredFactory):
    """Build the serving runtime that a ``runtime`` config section describes.

    ``__call__`` receives ``(config, model_path, recipe_config, environ)``
    and returns an :class:`InferenceRuntime`. ``RuntimeRegistry`` selects the
    factory by the section's ``type``.
    """

    @abstractmethod
    def __call__(
        self,
        config: Mapping[str, Any],
        model_path: str,
        recipe_config: Mapping[str, Any],
        environ: Mapping[str, str],
    ) -> InferenceRuntime:
        """Build the serving runtime that ``config`` describes."""

A small factory, the test double of the repository (training_deployment.py):

Python
class LocalServingFactory(RuntimeFactory):
    """Build the deployment's own serving runtime (``inference.serving: trainer``)."""

    kind = "tests.support.training_deployment:LocalServingFactory"

    def __call__(self, config, model_path, recipe_config, environ):
        return StubInferenceRuntime(model_path=model_path)

A deployment names the factory by its reference (weights.yaml):

YAML
inference:
  model-path: Qwen/Qwen3-8B
  # The serving runtime: a RuntimeFactory class. The factory gets serving-config as its config.
  serving: tests.support.training_deployment:LocalServingFactory
  serving-config:
    replicas: 2

Write a serving runtime has the rules that a runtime keeps, and the check with real engines.

Limits and open gaps.

  • Reef has no serving runtime for Modal, and none for another hosted GPU service. A deployment serves on its own GPU hosts, on Tinker's sampler, on Spindle, or on an upstream provider.

  • inference.backend takes sglang and vllm only. Another engine needs a RuntimeFactory.

  • No test of CI loads weights into a real engine. The checks with real engines are opt-in.

  • Serving the adapters of Tinker on SGLang (training.backend: tinker with inference.backend: sglang) is tested with a stand-in engine only.

Training backend #

What it is. The part that runs each training job on a framework or a hosted service, and saves the checkpoints that become versions.

Who calls it, and when. reef serve calls the deployment class once, before it starts a process. The training service builds the training component, and for each job it calls check_job, then submit, and then status until the job ends. The other services read only the backend's facts.

Select it. training.backend names the backend, and training.options holds the options of that backend (tutorials/tinker/serve.yaml):

YAML
training:
  backend: tinker
  ready-timeout: 1800
  timeout-s: 1800
  options:
    state-dir: ${REEF_TINKER_STATE_DIR}/tinker
    lora-rank: 32

Built in.

Name

What it runs on

Install extra

Credentials (environment variables)

Limits

Tested by

slime (default)

Your GPUs, on the Ray cluster that Reef starts or on yours at training.ray-address

The Reef GPU image, with reef-infra[slime]

None

One scenario for each deployment, and one job at a time. Trains all parameters or LoRA.

Fake: tests/slime_backend/ replaces the GPU workers. Real runs on GPUs are in the results of the recipes, such as SAO and TTT-Discover.

tinker

The Tinker service. The Reef host needs no GPU.

reef-infra[tinker]

TINKER_API_KEY

LoRA only. A recipe trains on it when its algorithm has a Tinker class: the built-in sft, and TTT-Discover. Takes no recipe.algorithm options.

Fake: tests/tinker_backend/ replaces the Tinker SDK. Real, opt-in: tutorials/tinker/smoke.py trains one step, and costs Tinker credits.

spindle_full

A Spindle service that you deploy on Modal

reef-infra[tinker] and reef-infra[modal]

The Spindle key in TINKER_API_KEY, MODAL_TOKEN_ID, MODAL_TOKEN_SECRET, HF_TOKEN

All parameters. One engine and one scenario for each base model. Each job pays for the GPU startup and the export.

Fake: test_spindle_full.py replaces the SDK, Modal and the Hugging Face Hub

Train with Tinker has the options of the two hosted backends.

Write your own. A backend is three classes: the deployment class that training.backend names (reef/train/deployment.py), a factory, and the training component that the factory builds (reef/train/component.py).

Member

Required

Called when

Returns

TrainingDeployment.prepare(config, settings)

Yes

reef serve reads the deployment file, before it starts a process

The processes that the Reef server depends on; an empty tuple for a backend that runs in the Reef process

TrainingDeployment.component_config(settings, *, default_parameters, objectives)

Yes

A Reef process builds the component or reads its facts

The config of the component. Its type is the reference of the factory. objectives holds the algorithms of the recipe, for a component that resolves their names.

default_serving, trainer_serving_config(settings), engine_weights(settings)

No

Reef selects the serving of a deployment that names none

engines or trainer; the config of the backend's own serving runtime; how engines get weights

TrainingComponentFactory.__call__(config, model_path, environ)

Yes

The training service starts

The TrainingComponent

TrainingComponentFactory.facts(config, model_path, environ)

Yes

Any service needs the backend's name, artifact format or start rules

A TrainingBackendFacts. It builds no component and makes no network call.

TrainingComponent.name, artifact_format

Yes

Reef reads what the backend is and what its checkpoints hold

The backend's name; the format of the weights, or None for checkpoints without weight files

TrainingComponent.submit(job), status(job_id), cancel(job_id)

Yes

The training service runs a job, polls it, and stops it

status returns a JobStatus with the state and the saved checkpoints

TrainingComponent.import_start(artifact_dir)

Yes

A trainer starts training from a version (train-from)

The start that later jobs train from

TrainingComponent.check_job(job)

No

Before a job enters the queue

Nothing; a raise refuses the job, and the job uses no sample

InProcessTrainingDeployment writes prepare and component_config for a backend that runs in the Reef process: the subclass names only its factory. The test double of the repository is such a backend (training_deployment.py). Its factory:

Python
class LocalFactory(TrainingComponentFactory):
    kind = "test-local"

    def config_type(self):
        return Options

    def facts(self, config, model_path, environ):
        return LocalFacts()

    def __call__(self, config, model_path, environ):
        return LocalRuntime(config, model_path)


component_factory = LocalFactory()

Its deployment class:

Python
class LocalDeployment(InProcessTrainingDeployment):
    """A training backend that serves its own snapshots by default, as Tinker does."""

    component_type = "tests.support.training_deployment:component_factory"
    default_serving = "trainer"

    def trainer_serving_config(self, settings):
        return {"type": LocalServingFactory.kind}

A deployment names the deployment class by its reference, or by the name of an entry point of the group reef.training_backends (weights.yaml):

YAML
training:
  # The training backend: a TrainingDeployment class.
  backend: tests.support.training_deployment:LocalDeployment
  options:
    lora-rank: 8

training.options are the fields of the dataclass that the factory's config_type returns, with a hyphen for each underscore. Write a training backend has the rules that a backend keeps.

Limits and open gaps.

  • Reef has no training backend that runs on Modal, on AWS or on Google Cloud by itself. spindle_full trains on a Spindle service that you deploy on Modal yourself.

  • No test of CI trains on a GPU or calls the Tinker service. The TTT-Discover recipe states that its Tinker backend has no measured results.

  • An algorithm with its own loss needs one class for each backend (Write a recipe). The built-in sft algorithm has a class for Slime and a class for Tinker only.

Activation rule #

What it is. The rule that decides whether a version that training made serves: at once, after its evaluation, or only when a person activates it.

Who calls it, and when. Control, at two moments:

  1. When a training step publishes a version, control calls activates(made). The commit stores the answer as activated, and inference loads an activated version.

  2. When an evaluation of a version finishes, control calls activates_evaluated(artifact_id, evaluation), and activates the version when the answer is true.

Reef builds the rule from the activation section when the deployment loads, so a wrong section stops the startup.

Select it. A weight recipe names an Evaluation class in its attribute evaluation (Write a recipe); the default is always. An activation rule is an Evaluation. The activation section of the deployment file names another rule in its place, for every scenario (deployment.yaml):

YAML
activation:
  module: always
  config:
    review_kinds: [extension]

One scenario replaces the rule for itself with a built-in rule. A client cannot name a class, because a client must not choose the code that the service imports:

Shell
curl -sS "$REEF_URL/reef/scenarios/demo/update" \
  -H "Authorization: Bearer $REEF_TOKEN" -H 'Content-Type: application/json' \
  -d '{"activation": {"module": "never"}}'

{"activation": null} restores the rule of the deployment. The section needs a recipe.implementation that is a class reference.

Built in.

Name

What it runs on

Install extra

Credentials (environment variables)

Limits

Tested by

always (default)

Control

None

None

A harness tree that changes a kind of config.review_kinds waits for a person. A harness recipe adds the kinds that its adapter marks for review.

test_activation_rules.py needs no external service

never

Control

None

None

A person sets what serves, with served of POST /reef/scenarios/{scenario}/update

test_activation_rules.py needs no external service

evaluated

Control, after the evaluation service scored the version

None

Those of the sandbox of the evaluation

Needs config.min_mean_score, and the scenario setting artifact_evaluation. Without that setting no new version serves, and Reef logs a warning.

Fake: test_artifact_evaluations.py runs the evaluations with a stand-in for the sandbox

Write your own. Subclass ActivationRule (reef/core/activation.py; the built-in rules are in reef/evaluation/activation.py).

Member

Required

Called when

Returns

activates(made)

Yes

A training step publishes a version. made.component is the component whose trainer made it: weights for a weight recipe, harness for a harness recipe. made.changed_kinds holds the kinds of harness files that the version changes, and is empty for weights.

True: the version serves at once

activates_evaluated(artifact_id, evaluation)

No. The default returns False.

An evaluation of the version finishes. evaluation.mean_score is the mean of the rollout scores, or None when every rollout failed.

True: the version serves now

from_config(config)

No. The default takes no config.

Reef builds the rule, with the config of the activation section

The rule

Both methods decide from their arguments alone. The two methods, as the base class declares them:

Python
@abstractmethod
def activates(self, made: MadeArtifact) -> bool:
    """Whether Reef activates ``made`` as soon as a training step publishes it."""

def activates_evaluated(self, artifact_id: str, evaluation: PolicyEvaluation) -> bool:
    """Whether Reef activates ``artifact_id`` once ``evaluation`` of it finished."""
    return False

A rule with one setting, the test double of the repository (activation_rule_plugin.py). It serves the new versions of one component, which matters for a composite recipe with a weight component and a harness component:

Python
class ComponentRule(ActivationRule):
    """Activates the artifacts of the configured component only."""

    def __init__(self, component: str) -> None:
        self.component = component

    @classmethod
    def from_config(cls, config):
        return cls(str(config["component"]))

    def activates(self, made: MadeArtifact) -> bool:
        return made.component == self.component

No registration exists apart from the deployment file. The activation section names the class, and gives its config (weights.yaml):

YAML
activation:
  # The activation rule: an ActivationRule class. Its from_config gets config.
  module: tests.support.activation_rule_plugin:ComponentRule
  config:
    component: weights

Limits and open gaps.

  • A scenario selects only a built-in rule. A rule class of your own applies to the whole deployment.

  • A rule gets the version's component, the changed kinds and one evaluation. Reef gives it no record, no training metric and no earlier version.

  • An evaluation whose harness is an item of the data store activates nothing.

Sandbox #

What it is. The place where a task runs, away from the Reef process: the container of an evaluation task, and the program of a harness run.

Who calls it, and when. Two services start sandboxes:

  • The evaluation service runs each rollout of an evaluation in one Harbor environment: Docker, E2B or Modal.

  • The training service runs the evaluation runs of a harness recipe (evolution.executor) and the coding agent of a harness method (evolution.agent.sandbox) on a program executor.

Select it. An evaluation names its environment in the request: "environment": "e2b" in the body of POST /reef/scenarios/{scenario}/evaluations; the default is docker. A harness recipe names its executor in the deployment file, with the executor's options in sandbox (harness.yaml):

YAML
recipe:
  implementation: reef.recipe.harness:HarnessEvolutionRecipe
  config:
    evolution:
      # The harness adapter: a built-in name, or a name of the reef.harness_adapters entry point group.
      adapter: pi
      # Where the evaluation runs execute: local, sandbox, e2b, modal, or a RemoteExecutor class.
      executor: tests.support.remote_sandbox_plugin:StandInRemoteExecutor
      # The options of the executor: its from_config gets this section.
      sandbox:
        region: eu

evolution.agent.sandbox selects the sandbox of the coding agent in the same way. It takes bwrap, seatbelt, none, e2b, modal or a class reference; unset, it is the local sandbox of the host, where the host has one. One evaluation process holds evaluation.max-sandboxes sandboxes at once (4 by default), in any environment.

Built in.

Name

What it runs on

Install extra

Credentials (environment variables)

Limits

Tested by

docker: evaluation environment

The Docker daemon of the host of the evaluation service

None

None

Builds the image of each task on that host

Fake: test_rollout_worker.py runs each rollout with a stand-in for the task run. The tests start no container.

e2b: evaluation environment and executor

E2B sandboxes

reef-infra[e2b]

E2B_API_KEY

A task with several Compose services needs an AgentENV deployment. As an executor: E2B grants a sandbox one hour at a time, and Reef renews it; egress_hosts and limits are refused.

Fake: test_e2b_executor.py and tests/sandbox/. Real, opt-in: test_e2b_run.py with REEF_TEST_E2B=1.

modal: evaluation environment and executor

Modal sandboxes

reef-infra[modal]

MODAL_TOKEN_ID, MODAL_TOKEN_SECRET, or the profile of ~/.modal.toml

A sandbox lives 24 hours at most. As an executor: the sandboxes are in the Modal app reef-sandboxes, and egress_hosts and limits are refused.

Fake: test_modal_executor.py replaces the Modal SDK. Real, opt-in: test_modal_sandbox.py with REEF_TEST_MODAL=1.

sandbox: executor

bubblewrap on Linux, Seatbelt on macOS, on the Reef host

None; bwrap on the host

None

On Seatbelt, addresses of the local network stay reachable, and memory limits do not apply

Real: the tests marked sandbox run bubblewrap in CI (test_native_harness.py). Seatbelt: tests that run on macOS only, which CI does not run.

local: executor (default)

The Reef host, with no isolation

None

None

The program has the privileges of the Reef process

Real: test_program_executor.py runs local processes

Write your own. A cloud sandbox provider is a subclass of RemoteExecutor and one of RemoteSession (reef/execution/sandbox/remote.py). The base classes copy the files, open the tunnel to the Reef host and close the sandbox; the subclasses write the provider's calls.

Member

Required

Called when

Returns

RemoteExecutor.from_config(section, environ)

Yes

Reef starts. section holds the options that provider_options names, with forward_ports and env_from.

The executor

RemoteExecutor.preflight()

Yes

Reef starts, so that a provider that cannot run fails the startup

Nothing; a raise stops the startup

RemoteExecutor.open()

Yes

A run starts

A RemoteSession: one running sandbox

RemoteExecutor.has_image(), with_program(program, binary)

Yes

Reef binds the executor to the program that it runs

Whether the image is known; the executor with an image built for the program

RemoteExecutor.reap()

Yes

Before the first sandbox of a process, to stop the sandboxes that an earlier run of the deployment left

The count of stopped sandboxes

RemoteSession.write_file, read_file, run, start, public_url, stop

Yes

During a run: the base class copies the files, starts the relay and stops the sandbox with them

See the block below

RemoteSession.launch(argv, *, root, workspace, env, timeout, ...)

Yes

Each process of a run

A ProcessOutcome. The provider runs the process in a bubblewrap jail (protected_command).

RemoteSession.tunnel_headers()

No

Reef opens the tunnel

The headers that the provider requires at a public address; none by default

The executor, as the base class declares it:

Python
@classmethod
@abstractmethod
def from_config(cls, section: Mapping[str, object], environ: Mapping[str, str]) -> Self:
    """Parse the deployment's sandbox section without copying the host environment into the sandbox."""

@abstractmethod
def has_image(self) -> bool:
    """Whether the sandbox's image is known: one the deployment names, or one built for a program."""

@abstractmethod
def with_program(self, program: SandboxProgram, binary: str) -> Self:
    """This executor with an image built for ``program`` (which has an ``npm_package``), launching ``binary``."""

@abstractmethod
def open(self) -> RemoteSession:
    """Start a sandbox from the image with a relay on each forwarded port."""

@abstractmethod
def reap(self) -> int:
    """Stop this deployment's running sandboxes and answer how many; without an ``owner`` none is touched."""

The session:

Python
@abstractmethod
def write_file(self, path: str, data: bytes, *, as_root: bool = False) -> None:
    """Write ``data`` to ``path`` in the sandbox."""

@abstractmethod
def read_file(self, path: str) -> bytes:
    """The bytes of ``path`` in the sandbox."""

@abstractmethod
def run(self, command: str, *, as_root: bool = False) -> None:
    """Run the shell ``command`` in the sandbox to its end; raise when it fails."""

@abstractmethod
def start(self, command: str, *, as_root: bool = False) -> None:
    """Start the shell ``command`` in the sandbox and return while it runs."""

@abstractmethod
def public_url(self, port: int) -> str:
    """The ``https`` address at which the provider exposes the sandbox's ``port``."""

@abstractmethod
def stop(self) -> None:
    """Stop the sandbox."""

A deployment names the executor class by its reference, as the block of "Select it" does. remote_sandbox_plugin.py is the smallest subclass, and the E2B executor a complete one. Sandboxes has the rules that a provider keeps.

Limits and open gaps.

  • An evaluation runs in Docker, E2B or Modal. Reef has no base class for another evaluation environment: RemoteExecutor plugs into the harness runs only.

  • The settings egress_hosts and limits of the local sandbox do not apply to a cloud sandbox: E2B and Modal refuse them.

  • The tests of CI use stand-ins for Docker, E2B and Modal. Only the opt-in tests start a real sandbox.

Harness adapter #

What it is. The description of one coding agent for a harness recipe: which files Reef may evolve, how the agent reaches the model, how a run starts it, and where it writes its sessions.

Who calls it, and when. The training and evaluation services render the harness tree for the agent, and run the agent on each task. The harness service gives the rendered tree to the clients that connect.

Select it. recipe.config.evolution.adapter names the adapter; the default is pi (gepa.yaml):

YAML
recipe:
  implementation: recipes.gepa.recipe:GEPARecipe

  config:
    evolution:
      adapter: pi

Built in. Reef installs the pinned version of each agent on the host that runs the runs, unless evolution.binary names a binary. No adapter needs an install extra of Reef. The workflow harness-smoke runs the tests of the six real agents when a pull request changes the harness code.

Name

What it runs on

Install extra

Credentials (environment variables)

Limits

Tested by

claude

Claude Code, from npm

None

None: Reef writes the model endpoint and its key into the agent's config

Anthropic API only

Real: test_real_claude.py runs the agent against a stand-in model

codex

OpenAI Codex CLI, from npm

None

None: Reef writes the model endpoint and its key into the agent's config

Responses API only

Real: test_real_codex.py runs the agent against a stand-in model

opencode

OpenCode, from npm

None

None: Reef writes the model endpoint and its key into the agent's config

OpenAI and Anthropic APIs

Real: test_real_opencode.py runs the agent against a stand-in model

pi (default)

pi, from npm

None

None: Reef writes the model endpoint and its key into the agent's config

OpenAI, Responses and Anthropic APIs

Real: test_real_pi.py runs the agent against a stand-in model

dsh

DeepSeek Harness, from npm

None

None: Reef writes the model endpoint and its key into the agent's config

OpenAI and Anthropic APIs. No reef-client harness connect.

Real: test_real_dsh.py runs the agent against a stand-in model

hermes

Hermes Agent, from Git

None

None: Reef writes the model endpoint and its key into the agent's config

OpenAI API only. No reef-client harness connect.

Real: test_real_hermes.py runs the agent against a stand-in model

native

Reef's own agent loop

None

None: Reef writes the model endpoint and its key into the agent's config

OpenAI API only. No reef-client harness connect.

Real: test_native_harness.py runs the loop against a stand-in model

python

A Python program, which uv runs

None

None: Reef writes the model endpoint and its key into the agent's config

OpenAI API only. No reef-client harness connect.

Fake: test_harbor_task_run.py checks the run with a stand-in for the task's container

Write your own. An adapter is a file adapter.yaml, which Reef loads as an AdapterDescriptor (reef/harness/adapters/descriptor.py). It has no base class to subclass, except for two optional classes.

Member

Required

Called when

Returns

name, binary

Yes

Reef resolves the adapter and starts the agent

The name that a deployment selects, and the program to run

evolve

Yes

Reef validates and renders a harness tree

Each kind of file that Reef may evolve, with the path where the agent reads it

sessions

Yes

After the agent exits

The path and the format of the agent's session log

dirs

No

A run starts

The agent's directories under the run's root, each with the variable that moves it there

model

No

Reef renders the tree for a run

For each model API, the config that points the agent at the model endpoint

run.task

Yes

Each evaluation run

The arguments of one headless run; {task} is the task's text

config

Yes: the target primary

Reef renders the tree

The agent's config files, with their defaults and their checks

install, run.layer, host_env

No

Reef installs the agent; a client connects

The pinned version and its source; how a person's machine runs the agent

renderer: an AdapterRenderer class

No

Reef renders the tree

The render steps that the declaration cannot state

execution_validator: an ExecutionValidator class

No

Before a run

Nothing; a raise refuses the executor for this adapter

The smallest built-in descriptor, of the python adapter (adapter.yaml):

YAML
name: python
binary: uv
# uv from PyPI at the pinned version. Reef uploads the same version into a task's container.
install:
  kind: uv
  package: uv
  version: "0.13.4"
  binary_path: "venv/bin/uv"
# What Reef may evolve: the program's modules. A program is code, so a change always waits for a person.
evolve:
  program: program/{name}.py
dirs:
  program/sessions: REEF_PROGRAM_SESSION_DIR
sessions: {format: python-jsonl, path: program/sessions}
# The served model reaches the program through this file only. base_url ends in /v1, as an OpenAI client takes it.
model:
  openai:
    - target: model
      data:
        api: openai
        base_url: "{base_url}/v1"
        api_key: "{api_key}"
        model: "{model}"
run:
  task:
    argv: ["run", "--script", "{root}/program/main.py", "{task}"]
# The program's own settings (primary), which a tree's config/primary.json sets, and the model binding (model).
config:
  primary:
    path: "program/config.json"
    defaults: {}
  model:
    path: "program/model.json"
    defaults: {}

A deployment names an adapter by its name only. A package registers the name with an entry point of the group reef.harness_adapters. The entry point names a function that returns the descriptor. The Terminal-Bench example of the Meta-Harness recipe registers its adapter terminus this way (reef_terminus):

Python
def descriptor() -> AdapterDescriptor:
    """The terminus adapter: the ``reef.harness_adapters`` entry point that installing the campaign registers."""
    return load_descriptor(Path(__file__).parent / ADAPTER_FILE)
TOML
[project.entry-points."reef.harness_adapters"]
terminus = "reef_terminus:descriptor"

Write a harness adapter has the parts of a tree and the rules that an adapter keeps.

Limits and open gaps.

  • evolution.adapter takes a name, not a class reference: an adapter of your own needs an installed package with the entry point.

  • reef-client harness connect works with the four adapters that declare run.layer: claude, codex, opencode and pi.

  • The tests run each real agent against a stand-in model, not against the model of a provider.

Storage #

What it is. The stores that keep the state of a deployment: the records and the work queues, the versions, the data items, and the files of trajectories and tasks.

Who calls it, and when. Every service. Each Reef process builds the stores at startup, from the storage section. The services never call each other: they share the stores, so the processes of a deployment on several hosts must all reach the same ones.

Select it. Each store has one key of storage (weights.yaml):

YAML
storage:
  # Records and work queues on PostgreSQL.
  record-backend: postgres
  record-database-url: ${REEF_RECORD_DATABASE_URL}
  # The artifact backend: a ConfigurableRepositoryBackendFactory class. Its from_config gets config.
  artifact-backend:
    module: tests.support.artifact_backend_plugin:MemoryArtifactBackend
    config:
      label: demo

Setting

What it stores

Values

Default

storage.record-backend

Records, commits and the settings of each scenario

sqlite, postgres, or a ScenarioStorage class

sqlite

storage.coordination-backend

The work queues, the served versions and the control lease

sqlite, postgres

Follows record-backend. A ScenarioStorage class of your own requires this key.

storage.data-store

The data items: records, trajectories, tasks, artifacts

sqlite, postgres, or a DataStore class

Follows record-backend

storage.artifact-backend

The versions: the files of each artifact

git_lfs, or a ConfigurableRepositoryBackendFactory class

git_lfs, in the local repository storage.artifact-repository

storage.segment-backend

The content of trajectories, and the data directories of training jobs

local, or a SegmentStore class

Unset: the content is in the database of the data store

storage.task-file-backend

The files of tasks

local, or a TaskFileStore class

local, in storage.task-file-dir

Built in.

Name

What it runs on

Install extra

Credentials (environment variables)

Limits

Tested by

sqlite

Files under storage.agent-record-dir

None

None

One host

Real: tests/storage/ writes SQLite files

postgres

Any PostgreSQL that the hosts reach

reef-infra[postgres]

The URL in storage.record-database-url

The role must create schemas. No managed product, such as RDS or Cloud SQL, is tested.

Real: test_postgres_records.py runs on PostgreSQL 16 in CI; without REEF_TEST_POSTGRES_URL the tests skip

git_lfs, local repository

A bare Git repository with Git LFS, on a local disk or on NFS

None; Git LFS on the host

None

Hosts share the repository only on a filesystem where flock reaches every host: NFS, and not SMB or a FUSE mount of an object store

Real Git with a stand-in for the git-lfs program: test_reef_git_lfs.py

git_lfs, Hugging Face repository

A repository on Hugging Face, with refs: branches-and-tags

None; Git LFS on the host

HF_TOKEN, named by token_env

The token must write to the repository

test_reef_git_lfs.py checks the config and the Git settings. No test calls Hugging Face.

local segments and task files

Directories under storage.agent-record-dir and storage.task-file-dir

None

None

Across hosts, a disk that every host mounts

Real: test_data_segments.py and test_task_store.py write local directories

S3, for imports and exports only

s3:// URIs of an artifact import, a data import and a data export

reef-infra[s3]

The credential chain of boto3

Not a store: no version, record or task file lives in S3

Fake: test_artifact_sources.py replaces the S3 client for reads. The writer of exports has no test in the repository.

Choose where a deployment stores its data has the Hugging Face config, the backup and the upgrade.

Write your own. Each store has one base class. Reef builds each class with its from_config:

Setting

Base class

from_config gets

Implementation to read

storage.artifact-backend

ConfigurableRepositoryBackendFactory (repository.py)

config, and context with work_dir and cache_dir

InMemoryRepositoryBackend (memory.py)

storage.record-backend

ScenarioStorage (store.py)

config, directory, task_files and data

SQLiteScenarioStorage (sqlite.py)

storage.data-store

DataStore (store.py)

config, directory, task_files and segments

SQLiteDataStore (data.py)

storage.segment-backend

SegmentStore (segments.py)

config and directory, a local directory for the segments or for a cache

LocalSegmentStore, in the same file

storage.task-file-backend

TaskFileStore (tasks.py)

config and directory, the value of storage.task-file-dir

LocalTaskFileStore, in the same file

The artifact backend is the store that an object store such as S3 or GCS replaces. Its members:

Member

Required

Called when

Returns

from_config(config, *, context)

Yes

Each Reef process starts

The factory

__call__(scenario)

Yes

A service needs the versions of a scenario. CachedRepositoryBackendFactory writes it: the subclass writes _build_backend(scenario).

The RepositoryBackend of that scenario

RepositoryBackend.register, current, metadata

Yes

A scenario is created or loaded

The reference of the scenario's newest stored version, and the metadata of its registration

RepositoryBackend.publish, materialize, resolve_snapshot

Yes

Control commits a version; a service needs the files of a version

The reference of the stored version; the version with its files in a local directory

RepositoryBackend.store_content, materialize_content, publish_parts, discard_content, discard_all_content

Yes

The training service stores a checkpoint's files, and control commits them as a version by name

See the docstring of each in repository.py

RepositoryBackend.artifact_snapshot, bind_artifact_id, artifact_content

Yes

Reef reads or binds the ID of an artifact

The stored version that the ID names

StagedSnapshotRepositoryBackend.commit_snapshot

Yes, for a scenario with a commit history

After the scenario commits a version that was published without moving the head

Nothing

A factory, the test double of the repository (artifact_backend_plugin.py):

Python
class MemoryArtifactBackend(CachedRepositoryBackendFactory, ConfigurableRepositoryBackendFactory):
    """In-memory scenario backends whose snapshots live under the context's cache directory."""

    def __init__(self, context: RepositoryBackendContext, *, label: str) -> None:
        super().__init__()
        self.context = context
        self.label = label
        self.archived: set[str] = set()

    @classmethod
    def from_config(cls, config: Mapping[str, Any], *, context: RepositoryBackendContext) -> Self:
        return cls(context, label=str(config["label"]))

    def _build_backend(self, scenario: str) -> InMemoryRepositoryBackend:
        return InMemoryRepositoryBackend(scenario, directory=self.context.cache_dir / "snapshots")

    def _archive_persisted_registration(self, scenario: str) -> tuple[str, ...]:
        self.archived.add(scenario)
        return ()

    def has_archived_registration(self, scenario: str) -> bool:
        return scenario in self.archived

The segment store is the smallest of the five contracts. Its abstract methods, as the base class declares them:

Python
@abstractmethod
def write(self, partition: str, segment_id: str, data: bytes) -> None: ...

@abstractmethod
def read(self, partition: str, lines: Sequence[SegmentLine]) -> tuple[bytes, ...]: ...

@abstractmethod
def delete(self, partition: str, segment_id: str) -> None: ...

@abstractmethod
def read_directory_uri(self, key: str) -> str | None: ...

@abstractmethod
def write_directory(self, key: str, source: Path) -> str: ...

@abstractmethod
def open_directory(self, uri: str) -> Path: ...

@abstractmethod
def delete_directory(self, key: str) -> None: ...

A deployment names each class in the mapping form, as the block of "Select it" does for the artifact backend.

Limits and open gaps.

  • Reef has no backend for S3, GCS or Azure Blob Storage: not for the versions, the segments, the task files or the data store. Each one is a class that you write.

  • Reef has no guide page for a storage class of your own. The base class and its docstrings are the contract.

  • A change of backend does not move the data. Choose the stores before the first training job.

  • Google Cloud has no built-in integration. AWS has the S3 reader and writer only.

More plug points #

These settings also take a class of your own. Each has a base class, and the linked page or file gives its contract.

Plug point

Setting

Base class

Who calls it

Contract

Training manager

training.manager

TrainingManager

Control, at an interval, for each trainer of a scenario in auto mode. It decides what trains, in place of the job-samples rule.

Write a training backend

Trial observer

evaluation.trial-observer

TrialObserver

The evaluation service, after each trial and before it removes the trial directory

Sandboxes

Task template builder

evaluation.task-template-builder

TaskTemplateBuilder

The evaluation service, for each task of an e2b evaluation

task_templates.py

Scenario admission

reef.scenario-admission

ScenarioAdmission

A service that creates or loads a scenario, in place of reef.max-scenarios and reef.max-loaded-scenarios

admission.py

Artifact source reader

storage.artifact-sources

ArtifactSourceReader

An artifact import, for a URI scheme beside hf, file and s3

sources.py

Executor

execution.<role>.backend

Executor

reef serve, for the processes and the workers that it starts

Executors

Reef ships no Kubernetes chart. Each service is one reef serve --service NAME process with /healthz, so a process manager or an orchestrator of your choice runs them (Run Reef in production).

Next steps #