Notes

RL Environments

1. What is a Task?

I’d say it’s a unit of work that a human or agent would be expected to complete. A combination of an instruction (the prompt or specified objective), an environment (the initial state and world where the agent attempts the task), and a verifier (a system that grades the agent’s attempt and assigns a reward). Reward = the score your verifier gives to a model for attempting your task.

The purpose of a Task is to determine what a model can or can’t do. They are used for training or evaluating a model, or both. This means they are used to measure progress or to make progress.

So, we aim to find tasks where models’ capabilities are lacking- tasks that can’t be solved yet. For that reason, we focus on finding failure modes (section 3) instead of “Tasks”, as we already know what units of work there are in the real world, either ones humans already complete (filing taxes), or ones that no human has ever or might ever complete but we know what success would look like. This failure mode finding process might require creating and experimenting with multiple tasks.

The real world already tells us how valuable a task is. A good heuristic is: what do we pay people more for, or what would be the economic value of models mastering this? Filing taxes vs curing cancer?

“Task” and “RL Environment” are used interchangeably, but sometimes people refer to an environment as the world that might contain multiple tasks in it.

2. Basic Terminology

  • Saturation = Models are already capable of completing this task.
  • Reward Hacking = the model gets 1.0 by cheating and not solving the task.
  • Judge = LM prompt that reviews a task + final state/response and assigns a reward.
  • Verifiable = You can grade the task without any subjectivity, deterministically, no judge.
  • Trace = A model’s step-by-step thinking, actions, and observations.
  • Artifacts = a snapshot of the environment state at completion time.
  • Benchmark = a collection of tasks that challenge models in a specific domain or measure an AI product company’s ability to complete a task. (aka Eval)
  • Data Pipeline = A process that reduces human involvement in the task creation process.
  • Synthetic Data = tasks built without human intervention or simulated real-world data.
  • Raw Data = real-world data of the domain targeted.

Further definitions: Overview - Harbor

3. Finding Failure Modes

A failure mode is simply the mechanism by which the model fails when trying to complete a task.

We can find these in multiple places; here are 4 of them:

3.1. From real usage

Experts spend a lot of time using the models for work (completing “Tasks”), and they often find things models struggle with; if you find them on yours, congratulations, you are AGI-proof (for now). If you are not an expert, you can work with or get traces from one and use these to build tasks.

In this setup, you already have your instruction/prompt, a decent idea of the result you expect from the model, and how it fails. The hard part is the environment, since these interactions come from the real world, and the real world is messy; you might not be able to replicate it, but it gives you the world components, structure, and hierarchy that will matter later when making our task reproducible.

Note: you could also take cases they complete, but required a lot of steering, or cases they complete but you know increasing difficulty is easy naturally. (UPDATE)

3.2. From real raw data

If you find yourself with lots of raw data in a domain, let’s say astrophysics, chemistry, accounting, healthcare, or coding (aka public GitHub repos), you:

  1. Learn the basics and terminology of the field/narrow domain enough so that you understand what an expert might do with this data, and what the key entities are.
  2. Figure out the type of experts that interact with that data and the types of tasks they do with it. (GitHub is amazing because it gives you state over time via commits, comments, history, issues, PRs; the best type of raw data available has similar characteristics).
  3. Look for time-series data, or rather, data that changes over time; this will give you hints of what events have occurred (for example, a patient was diagnosed, taxes were filed, a planet was discovered, a bug was patched).
  4. These events clearly came from a task completion; that’s what we are looking for here: if you give the model the state up to t−1t-1 (aka the environment), and ask it (instruction) to get to tt (our label for the verifier), can it do it?
  5. After many of these experiments, you should be able to find things models struggle with.

Note: some times that time series data is not enough but the idea is you find the adjacent information to it.

Concrete example: selecting a repo and issue/PR cuts in the Nim pipeline.

3.3. App company traces

If you are an app company, and you are working at the frontier of an economically valuable task, it’s very likely that your evals and user logs show failures models often run into, or failures that they ran into before, but you fixed after a lot of harness patches.

Assuming these failures are model-capability limited, not an implementation issue, this is one of the best places to create tasks. Why? It has the richest signal: user behavior; you can see user retries, complaints, interactions, and use all of that as part of your RL task (and exactly this is the reason why RLaaS companies are thriving)

And the million-dollar question is: should you use these to create RL Tasks and sell them to a lab? Will this give away your moat? I don’t know, and everyone has their own incentives to tell you either way.

2. Selecting Good Failure Modes

Let’s say you found things models can’t do; what of this is worthy of a task?. There are many reasons models could fail at a task; not all of them are useful.

