Setting up a Hive experiment requires three things:
- A target — which files (or lines) the Hive is allowed to modify
- An evaluator — a script that scores each candidate solution
- A sandbox — the environment where evaluations run
Optionally, you can also provide natural language context to guide the search.
The Hive can evolve arbitrarily large codebases, but like a human researcher, it performs best when its task is well-defined. Before starting, consider:
- Is the code you want to improve clearly separable from the surrounding harness?
- Do you have a quantifiable metric? If a higher score doesn’t mean a better algorithm, you’re measuring the wrong thing.
- Would domain knowledge or directional hints help narrow the search?
Define the target
The Hive needs to know which files in your codebase it is allowed to modify. This is specified in the configuration YAML using the repo.target_code field:
It is possible to specify multiple files to evolve, and specific line ranges too, see here.
Everything outside these paths is treated as fixed infrastructure. This lets you isolate the algorithm or heuristic you want to improve while keeping the surrounding harness stable.
Write the evaluator
One of the most important parts to setting up a Hive experiment is defining an evaluator. Concretely, this is a Python script specified in the configuration YAML file as a local path relative to the codebase root.
This script is run as python3 path/to/evaluation.py, and must print a JSON object to the final line of stdout. A typical evaluation script looks something like:
The evaluation script communicates its feedback to the hive-coordinator via stdout. This is done by writing a JSON on the last line of stdout.
The JSON must be printed as a single line on the last line of the evaluator’s output.
Single Objective
On successful evaluation, the JSON should have the following form:
The Hive optimizes for an algorithm which maximizes the quantity reported under result.fitness.
Multi Objective
You can also define an evaluator with multiple objectives to be optimized simultaneously by reporting result.fitness as a mapping of objective names to scores, e.g.,
Failed Evaluation
When an evaluation fails — for example the candidate code fails correctness checks or errors out — report the failure with an error message instead:
Tips and tricks
The Hive optimizes for the score your evaluator returns — make sure that score faithfully represents what you actually want to improve.
- Enforce correctness explicitly. Never assume the output of the evaluator is correct. You should always add tests or checks to guarantee the code produces correct results before scoring performance. Your evaluator should return a failure if the code produces incorrect results, regardless of performance.
- Guard against reward hacking. The Hive will exploit any shortcut that inflates the score — caching results, short-circuiting logic, or producing hardcoded outputs. Build validation checks into your evaluator and treat unexpectedly large score jumps with skepticism.
- Make evaluations deterministic. If your evaluator has stochasticity, run it multiple times and report the mean or median. Noisy scores make it harder for the Hive to distinguish genuine improvements.
- Stochastic evaluations. If your evaluator can’t be made deterministic, the Hive supports an adaptive approach to re-sample high-variance results, see
runtime.stochastic_evaluator.
- Keep evaluations fast. The Hive iterates faster with quick feedback. Balance evaluation thoroughness with speed — consider if a lighter test suite provides sufficient signal compared to an exhaustive one.
- Use relative scoring for timed benchmarks. Hardware performance can vary between sandboxes. If optimizing for runtime, instead of reporting raw times, run a baseline alongside each candidate and report the speedup factor.
- Maximize by convention. The Hive always assumes objectives should be maximized. If you have a quantity you want to minimize, return the negative of that value as the fitness.
Once the evaluator is implemented, it is also important to consider what environment to run the code in. Each candidate solution is evaluated inside a sandboxed environment which can be customized in the configuration YAML as follows:
Below, we briefly explain the most important fields and how to use them. See this page for a full list of available options.
base_image: The Docker image used as the base environment. Because evaluation scripts are run with python3, the base image must include python3. The Hive will attempt to install the following system-dependencies if missing: rsync, git, jq, iptables, and util-linux — using one of the following supported package managers: apt-get (Debian/Ubuntu), yum (RHEL/CentOS), or apk (Alpine). Good choices are the official python images (e.g. python:3.14-slim) or, for GPU workloads, an ML image that ships Python such as pytorch/pytorch. You can also build and use your own custom base image, as explained here.
setup_script: Shell commands that run once when the sandbox is first created. Use this to install dependencies or download data.
resources: CPU, RAM, and shared memory allocated to the sandbox. GPUs can be added with the format <accelerator-name>:<num-gpus>.
If you don’t have a strict constraint on target hardware, allocate resources with some headroom. Resource exhaustion is reported as an evaluation failure, and high-performing solutions can consume more resources than expected.
evaluation_timeout: Maximum time in seconds before an evaluation is terminated.
Set this with some headroom — high-performing candidates can take longer than expected, and an overly tight timeout may discard good solutions.
Provide context
You can provide natural language context to guide the Hive’s search. This is specified in the prompt.context field:
Use this to describe the problem domain, suggest directions to explore, or set soft constraints on approaches the Hive should avoid.
If you have multiple distinct ideas you want the Hive to explore, list them in the prompt.ideas field:
On each iteration, the Hive will randomly sample one of these ideas to guide its approach.
Finally, if there are any files in the codebase that provide important context to writing the desired algorithm, such as internal dependencies, these can be specified in the repo.additional_context field.