API Reference

Services

A Reef deployment runs seven services. reef serve runs all of them in one process, and reef serve --service NAME runs one (Run the services in separate processes). The services never call each other. They share one store, and a service asks another for work by adding an item to a work queue in that store. The other service runs the item and stores a result.

This page is generated from reef/api/contracts.py (python .github/scripts/check_service_reference.py --write). Each queue's messages are typed in the code (reef.core.messages), so a producer and a reader of a queue use the same fields.

Service

What it does

Takes work from

Adds work to

control

Owns the scenarios: it accepts records and reports, runs the trainers that turn samples into training jobs, commits new versions, decides which version serves, and queues work for the other services.

training_requests, data_sync, harness_sync, scenario_deletes

serving, samples, training_requests, jobs, training_checks, evaluations, data, scenario_deletes

inference

Starts the engines for the versions that each scenario serves, answers model requests, and appends a record for each request.

serving, inference-owner

serving, inference-owner

samples

Reads new records and turns them into training samples with the recipe's record-to-sample stage.

samples

samples

training

Runs training jobs and the checks before them on the training backend, and saves checkpoints.

jobs, training_checks

none

evaluation

Runs the evaluation rollouts of candidate versions in sandboxes and scores them. It asks inference to serve each candidate.

evaluations

serving

data

Stores the data items of each user: uploads, imports and exports, sets and collections. It also answers the read routes of each scenario.

data

data, data_sync

harness

Answers the harness client: it gives the current harness tree and queues the trees that clients send back.

none

harness_sync

The services #

control #

Owns the scenarios: it accepts records and reports, runs the trainers that turn samples into training jobs, commits new versions, decides which version serves, and queues work for the other services.

  • HTTP: The whole Reef API: scenarios, records and reports, training requests, artifacts, evaluations and status (HTTP API reference). It also answers the model routes and the harness routes, and, when it runs in one process with the data service, the data routes.

  • Takes work from: training_requests, data_sync, harness_sync, scenario_deletes

  • Adds work to: serving, samples, training_requests, jobs, training_checks, evaluations, data, scenario_deletes

  • Stores:

    • scenario storage: records, commits and settings

    • data store: samples and training job data

    • artifact repository: commits and activation

    • coordination store: served models, the control lease and the work queues

  • What a recipe adds: The report type (Recipe.report_type), the sample-to-job stage (Sample2Job) and the activation rule that decides whether a new version serves.

  • Control lease: Needs the control lease. Standbys wait for it; an instance that loses it stops.

  • Scaling: One active instance and any number of standbys. A standby takes over within 10 seconds after a normal stop, and after a crash when the 30-second control lease runs out.

inference #