The first thing we need to check is if our Task is “Fair”? A task is unfair if we give the task to an expert and that expert fails the same way a model does. Unfairness usually comes from:

  1. The instruction being underspecified, vague, or contradictory.
  2. The environment lacking enough information or failing to get the relevant information (infra failure) needed to complete the task. A solution might exist, but can a solution even be discovered?
  3. The definition of success not reflecting reality (e.g., artificially inflated expectations)
  4. Success being implementation-dependent, not outcome-dependent. The real world rewards outcomes.

Assuming all of this checks out, here is a taxonomy to categorize the failure modes you found:

  1. Poor reasoning due to lack of knowledge or lack of real-world experience (realism).
  2. The task was solved, but it broke something else
  3. It was lazy and terminated early: claims the task is done, but only did half of it.
  4. Claimed completion of the task by cheating. (reward hacked)

3. Crafting the environment

Let’s build a reproducible world.

  1. What are the APIs/databases/libraries needed?
    • Install them or create mocks (PyPI vs. a Stripe API clone).
    • Figure out how to expose them. Via MCP/coding/CUA, etc.
  2. What are the files needed for the initial state of the task? These will be files in your environment /workspace directory, or used for seeding your API/database mocks.

Example setup: the environment Dockerfile and separate verifier Dockerfile; see the pipeline's environment section for how they fit together.

By default, aim for your tasks to be coding first. read more. This allows out-of-the-box harnesses (codex/claude-code) to interact with the environment in its native action space.

3.1 Realism

A common mistake in RL Tasks is to make them difficult but unrealistic. And this is one reason some models’ usability and behavior don’t match the frontier, even though they look close on benchmarks (hillclimbing). Check John Schulman’s hypothesis on realism and distillation.

The key question is “If an expert were to complete a task or use a model for a very similar task at work, would their experiences look similar to this?” There’s a lot of nuance and “taste” based decisions here; for more details, check section 5 on “What’s high quality”.

3.2. Leakage and Eval Awareness

The environment should not give away the answer, and it should not make it obvious for the model that it’s being tested. Leakage usually comes from git history, metadata left in env, dependencies used for env setup, etc. The following are common instruction texts found in task instructions that create eval awareness and a lack of realism: “The verifier will check x, y, z”… or “you have n seconds to finish your task”.

4. Scoring an attempt

If our fairness checks were successful (Section 2), how do we represent this in the verifier?

  1. Ensure the verifier doesn’t check something the instruction didn’t ask for.
  2. Verify outcomes, not implementations. Treat implementations as a black box.
  3. Do not artificially increase difficulty, especially when it doesn’t reflect a better real-world result. (e.g., making a target number narrower)

From here, it’s mostly nuanced decisions and taste; for example, should we make our reward binary or continuous? Should we allow for partial rewards? Will it be deterministic or via an LM Judge, or a mix of both? How do we prevent cheating?

Some examples

  • Let's say your solution needs to pass 25 unit tests; if the model achieves 24/25, should it get a 0? Should it get a 0.5? Should it get a 0.96? It depends?
  • Let’s say your verifier needs a performance of 10ms; what is the baseline, or 0 reward? Is there a negative reward? Can the model get a score greater than 1? Can the score be continuous?
  • Say you ask for your taxes filed, but you get only bookkeeping, or bookkeeping + the form but not submitted; is that a partial reward? A 0?

Concrete implementation: the Nim verifier and scoring code. See Verifier creation in the worked example.

4.1 Deterministic or not?

Deterministic vs LM Judges/Rubrics

A task is deterministic if, when you show a potential solution to 10 humans, they all flag it as equally correct or incorrect, or if all 10 of them would answer the exact same thing; when you need judges/rubrics, it’s when the opposite happens: they might disagree, and both could be correct or wrong, so it requires judgment.

  1. Some examples of deterministic verifiers:
    • unit tests in a codebase
    • testing the performance of some code
    • extracting a value from the environment mocks (apis/database/etc)
    • matching an exact amino acid chain string in a JSON response
    • matching a float with some tolerance (realistic tolerance not constrained to a narrower one just to increase difficulty)
  2. Some examples of when LM Judges / Rubrics are needed:
    • diagnosing a patient (do 2 physicians agree)
    • accounting or legal tasks where there’s subtlety expert by expert

For LM judges, 3 techniques to keep in mind: 1) expert <> judge alignment, 2) self-consistency / majority voting, 3) few contrastive shots in the prompt.

4.2 Reward Hacking

If during the RL process you reward the model for completing a task by cheating and that behavior gets reinforced, it becomes a major misalignment risk. Making tasks not reward-hackable is unfortunately mostly a reactive process, not proactive. Here are some general guidelines:

  • Do not expose your tests in the environment

  • Make sure that your tests don’t suffer tampering

  • Keep SHAs of files that should not be modified

  • Isolate environment and verifier containers

  • Do not reuse files from your environment in the verifier container; rather, add clean copies.

  • The best way of finding task reward-hacking vectors is by sampling: ask models to find alternative solutions to your task; a simple example of this is the terminal-bench-ci /cheat command. Some things you could do are:

  • Include the verifier logic in the environment and run trials asking models to pass the verifier with solutions that don’t satisfy the instruction but still score 1.0.

  • Run an LM judge on your existing trials asking for instances of reward hacking (models are usually good at reading traces and finding this).

  • Iterate a few times here by adding deterministic gates that prevent the verifier from allowing reward-hacking behaviors until you patch every possible opportunity.

