When I started extracting tasks from our codebase, I assumed the existing unit tests could become the grader. We already had a working system and tests for it. Give an agent the task, run the suite, and use the result as the reward.

Can you use those unit tests as the grader? Not as they stand, if they run inside a system the agent controls.

Keep useful tests in the workspace to help the agent develop its solution. But extract the checks that determine the final score into a protected grader outside the agent-controlled environment. That grader should act like an independent observer: give the system inputs, inspect what it actually does, and decide whether the requirements were met.

The assertions can still be tests. The important change is who controls their execution and the evidence they produce.

Unit tests help the agent work

Local tests are useful feedback. They show examples of expected behavior, catch regressions, and let the agent check a change before continuing. I would keep them for the same reasons I keep them when writing software myself.

But a development test and an authoritative grading check have different jobs. The agent can use a local test to guide its work. The final reward needs evidence that the agent cannot manufacture by changing the surrounding system.

That means you can leave examples or copies of tests available to the agent while keeping the authoritative checks in the grader. There is no need to make the task harder by removing all feedback.

Why the existing test suite isn't enough

Consider a Go server with unit tests that call its functions directly. The candidate code and the tests execute in the same process. The agent may not be able to edit the test files, but it can change the code those tests load.

If the outer grading script accepts a printed “all tests passed” message or a zero exit code as proof of success, candidate code could print that message and exit before the assertions run. The task remains unsolved, but the grading wrapper accepts the result.

This is a failure of that grading setup, not a claim that every unit-test runner behaves this way. It illustrates the question to ask: can the code under test interfere with the mechanism that decides whether it passed?

Read-only test files don't answer that question. Neither does putting the tests in a folder called protected. The runner, expected answers, and final score all need a real protection boundary.

Extract the checks into an outside observer

For the authoritative grader, I want a simple division of responsibility:

  1. The candidate runs the system under test. It accepts requests and produces outputs or changes state.
  2. The protected grader chooses the inputs and checks the observations. Its expected results and comparisons stay outside the candidate's control.
  3. The protected grader writes the score. A candidate response is data to evaluate, never permission to award itself credit.

An HTTP API or a small input/output CLI can provide that interface. For a calculation, the grader sends values, reads the returned answer, and compares it with an independently computed result. The candidate does not get to supply the expected answer or report an authoritative PASS.

Two grading paths: a wrapper that trusts a candidate’s printed PASS can award an undeserved reward. A protected external grader instead sends inputs, checks outputs and stored state against expected results, and assigns the score. Local unit tests stay in the agent-controlled workspace.

In the lower path, the protected grader supplies test inputs to the candidate and compares the returned outputs and stored state with expected results. For a persistence task, that could mean writing a record, restarting the program, and checking that the record survives. The dashed boundary means the agent cannot change the grader, its expected answers, or the final score; local unit tests remain available to help the agent develop its solution.

You can reuse the cases and assertions from the original unit tests. Some will need rewriting to exercise the system through its external interface instead of calling an internal function in the grader's process. Those checks may now be integration or behavioral tests; that is fine. Their job is to establish whether the task was completed.

A unit-test framework can still organize the protected grader's own checks. The problem is not the assertion library. It is giving candidate-controlled code authority over the verdict.

Observe the behavior the task actually requires

Suppose the task is to save a record durably. A response like {"saved": true} is a claim, not proof of persistence.

The outside grader can write a record, restart the candidate under controlled conditions, and check that the record can still be read. If the requirement includes a particular on-disk format or storage location, inspect that artifact with trusted code as well.

Different requirements need different observations. Matching a returned answer can establish a calculation's result. It cannot establish which internal function ran. If an implementation constraint matters, the grader needs evidence for that constraint too.

A separate process is only the beginning

Moving the tests out is useful only if the candidate cannot modify them, overwrite the score, or interfere with the grader's execution. Avoid shared writable paths that let the candidate change the evidence after it has been checked.

The observer must also remain independent. If it imports candidate code into its own process to perform a check, it can recreate the same problem inside the supposedly trusted grader. Run the candidate behind the boundary and treat its outputs as untrusted input.

Before relying on the result, test the setup with a working solution, a different valid solution, an implementation missing a required behavior, and one that merely prints a passing message. Confirm that the checks actually execute and that only the implementations satisfying the requirements earn credit. A grader crash should be identifiable as an evaluation failure, rather than silently becoming a passing score.

My recommendation

Keep local unit tests as a development aid. Extract the authoritative checks, expected results, and score-writing logic into a protected external grader.

When turning software into a task for post-training, extracting the problem is only part of the work. You also have to extract the authority to judge the answer. The candidate runs the system; the outside observer decides whether it worked.


Further reading: Anthropic's guide to agent evaluations distinguishes an agent's claims from the final state it produces. Harbor's separate-verifier guide documents running verification in a separate environment.