Starts the engines for the versions that each scenario serves, answers model requests, and appends a record for each request.

  • HTTP: The model routes: /v1/*, /reef/scenarios/{scenario}/v1/* and the artifact and evaluation model routes (Inference API), and the inference status of each scenario.

  • Takes work from: serving, inference-owner

  • Adds work to: serving, inference-owner

  • Stores:

    • coordination store: reads served models; the engine owner writes them

    • scenario storage: appends records

    • artifact repository: stages snapshots in storage.artifact-cache-dir

  • What a recipe adds: The artifact components (Recipe.build_components): what a version holds and how to load it.

  • Control lease: No control lease. One replica holds the inference-owner item and starts the engines.

  • Scaling: Any number of replicas answer requests. One of them owns the engines; when it stops, another replica takes the inference-owner item and starts the engines of each scenario again.

samples #

Reads new records and turns them into training samples with the recipe's record-to-sample stage.

  • HTTP: None besides GET /healthz.

  • Takes work from: samples

  • Adds work to: samples

  • Stores:

    • scenario storage: reads records

    • data store: writes samples

  • What a recipe adds: The record-to-sample stage (Record2Sample), and the task generator of a generated-task recipe.

  • Control lease: No control lease.

  • Scaling: Any number of replicas. Each trainer of a scenario has one selection at a time.

training #

Runs training jobs and the checks before them on the training backend, and saves checkpoints.

  • HTTP: None besides GET /healthz.

  • Takes work from: jobs, training_checks

  • Adds work to: none

  • Stores:

    • data store: reads the data of each job

    • task files: the tasks of task jobs

    • artifact repository: reads the start snapshot and writes checkpoint files

  • What a recipe adds: The job parameters (WeightTrainingRecipe.default_parameters) with the objective and loss family that they name, or, for harness evolution, the method (Method), the task scorer and the task collector.

  • Control lease: No control lease.

  • Scaling: training.max-jobs jobs at once for each training component in each process. When a worker stops, the next one continues the job from its checkpoints.

evaluation #

Runs the evaluation rollouts of candidate versions in sandboxes and scores them. It asks inference to serve each candidate.

  • HTTP: None besides GET /healthz.

  • Takes work from: evaluations

  • Adds work to: serving

  • Stores:

    • scenario storage: reads the scenario of each rollout

    • data store: writes evaluation calls and trajectories

    • artifact repository: reads task files

  • What a recipe adds: Nothing. The deployment selects the trial observer and the task template builder.

  • Control lease: No control lease.

  • Scaling: evaluation.max-sandboxes rollouts at once in each process. evaluation.on-stop says whether a stopping worker gives its rollouts back or lets them finish.

data #

Stores the data items of each user: uploads, imports and exports, sets and collections. It also answers the read routes of each scenario.

  • HTTP: The data routes /reef/namespaces/{owner}/* (Data API), artifact files, and the scenario read routes.

  • Takes work from: data

  • Adds work to: data, data_sync

  • Stores:

    • data store: items, sets and collections

    • scenario storage: reads, and copies records

    • artifact repository: reads artifact files

  • What a recipe adds: Nothing.

  • Control lease: No control lease. A write waits up to 30 seconds for control to sync the scenario.

  • Scaling: Any number of replicas.

harness #

Answers the harness client: it gives the current harness tree and queues the trees that clients send back.

  • HTTP: The harness routes /reef/harness* (Harness API).

  • Takes work from: none

  • Adds work to: harness_sync

  • Stores:

    • scenario storage and artifact repository: reads commits and artifacts

  • What a recipe adds: The harness adapter of the harness recipe. The service refuses a recipe without a harness.

  • Control lease: No control lease. An import waits up to 30 seconds for control to commit it.

  • Scaling: Any number of replicas.

Work queues #

Each queue has kinds of items. A kind written as name:{placeholder} is a family of kinds, one for each value. An item's payload is what its producer asks for, and its result is what the worker stores when it finishes.

serving #

The serving work of the inference owner. Control adds a serve item for each new selection of a scenario, with the serial key serving:<scenario>, so that the work of one scenario runs in order. The inference owner adds a stop_serving item for each due stop, with the scenario 'serving' and the serial key 'serving', so that the stops run one at a time. When it takes over, it adds a copy of each finished serve item. An evaluation rollout adds serve_artifact items, with the serial key serve_artifact:<scenario>:<artifact_id>.

serve items

Serve a scenario's selected artifact and the artifacts beside it, and publish their routes; an empty payload withdraws the scenario's routes at once.

Payload

artifact_id string the non-empty ID of the artifact that the scenario's model name active serves.
selection object the artifact selection that loads artifact_id: each component name mapped to an artifact ID (a string).
aliases list of string more non-empty model names that serve artifact_id; can be empty.
beside object each artifact that the scenario serves at its own route, under its ID as model name. It maps the artifact ID to an object with selection (component name to artifact ID) and component (string); can be empty.
serving_config object the serving fields of the served component; {} when the scenario sets none.
redeploy integer left out unless a person asked to deploy the engines again; then a number that makes the request new, so that the engines start again for the same selection.

Result

<model name> object, a ServedArtifact the route of one non-empty model name (active, an alias, or the ID of an artifact served beside): exactly the keys artifact_id, url and model_name (non-empty strings).

Progress entry

startup object the report. Its keys are artifact_id (string), the non-empty ID of the artifact that starts, the selected one or one served beside it; phase (string), "prepare", "start" or "load" (PHASES); detail (string or null), a short note of what the phase does now, such as "Quantizing to NVFP4"; estimate_seconds (number or null), a finite guess of the seconds until the engine is warm; and at (number), the finite time of the report, in seconds since the epoch. A missing detail or estimate_seconds reads as null.

stop_serving items

Stop serving an artifact whose scheduled stop is due, when no route uses its engine any more.

Payload

served object, a ServedArtifact the served artifact to stop, with exactly the keys artifact_id, url and model_name (non-empty strings).
stop_after number the finite time in seconds since the epoch from which the stop is due.

Result: an empty object, {}.

serve_artifact items

Serve one artifact with no route, such as an evaluation candidate, and give the address that reaches it.

Payload

selection object the artifact selection that loads the artifact: each component name mapped to an artifact ID (a string).
component string the non-empty name of the component of the selection to serve.

Result

served object, a ServedArtifact, or null the route of the started artifact, with exactly the keys artifact_id, url and model_name (non-empty strings); null for a runtime with no address that another process can call. The key must be present.

Metadata keys:

  • automatic_retries: On a serve item that control made to retry a failed request of the same payload: the number of such retries in a row, an integer from 1; no key means 0. Control reads it to compute the next retry delay.

  • recovery: On a serve item that the inference owner added again after it took over: true. The startup status shows such an item as starting, not pending.

inference-owner #

The ownership of the inference runtime. Each inference worker asks for the one item, with the scenario 'inference' and the serial key inference-owner. The worker that takes it owns the runtime while it renews the item's work lease.

inference-owner items

Hold the inference runtime: only the inference worker that holds this item starts and stops engines.

Payload: an empty object, {}.

Result: an empty object, {}.

samples #

The record selections of each trainer, one at a time per trainer; each turns new records into samples.

record_selection items

Make samples of the records that one trainer has not used yet, and store them as data items of the scenario.

Payload

scenario string the non-empty name of the item's scenario. It is written but not read: readers use the item's scenario, and the key stays so that the stored JSON does not change.
component string the non-empty name of the trainer's component.

Result

changed boolean whether the selection gave the trainer something new to build a job from: a new stored sample or a new training request. It is true when samples_created is more than 0.
background boolean whether background work of the stages still runs, so that the samples service looks again later.
records_read integer or null the records that the attempt replayed, ignored records included, from 0; null when unavailable.
samples_created integer or null the samples that the attempt inserted, from 0; null when unavailable.
due_in_seconds number or null the seconds, finite and from 0, until a set that waits for time alone is due, such as a trajectory at the end of its idle time; null when no set waits for time.
record_sequences list of integer or null [first, last], the first and last data sequence of the scenario's own records that the attempt read, with 1 <= first <= last; null when it read none of them.

Metadata keys:

  • trigger:<name>: A number: when the trigger <name> (one of TRIGGERS) first asked for the selection, in seconds since the epoch. The sample processing pages list them, and the samples service drops a deleted scenario when the trigger delete asked.

  • progress: A SelectionProgress: the counts so far of the attempt that runs. The sample processing pages show the counts of the current attempt.

  • background_poll_seconds: A number: the seconds that the selection waited before it looked again at background work. The samples worker doubles it for the next look while nothing changes.

training_requests #

The training requests that wait for a commit, in the order they came, one serial key per scenario.

training_request:{scenario} items

Train once on what the person asked for; the item ID is the request ID, and the item waits until a training commit consumes the request.

Payload

text string what the person asks the training to change; not blank, at most 4000 characters.
session string the session that the request came from; can be empty. With artifact_id it names the request's source; it does not select an inference batch.
artifact_id string the artifact that the person used when they asked; can be empty.
requires list of object what the change needs from the person's machine: at most MAX_REQUIRES {name, kind, check?, prompt?} items (reef.core.requirements.parse_requires); can be empty. Missing or null reads as none.
client object the requesting client's report of its machine (parse_client): platform, arch and release (strings) and commands (an object of booleans). Left out when empty. A reader keeps only the entries that fit this shape.
parameters object the parameters of the request's training job, merged into the recipe's; at most MAX_PARAMETERS_BYTES bytes of JSON. Left out when empty; missing reads as {}.
samples list of string the distinct non-empty IDs of the samples that the request's job trains; not empty when present. Left out when empty; missing reads as none.
train_from string the non-empty ID of the artifact that the request's job starts from. Left out when null; when it is missing, the job starts from the scenario's training start.

Result

consumed boolean always true. No code reads it; the item's state finished says the same.

Metadata keys:

  • failure: A string: what the failed step of the request said, or REQUEST_CANCELLED_ERROR when a client cancelled it. Control writes it; the trainers then consume the request with a skip row and no job, and a job of the request that control submits later is cancelled.

jobs #

The training jobs that control's trainers submit and the training service runs, one component's jobs to its worker.

training_job:{component} items

Run one training job on the named training component, and record each checkpoint that it stores.

Payload

backend string the non-empty name of the training component that runs the job; the item's kind names it too.
start string the non-empty start of the job: a start that the component made, or the name of a snapshot of the scenario (SnapshotStart.to_text). The training service replaces a snapshot name by the component's own start before the component reads the job.
data object the job data directory in the data store (JobDataRef.to_dict), with the keys data_id, uri and key (non-empty strings), sample_count (integer from 0) and kind ("trajectory", "task", or null for data without samples). Each of these keys must be present.
parameters object the job's training parameters.
request object, a JobRequestSummary, or null the training request that the job trains; null for a job that the training mode auto made without a request, and in a job check. Missing reads as null.
component string or null the non-empty name of the scenario component that the job trains. Missing reads as null.
previous_job_id string or null the non-empty ID of the last job whose end the trainer committed. Missing reads as null.
train_from_artifact_id string or null the non-empty ID of the artifact that the start came from. Missing reads as null.

Result

state string always "finished".
metrics object the training metrics that the component reported for the whole job. Missing or null reads as {}.

Progress entry

step integer the step of the job that saved the checkpoint, from 0.
path string the non-empty path of the checkpoint in the training service; only the component reads it.
content string the non-empty name of the stored content that holds the checkpoint's files in the artifact store of the job's scenario.
metrics object the training metrics that the component reported for the checkpoint.
changed_parts list of string the parts of the artifact that the checkpoint changed (TrainingComponent.changed_parts), sorted, each non-empty.

Metadata keys:

  • stored_content: A list of strings: the names of the content that the training worker stored, or was about to store, for the job's checkpoints. The worker and control's sweep of ended jobs read it.

  • progress: An object or null: what the training component reports about the running job (TrainingComponent.job_progress). The training worker writes it; control reads it as the progress of the running harness step.

  • experiment: An object {tracker, project, entity, run_id, url}: the experiment run that records the job. Control writes it when its tracker records a commit of the job; the job listing reads it.

  • failed_metrics: An object: the metrics that the training component reported for a failed job, since a failed item has no result. Control reads them with the job's status.

training_checks #

The questions that only a training component can answer, which control asks the training service.

training_check:{component} items

Ask the named training component whether it can train a job or read an artifact, or have it archive what it keeps for a deleted scenario.

Payload

check string "job", "artifact" or "archive".
job_id string only when check is "job"; see JobCheckPayload.
job object, a JobPayload only when check is "job"; see JobCheckPayload.
names object only when check is "artifact"; see ArtifactCheckPayload.

Result

refusal string or null the message of the ValueError with which the component refused; null when it accepted. An archive always answers null. Missing reads as null.

Metadata keys:

  • asked_at: A number: the time in seconds when control last asked for the answer. The check worker drops a job or artifact check that control did not ask for within UNASKED_CHECK_SECONDS.

  • answer_read: A boolean: true once control read the answer, so that a later submit of the job asks again.

evaluations #

The rollouts of the artifact evaluations that control accepted, and on e2b the template builds of their tasks.

evaluation_rollout items

Run one rollout of an evaluation: run one task once with the candidate's model and the evaluation's harness, and store its score.

Payload

scenario string the non-empty name of the scenario of the evaluation.
evaluation_id string the non-empty ID of the evaluation.
artifact_id string the non-empty ID of the candidate artifact that the rollout evaluates.
component string the non-empty name of the component of the scenario's artifacts that the candidate is.
task_index integer the position of the task in the evaluation's task list, from 0.
task_name string the non-empty name of the task.
repeat integer the number of this rollout among the rollouts of its task, from 0; 0 in a template item.
model object the model that inference serves for the candidate (PolicyModel): name (non-empty string) and adapter (a non-empty string, the location of a LoRA adapter, or null).
agent object or null the Harbor agent configuration; null when tree is the harness.
environment string the non-empty Harbor environment type, such as docker or e2b.
selection object the artifact selection that serves the candidate: each component name mapped to an artifact ID (a string).
tree object or null the harness tree (TreeHarness); null when agent is the harness. Its keys are adapter and api (non-empty strings), files (an object of path to text) and env (an object of variable name to text, left out when empty; missing reads as {}).
log_probs boolean whether the model calls ask for log probabilities. Missing reads as false.
owner string or null on e2b, the non-empty owner that the scenario's record stored when control accepted the evaluation; null when the record stored none, and on every other environment. Missing reads as null.
requires_prepared_templates boolean whether the rollout runs a trial only from its task's prepared templates; true only on e2b. Missing reads as false.
task_digest string the lowercase hex SHA-256 of the accepted task's files. Left out when null, for work that pins no task files.

Result

score number or string the rollout's score, a finite number, or "failed" when the rollout ran and gave no score (RolloutScore).
rewards object or null the rewards of the task's verifier (verifier_rewards), reward name to number, at most MAX_VERIFIER_REWARDS; null when the verifier wrote none. A reader checks that it is an object, but not its values: nothing scores with them. Missing reads as null.
error string or null why a "failed" score has no value; null for a scored rollout. Missing reads as null.

evaluation_task_template items

Build the e2b sandbox templates of one task of an evaluation before its rollouts run; the payload is the task's first rollout.

Payload

scenario string the non-empty name of the scenario of the evaluation.
evaluation_id string the non-empty ID of the evaluation.
artifact_id string the non-empty ID of the candidate artifact that the rollout evaluates.
component string the non-empty name of the component of the scenario's artifacts that the candidate is.
task_index integer the position of the task in the evaluation's task list, from 0.
task_name string the non-empty name of the task.
repeat integer the number of this rollout among the rollouts of its task, from 0; 0 in a template item.
model object the model that inference serves for the candidate (PolicyModel): name (non-empty string) and adapter (a non-empty string, the location of a LoRA adapter, or null).
agent object or null the Harbor agent configuration; null when tree is the harness.
environment string the non-empty Harbor environment type, such as docker or e2b.
selection object the artifact selection that serves the candidate: each component name mapped to an artifact ID (a string).
tree object or null the harness tree (TreeHarness); null when agent is the harness. Its keys are adapter and api (non-empty strings), files (an object of path to text) and env (an object of variable name to text, left out when empty; missing reads as {}).
log_probs boolean whether the model calls ask for log probabilities. Missing reads as false.
owner string or null on e2b, the non-empty owner that the scenario's record stored when control accepted the evaluation; null when the record stored none, and on every other environment. Missing reads as null.
requires_prepared_templates boolean whether the rollout runs a trial only from its task's prepared templates; true only on e2b. Missing reads as false.
task_digest string the lowercase hex SHA-256 of the accepted task's files. Left out when null, for work that pins no task files.

Result

prepared_images list of object the images that the trials of the task can start (PreparedImage), each with the keys directory, source_image, image, template_id, start and ready. No two of them have the same directory and source_image. Left out when null, when the builder gave none.
task_digest string or null the non-empty task digest that the builder made the images for; null when the task resolver gave no digest. Missing reads as null.

Metadata keys:

  • waits_for_retry: true on a final rollout item that a retry or a resume runs again once max_concurrent_rollouts lets it, else false or missing; control writes it and reads it.

data #

Work on the data store that runs apart from control: artifact copies after a commit, imports and exports.

artifact_copy items

Store an artifact item in the owner's data store for each artifact that the item's scenario lists.

Payload: an empty object, {}.

Result

items integer the number of items, from 0: the artifact items that a copy stored, the items that an import stored, or, in a progress entry of a trajectory import, the items stored so far.

data_import items

Import the files at a URI as task or trajectory items of one owner; each progress entry of a trajectory import counts the items stored so far.

Payload

owner string the non-empty name of the owner whose items the import stores; the item's scenario holds it too. The data routes check it as an owner name.
uri string where the files are, such as s3://bucket/prefix or file:///path; it holds ://.
metadata object the metadata of each item that the import stores. Its kind is "task" (each Harbor task directory becomes a task item) or "trajectory" (each line of a JSON Lines file becomes a trajectory item).

Result

items integer the number of items, from 0: the artifact items that a copy stored, the items that an import stored, or, in a progress entry of a trajectory import, the items stored so far.

Progress entry

items integer the number of items, from 0: the artifact items that a copy stored, the items that an import stored, or, in a progress entry of a trajectory import, the items stored so far.

data_export items

Write items of one owner, by ID or by kind and scenario, to a tar.gz archive at a URI.

Payload

owner string the non-empty name of the owner whose items the export writes; the item's scenario holds it too.
uri string where the archive goes, such as s3://bucket/key or file:///path; it holds ://.
ids list of string or null the IDs of the items to write, 1 to MAX_QUERY_LIMIT non-empty IDs. Left out when null, except that a null that the request gave stays.
kind string or null without ids, write only the items of this kind, one of ITEM_KINDS. Left out when null, except that a null that the request gave stays.
scenario string or null without ids, write only the items that this scenario uses. Left out when null, except that a null that the request gave stays.

Result

items integer the number of items in the archive, from 0.
bytes integer the size of the archive in bytes, from 0.

data_sync #

The syncs that the data service asks control for after each data write, one for each scenario and owner.

data_sync items

Sync the item's scenario, when it is loaded and has the owner, with the owner's items: wake its trainers and its samples service.

Payload

owner string the non-empty name of the owner whose items the scenario of the item reads. A scenario of another owner does not sync.

Result: an empty object, {}.

harness_sync #

The harness syncs that the harness service asks control to commit, for POST /reef/harness/import.

harness_sync items

Commit a sync of a person's harness files onto the active harness of the item's scenario, and answer the harness service.

Payload

files object each file's path under the adapter's render roots, mapped to the file's text (a string).
base_artifact_id string or null the non-empty ID of the harness artifact that the client installed. Left out when null, except that a null that the client sent stays. Control refuses a sync without it once it found the scenario.
<other key> any JSON type another key of the body, as the client sent it. It is written but not read.

Result

answer object, a HarnessImportAnswer present when control committed the sync; the answer of the sync.
refused object, an ImportRefusal present when control refused the sync; why it refused.

scenario_deletes #

The cleanups of deleted scenarios, one queued item for each scenario; every service drops its copies of the scenario when it sees an item.

scenario_delete items

Remove what Reef keeps of the item's scenario once its delete marked it, and ask the training and samples services to remove what they keep.

Payload: an empty object, {}.

Result

deleted boolean whether the scenario was marked deleted, so that the cleanup removed it. False when the delete stopped before its mark: the scenario is whole, and the cleanup removed nothing.
archived list of string the non-empty archive locations of the scenario's storage. Left out when deleted is false.