Open problem: if patches are too specific to custom solutions, future models will certainly discover novel ways to hack your task.

This project's adversarial cheat-trial runner and trial analysis implement that review loop.

4.3. Oracle Solution

Write a solution script or string response/document, etc., that consistently gets a reward of 1.0 when sent through the verifier. Doing nothing should return 0.0.

Example: the reference solution script and fail-to-pass validation.

5. Going Further on QC

5.1 Calibration

Calibration refers to the task’s pass rates; for example, if you sample 8 times with 6-astra and the model gets 100% on 3 of 8. Ideally, this isn’t something you tweak; it should come naturally from the task’s intrinsic difficulty.

Taking an “easy” task (high pass rates) and trying to make it more difficult is valid and common. But make sure it stays realistic, that the difficulty doesn’t become just repetition (like doing a lot of the same task), and that task stacking (combining 2 or n simple tasks) is, for example, not just “do x and then do y”, but only “do y”, which will force the model to figure out and achieve x as well.

During this process, you might need to change the instruction multiple times. You’ll notice how task pass rates vary after adding or removing a hint; it’s useful to watch for signals: pass rates increasing drastically across multiple models after a small change might flag a task design issue, and pass rates not increasing after many hints might also flag task design issues. Check Reverse GEPA for more details here.

Discriminative power is usually a good signal: when different models struggle with different things and pass rates vary across them. (If every model seems to be having the same issue, it might be a task design issue)

Example results: eval.md reports pass rates and methodology for nim-hard. See also the pipeline's calibration section.

5.2 Contamination

If your solution is public (available on the internet), like a commit or a PR in a repo, it’s very likely the model saw it during pre-training. Check if any responses seem elicited from memory.

Note: the data need is so large that I’m not sure how much of a big deal this is anymore, with so many tasks sold that are just being farmed out of GitHub repos.

5.3 Consistency

If you take a solution and run it multiple times, is your verifier consistent? e.g., when tasks require a GPU, there’s hardware variance from CUDA drivers, GPU clocks, temperature, etc.

5.4 Instruction Quality

Bad instructions usually overspecify the environment and ask for a specific implementation rather than an objective. Make sure your environment has no READMEs or files that act as separate instructions. Let the agent discover part of the task from the environment resources/available options; there’s no need to tell it everything about it.

5.5 Internet Access

If you give it access, there’s a potential security issue as well as reproducibility (websites/huggingface/github) might change repos or state, which we can’t control (frontier labs are giving models a replica of the internet).

If you don’t give it access, you are guaranteeing consistency and security, but trading eval awareness and realism.

Isolation should be handled by sandbox providers such as modal/daytona/e2b… In theory, a task creator should not worry about the sandbox primitive.

5.6 Reading Traces

Reading traces

Open the Harbor evaluation job for the 180 retained agent trajectories, verifier logs, and submitted source artifacts.

5.7 Post-Training a model

If you can create many of these tasks, run controlled training experiments, and have the compute to do it, why not? Primarily, you’ll learn 2 things: 1) data attribution, 2) data’s hill-climbing abilities.

For more, read What Makes a Good Terminal Bench Task.

6. Scaling up

Your ability to scale will depend on how easy it is to synthesize and automate parts of the task creation process while sustaining quality.

6.1 Parametrizable Tasks:

When an environment can be parametrized to create a large number of tasks, either by searching a space of potential input <> output pairs or by procuring a variety of seed data <> expected output pairs.

Especially useful when a task involves optimization, anything with a number people push (faster, cheaper, lower, stronger…) and that you can search for programmatically at the expense of more compute, like the right kernel grid params, vLLM params, etc. For example PostTrainBench.

Tasks here must satisfy the following criteria.

  • 0 (baseline) and 1 (target) must be easy to determine or extract
  • Scores must be easy to measure across task variants.
  • Easy to change inputs and create task variants.
  • [Optional] but preferred, the solution (a patch that gets a score of 1.0) can be searched programmatically, or heuristics can represent it.

A separate question is how much diversity you can sustain while synthesizing tasks.

6.2 Great QC and Infra

Good QC pipelines have at least the following steps:

  • Static checks
  • LM rubrics
  • Automated trials
  • Judge trial analysis

After your task goes through QC, a human pipeline is needed (sometimes it’s not) where experts can apply their own judgment to a task and check its quality, fairness, realism, etc.

Example QC code: static checks, rubric review, and trial analysis. The pipeline note shows how these stages connect.