verifiers 0.4.2.dev57__py3-none-any.whl → 0.4.2.dev59__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- verifiers/v1/__init__.py +3 -3
- verifiers/v1/agent.py +3 -30
- verifiers/v1/cli/debug.py +3 -10
- verifiers/v1/cli/validate.py +1 -7
- verifiers/v1/configs/runtime.py +19 -10
- verifiers/v1/env.py +1 -19
- verifiers/v1/envs/agentic_judge/env.py +3 -8
- verifiers/v1/envs/best_of_n_judge/env.py +2 -13
- verifiers/v1/grading.py +4 -10
- verifiers/v1/harness.py +1 -7
- verifiers/v1/harnesses/bash/harness.py +0 -1
- verifiers/v1/harnesses/browser_use/harness.py +0 -1
- verifiers/v1/harnesses/null/harness.py +0 -1
- verifiers/v1/mcp/launch.py +39 -223
- verifiers/v1/mcp/packages.py +287 -0
- verifiers/v1/mcp/toolset.py +5 -5
- verifiers/v1/runtimes/__init__.py +3 -10
- verifiers/v1/runtimes/backends/cli.py +51 -0
- verifiers/v1/runtimes/backends/custom.py +7 -12
- verifiers/v1/runtimes/backends/docker.py +2 -13
- verifiers/v1/runtimes/backends/prime.py +0 -13
- verifiers/v1/runtimes/base.py +28 -53
- verifiers/v1/runtimes/runtime.py +2 -13
- verifiers/v1/runtimes/strategies.py +2 -2
- verifiers/v1/submission.py +4 -13
- verifiers/v1/task.py +1 -4
- verifiers/v1/tasksets/harbor/taskset.py +1 -5
- verifiers/v1/tasksets/nemo_gym/server.py +21 -8
- verifiers/v1/tasksets/nemo_gym/taskset.py +70 -30
- verifiers/v1/utils/artifacts.py +0 -7
- verifiers/v1/utils/compile.py +9 -62
- verifiers/v1/utils/git.py +1 -1
- {verifiers-0.4.2.dev57.dist-info → verifiers-0.4.2.dev59.dist-info}/METADATA +1 -1
- {verifiers-0.4.2.dev57.dist-info → verifiers-0.4.2.dev59.dist-info}/RECORD +37 -36
- verifiers/v1/runtimes/backends/subprocess.py +0 -223
- {verifiers-0.4.2.dev57.dist-info → verifiers-0.4.2.dev59.dist-info}/WHEEL +0 -0
- {verifiers-0.4.2.dev57.dist-info → verifiers-0.4.2.dev59.dist-info}/entry_points.txt +0 -0
- {verifiers-0.4.2.dev57.dist-info → verifiers-0.4.2.dev59.dist-info}/licenses/LICENSE +0 -0
verifiers/v1/__init__.py
CHANGED
|
@@ -47,7 +47,7 @@ if TYPE_CHECKING:
|
|
|
47
47
|
PrimeConfig,
|
|
48
48
|
PrimeVolume,
|
|
49
49
|
RuntimeConfig,
|
|
50
|
-
|
|
50
|
+
SandboxConfig,
|
|
51
51
|
)
|
|
52
52
|
from verifiers.v1.configs.sampling import Sampling, SamplingConfig
|
|
53
53
|
from verifiers.v1.configs.scoring import ScoringConfig
|
|
@@ -262,6 +262,7 @@ _NAME_TO_MODULE = {
|
|
|
262
262
|
"ModelRoute": "verifiers.v1.clients",
|
|
263
263
|
"RouteRejected": "verifiers.v1.clients",
|
|
264
264
|
"NetworkPolicyConfig": "verifiers.v1.configs.runtime",
|
|
265
|
+
"SandboxConfig": "verifiers.v1.configs.runtime",
|
|
265
266
|
"PATCH_CAP_BYTES": "verifiers.v1.utils.git",
|
|
266
267
|
"ParentLink": "verifiers.v1.semantic",
|
|
267
268
|
"PolicyEvent": "verifiers.v1.trace",
|
|
@@ -305,7 +306,6 @@ _NAME_TO_MODULE = {
|
|
|
305
306
|
"State": "verifiers.v1.state",
|
|
306
307
|
"StateT": "verifiers.v1.state",
|
|
307
308
|
"StopFunctionConfig": "verifiers.v1.configs.task",
|
|
308
|
-
"SubprocessConfig": "verifiers.v1.configs.runtime",
|
|
309
309
|
"SystemMessage": "verifiers.v1.types",
|
|
310
310
|
"TRACE_VERSION": "verifiers.v1.trace",
|
|
311
311
|
"Task": "verifiers.v1.task",
|
|
@@ -496,11 +496,11 @@ __all__ = [ # noqa: RUF022 - grouped by public API area
|
|
|
496
496
|
"RuntimeConfig",
|
|
497
497
|
"RuntimeInfo",
|
|
498
498
|
"ProgramResult",
|
|
499
|
-
"SubprocessConfig",
|
|
500
499
|
"DockerConfig",
|
|
501
500
|
"BindMount",
|
|
502
501
|
"CustomRuntimeConfig",
|
|
503
502
|
"NetworkPolicyConfig",
|
|
503
|
+
"SandboxConfig",
|
|
504
504
|
"PrimeConfig",
|
|
505
505
|
"PrimeVolume",
|
|
506
506
|
"Env",
|
verifiers/v1/agent.py
CHANGED
|
@@ -38,7 +38,6 @@ from verifiers.v1.rollout import Rollout, RolloutTimeouts
|
|
|
38
38
|
from verifiers.v1.runtimes import (
|
|
39
39
|
Runtime,
|
|
40
40
|
RuntimeConfig,
|
|
41
|
-
backend_cls,
|
|
42
41
|
provision_backend,
|
|
43
42
|
runtime_is_local,
|
|
44
43
|
)
|
|
@@ -96,16 +95,6 @@ def resolve_rollout_timeouts(timeout: TimeoutConfig, task: Task) -> RolloutTimeo
|
|
|
96
95
|
)
|
|
97
96
|
|
|
98
97
|
|
|
99
|
-
def _check_artifact_runtime(runtime_config: RuntimeConfig) -> None:
|
|
100
|
-
"""Artifact collection reads the task's paths out of the box, so the box needs a
|
|
101
|
-
filesystem of its own."""
|
|
102
|
-
if not backend_cls(runtime_config).SUPPORTS_TASK_IMAGES:
|
|
103
|
-
raise TypeError(
|
|
104
|
-
"artifact collection requires a runtime with its own filesystem; the "
|
|
105
|
-
f"{runtime_config.type} runtime cannot run images"
|
|
106
|
-
)
|
|
107
|
-
|
|
108
|
-
|
|
109
98
|
def _check_borrowed_placement(
|
|
110
99
|
task: Task, runtime: Runtime, base_config: RuntimeConfig
|
|
111
100
|
) -> None:
|
|
@@ -146,13 +135,7 @@ def _check_borrowed_placement(
|
|
|
146
135
|
)
|
|
147
136
|
if task.data.image is None:
|
|
148
137
|
return
|
|
149
|
-
|
|
150
|
-
raise TypeError(
|
|
151
|
-
f"task {task.data.idx!r} requires image {task.data.image!r}, but the "
|
|
152
|
-
f"borrowed {runtime.type} runtime cannot run images; borrow a container "
|
|
153
|
-
"box (e.g. agent.provision(task)) or drop the task's image"
|
|
154
|
-
)
|
|
155
|
-
box_image = getattr(runtime.config, "image", None)
|
|
138
|
+
box_image = runtime.config.image
|
|
156
139
|
if box_image != task.data.image:
|
|
157
140
|
logger.warning(
|
|
158
141
|
"Running task %s in borrowed box %s on its image - the task requires %s "
|
|
@@ -609,7 +592,6 @@ class Agent:
|
|
|
609
592
|
self.trainable: bool = True
|
|
610
593
|
self._entered = False
|
|
611
594
|
self._server: InterceptionServer | None = None
|
|
612
|
-
self._warned_resources: set[tuple[str, str]] = set()
|
|
613
595
|
|
|
614
596
|
async def __aenter__(self) -> Self:
|
|
615
597
|
if self._entered:
|
|
@@ -765,8 +747,6 @@ class Agent:
|
|
|
765
747
|
attempt: int,
|
|
766
748
|
) -> Trace:
|
|
767
749
|
params = self._rollout_params(task, runtime, dict(shared_tools or {}), route)
|
|
768
|
-
if collect_artifacts:
|
|
769
|
-
_check_artifact_runtime(params["runtime_config"])
|
|
770
750
|
run = Rollout(
|
|
771
751
|
task=task,
|
|
772
752
|
on_trace=on_trace,
|
|
@@ -835,8 +815,6 @@ class Agent:
|
|
|
835
815
|
params = self._rollout_params(
|
|
836
816
|
task, runtime, dict(tools or {}), route or ModelRoute(self.ctx)
|
|
837
817
|
)
|
|
838
|
-
if collect_artifacts:
|
|
839
|
-
_check_artifact_runtime(params["runtime_config"])
|
|
840
818
|
run = Rollout(
|
|
841
819
|
task=task,
|
|
842
820
|
has_user=True,
|
|
@@ -888,9 +866,7 @@ class Agent:
|
|
|
888
866
|
runtime_config = runtime.config
|
|
889
867
|
run_is_local = runtime.is_local
|
|
890
868
|
else:
|
|
891
|
-
runtime_config = resolve_runtime_config(
|
|
892
|
-
self.runtime_config, task, self._warned_resources
|
|
893
|
-
)
|
|
869
|
+
runtime_config = resolve_runtime_config(self.runtime_config, task)
|
|
894
870
|
run_is_local = runtime_is_local(runtime_config)
|
|
895
871
|
validate_pairing(
|
|
896
872
|
harness,
|
|
@@ -916,7 +892,7 @@ class Agent:
|
|
|
916
892
|
"""Provision (and on exit tear down) a box from this agent's runtime
|
|
917
893
|
policy, resolved for `task` when given; share it via `run(..., runtime=runtime)`."""
|
|
918
894
|
config = (
|
|
919
|
-
resolve_runtime_config(self.runtime_config, task
|
|
895
|
+
resolve_runtime_config(self.runtime_config, task)
|
|
920
896
|
if task is not None
|
|
921
897
|
else self.runtime_config
|
|
922
898
|
)
|
|
@@ -947,11 +923,8 @@ class _EpisodeAgent(Agent):
|
|
|
947
923
|
completed: list[Trace],
|
|
948
924
|
on_trace: Callable[[Trace], None] | None,
|
|
949
925
|
on_discard: Callable[[Trace], None] | None,
|
|
950
|
-
warned_resources: set,
|
|
951
926
|
) -> None:
|
|
952
927
|
super().__init__(config, interception=interception)
|
|
953
|
-
# Resource warnings dedupe env-wide, not per episode.
|
|
954
|
-
self._warned_resources = warned_resources
|
|
955
928
|
self._name = name
|
|
956
929
|
self._shared_tools = shared_tools
|
|
957
930
|
self._task_cls = task_cls
|
verifiers/v1/cli/debug.py
CHANGED
|
@@ -39,7 +39,7 @@ logger = get_logger(__name__)
|
|
|
39
39
|
|
|
40
40
|
USAGE = (
|
|
41
41
|
"usage: uv run vf-debug [<taskset-id>] (--command <cmd> | --script-path <path>) "
|
|
42
|
-
"[--runtime.type
|
|
42
|
+
"[--runtime.type docker] [options] [@ file.toml]\n"
|
|
43
43
|
" runs setup, then one command or uploaded host script, and saves traces"
|
|
44
44
|
)
|
|
45
45
|
|
|
@@ -173,9 +173,8 @@ async def run_action(runtime: Runtime, config: DebugConfig) -> dict[str, Any]:
|
|
|
173
173
|
**(await run_timed(runtime.run(["sh", "-lc", config.command], {}), config)),
|
|
174
174
|
}
|
|
175
175
|
assert config.script_path is not None
|
|
176
|
-
#
|
|
177
|
-
#
|
|
178
|
-
# the subprocess runtime, where an absolute path is a host path.
|
|
176
|
+
# Keep the script outside the task workdir so it doesn't appear in the repo
|
|
177
|
+
# state being inspected; the runtime name separates concurrent runs.
|
|
179
178
|
remote_path = f"/tmp/{runtime.name}-script.sh"
|
|
180
179
|
quoted = shlex.quote(remote_path)
|
|
181
180
|
command = f"chmod +x {quoted} && {quoted}"
|
|
@@ -275,12 +274,6 @@ async def run_debug(config: DebugConfig) -> list[Trace]:
|
|
|
275
274
|
f"{type(taskset).__name__} is infinite - bound the run with -n"
|
|
276
275
|
)
|
|
277
276
|
tasks = list(taskset)
|
|
278
|
-
if isinstance(config.runtime, vf.SubprocessConfig) and any(
|
|
279
|
-
type(t).NEEDS_CONTAINER or t.data.image for t in tasks
|
|
280
|
-
):
|
|
281
|
-
raise SystemExit(
|
|
282
|
-
"taskset needs a container runtime to debug - pass --runtime.type docker (or prime)"
|
|
283
|
-
)
|
|
284
277
|
|
|
285
278
|
out = output_path(config)
|
|
286
279
|
save_config(config, out, "debug.json")
|
verifiers/v1/cli/validate.py
CHANGED
|
@@ -63,7 +63,7 @@ ResultRow = dict[str, Any]
|
|
|
63
63
|
|
|
64
64
|
USAGE = (
|
|
65
65
|
"usage: uv run vf-validate [<taskset-id>] [--only-setup | --only-gold | --only-noop] "
|
|
66
|
-
"[-o <output-dir>] [--runtime.type
|
|
66
|
+
"[-o <output-dir>] [--runtime.type docker] [options] [@ file.toml]\n"
|
|
67
67
|
" uv run vf-validate @ <run-dir>/configs/validate.json --resume (re-run missing/errored/timed-out tasks)\n"
|
|
68
68
|
" runs persisted gold and noop (untouched scoring) checks per task (no agent)"
|
|
69
69
|
)
|
|
@@ -448,12 +448,6 @@ async def run_validate(config: ValidateConfig) -> list[dict]:
|
|
|
448
448
|
f"{type(taskset).__name__} is infinite - bound the run with -n"
|
|
449
449
|
)
|
|
450
450
|
tasks = list(taskset)
|
|
451
|
-
if isinstance(config.runtime, vf.SubprocessConfig) and any(
|
|
452
|
-
type(t).NEEDS_CONTAINER or t.data.image for t in tasks
|
|
453
|
-
):
|
|
454
|
-
raise SystemExit(
|
|
455
|
-
"taskset needs a container runtime to validate - pass --runtime.type docker (or prime)"
|
|
456
|
-
)
|
|
457
451
|
mode = validation_mode(config)
|
|
458
452
|
checks = "gold+noop" if mode == "all" else mode
|
|
459
453
|
out = output_path(config)
|
verifiers/v1/configs/runtime.py
CHANGED
|
@@ -152,17 +152,28 @@ class NetworkPolicyConfig(BaseConfig):
|
|
|
152
152
|
return type(self).model_validate({**values, "allow": allow, "block": block})
|
|
153
153
|
|
|
154
154
|
|
|
155
|
-
class
|
|
156
|
-
|
|
155
|
+
class SandboxConfig(BaseConfig):
|
|
156
|
+
"""What every runtime provisions: a task image with a working directory and the
|
|
157
|
+
resources `TaskData.resources` requests. Network policy support is declared by also
|
|
158
|
+
inheriting `NetworkPolicyConfig`."""
|
|
157
159
|
|
|
158
|
-
|
|
159
|
-
class DockerConfig(NetworkPolicyConfig):
|
|
160
|
-
type: Literal["docker"] = "docker"
|
|
161
160
|
image: str = "python:3.11-slim"
|
|
162
161
|
workdir: str | None = None
|
|
163
162
|
"""Working directory override; None uses the task's workdir, or /app."""
|
|
164
163
|
# TaskData.resources uses these units; non-default runtime config values take precedence.
|
|
165
164
|
cpu: float | None = None
|
|
165
|
+
"""CPU cores. None = the provider's default."""
|
|
166
|
+
memory: float | None = None
|
|
167
|
+
"""Memory limit in GB. None = the provider's default."""
|
|
168
|
+
gpu: str | None = None
|
|
169
|
+
"""GPU spec, e.g. "A100" or "A100:2" (a bare count = provider-chosen type)."""
|
|
170
|
+
disk: float | None = None
|
|
171
|
+
"""Disk in GB. None = the provider's default."""
|
|
172
|
+
|
|
173
|
+
|
|
174
|
+
class DockerConfig(SandboxConfig, NetworkPolicyConfig):
|
|
175
|
+
type: Literal["docker"] = "docker"
|
|
176
|
+
cpu: float | None = None
|
|
166
177
|
"""Pin the container to this many CPU cores. None = unlimited."""
|
|
167
178
|
memory: float | None = None
|
|
168
179
|
"""Hard memory limit in GB. None = unlimited."""
|
|
@@ -189,15 +200,13 @@ class PrimeVolume(BaseConfig):
|
|
|
189
200
|
read_only: bool = True
|
|
190
201
|
|
|
191
202
|
|
|
192
|
-
class PrimeConfig(NetworkPolicyConfig):
|
|
203
|
+
class PrimeConfig(SandboxConfig, NetworkPolicyConfig):
|
|
193
204
|
type: Literal["prime"] = "prime"
|
|
194
205
|
image: str = "python:3.11-slim"
|
|
195
206
|
"""Docker image to run. Any pullable ref works: on the first use of an image, the
|
|
196
207
|
platform auto-builds the VM image that the sandbox needs from it (~10 minutes)
|
|
197
208
|
and caches the result, so later sandboxes on the same ref start in
|
|
198
209
|
seconds."""
|
|
199
|
-
workdir: str | None = None
|
|
200
|
-
"""Working directory override; None uses the task's workdir, or /app."""
|
|
201
210
|
region: str | None = None
|
|
202
211
|
"""Region to provision in (None = provider-chosen)."""
|
|
203
212
|
labels: list[str] = Field(default_factory=list)
|
|
@@ -246,7 +255,7 @@ class PrimeConfig(NetworkPolicyConfig):
|
|
|
246
255
|
return self
|
|
247
256
|
|
|
248
257
|
|
|
249
|
-
class CustomRuntimeConfig(
|
|
258
|
+
class CustomRuntimeConfig(SandboxConfig):
|
|
250
259
|
type: Literal["custom"] = "custom"
|
|
251
260
|
import_path: str
|
|
252
261
|
"""Dotted path to a `RuntimeBackend` subclass, e.g. `my_package.runtime.MyBackend`."""
|
|
@@ -275,7 +284,7 @@ class CustomRuntimeConfig(BaseConfig):
|
|
|
275
284
|
# Serialized by the runtime type, so a custom runtime's typed config keeps its fields.
|
|
276
285
|
RuntimeConfig = SerializeAsAny[
|
|
277
286
|
Annotated[
|
|
278
|
-
|
|
287
|
+
DockerConfig | PrimeConfig | CustomRuntimeConfig,
|
|
279
288
|
Field(discriminator="type"),
|
|
280
289
|
]
|
|
281
290
|
]
|
verifiers/v1/env.py
CHANGED
|
@@ -30,7 +30,7 @@ from verifiers.v1.interception import (
|
|
|
30
30
|
requires_tunnel,
|
|
31
31
|
)
|
|
32
32
|
from verifiers.v1.mcp import SharedToolServer, serve_shared
|
|
33
|
-
from verifiers.v1.runtimes import
|
|
33
|
+
from verifiers.v1.runtimes import runtime_is_local
|
|
34
34
|
from verifiers.v1.task import Task
|
|
35
35
|
from verifiers.v1.trace import Error, Trace, TraceTask
|
|
36
36
|
from verifiers.v1.utils.format import format_time
|
|
@@ -131,27 +131,10 @@ class Env(ABC, Generic[ConfigT]):
|
|
|
131
131
|
if key not in loaded:
|
|
132
132
|
loaded[key] = load_harness(cfg)
|
|
133
133
|
self._harnesses[name] = loaded[key]
|
|
134
|
-
warned: set[str] = set()
|
|
135
|
-
for name, harness in self._harnesses.items():
|
|
136
|
-
# Warn once per distinct harness; tool-less chat loops are exempt.
|
|
137
|
-
if (
|
|
138
|
-
harness.EXECUTES_CODE
|
|
139
|
-
and isinstance(self._agent_specs[name].runtime, SubprocessConfig)
|
|
140
|
-
and harness.config.id not in warned
|
|
141
|
-
):
|
|
142
|
-
warned.add(harness.config.id)
|
|
143
|
-
logger.warning(
|
|
144
|
-
"Harness %r is running in the subprocess runtime on the local system. "
|
|
145
|
-
"Local files and settings may affect the evaluation; use subprocess only "
|
|
146
|
-
"for debugging. Use --env.<role>.runtime.type docker or prime "
|
|
147
|
-
"for an isolated run.",
|
|
148
|
-
harness.config.id,
|
|
149
|
-
)
|
|
150
134
|
# Serving resources, live only inside `serving()`; the env's agents borrow them.
|
|
151
135
|
self._shared_tools: dict[str, SharedToolServer] = {}
|
|
152
136
|
self._interception: Interception | None = None
|
|
153
137
|
# Resource warnings dedupe env-wide (agents are per-episode).
|
|
154
|
-
self._warned_resources: set = set()
|
|
155
138
|
|
|
156
139
|
# --- the multi-agent surface (override these) ------------------------------
|
|
157
140
|
|
|
@@ -231,7 +214,6 @@ class Env(ABC, Generic[ConfigT]):
|
|
|
231
214
|
completed=completed,
|
|
232
215
|
on_trace=on_trace,
|
|
233
216
|
on_discard=on_discard,
|
|
234
|
-
warned_resources=self._warned_resources,
|
|
235
217
|
)
|
|
236
218
|
|
|
237
219
|
agents = Agents(self.config, make)
|
|
@@ -117,10 +117,7 @@ HINT_SECTION = """\
|
|
|
117
117
|
class JudgeTask(vf.Task):
|
|
118
118
|
"""The judge's verdict task: the solver task's world mirrored onto the minted
|
|
119
119
|
row, the trace record written (and any stale verdict removed) before the
|
|
120
|
-
judge starts, verdict scraped off the live box after it exits.
|
|
121
|
-
keeps `Agent.run`'s per-task backstop aligned with the judge's declared need."""
|
|
122
|
-
|
|
123
|
-
NEEDS_CONTAINER = True
|
|
120
|
+
judge starts, verdict scraped off the live box after it exits."""
|
|
124
121
|
|
|
125
122
|
def __init__(
|
|
126
123
|
self,
|
|
@@ -275,8 +272,8 @@ class AgenticJudgeEnv(vf.Env[AgenticJudgeEnvConfig]):
|
|
|
275
272
|
config.task.criteria()
|
|
276
273
|
|
|
277
274
|
def _check_agents(self) -> None:
|
|
278
|
-
"""
|
|
279
|
-
|
|
275
|
+
"""Refuse an impossible judge at construction, not after burning a full
|
|
276
|
+
solver run."""
|
|
280
277
|
judge = self._harnesses["judge"]
|
|
281
278
|
if not judge.EXECUTES_CODE:
|
|
282
279
|
raise ValueError(
|
|
@@ -317,8 +314,6 @@ class AgenticJudgeEnv(vf.Env[AgenticJudgeEnvConfig]):
|
|
|
317
314
|
workspace = (
|
|
318
315
|
policy.runtime if policy.mode == "isolated" else None
|
|
319
316
|
) or self.config.solver.runtime
|
|
320
|
-
if isinstance(workspace, vf.SubprocessConfig):
|
|
321
|
-
raise TypeError("agentic judging requires a container scoring workspace")
|
|
322
317
|
validate_pairing(self._harnesses["judge"], JudgeTask, workspace)
|
|
323
318
|
|
|
324
319
|
async def judge(solution: vf.Trace, runtime: vf.Runtime) -> None:
|
|
@@ -25,7 +25,6 @@ from verifiers.v1.envs.agentic_judge.env import (
|
|
|
25
25
|
TextSource,
|
|
26
26
|
)
|
|
27
27
|
from verifiers.v1.envs.best_of_n import BestOfNEnv, BestOfNEnvConfig
|
|
28
|
-
from verifiers.v1.runtimes import backend_cls
|
|
29
28
|
from verifiers.v1.utils.artifacts import _validate_restore
|
|
30
29
|
|
|
31
30
|
ATTEMPTS_DIR = "/tmp/attempts"
|
|
@@ -120,9 +119,7 @@ class Ranking(BaseModel):
|
|
|
120
119
|
class RankTask(vf.Task):
|
|
121
120
|
"""One judge's ranking task: every attempt's record and artifacts uploaded
|
|
122
121
|
under its label before the judge starts, the ranking scraped off the box after
|
|
123
|
-
it exits.
|
|
124
|
-
|
|
125
|
-
NEEDS_CONTAINER = True
|
|
122
|
+
it exits."""
|
|
126
123
|
|
|
127
124
|
def __init__(self, data: vf.TaskData, labels: dict[str, vf.Trace]) -> None:
|
|
128
125
|
super().__init__(data)
|
|
@@ -246,23 +243,15 @@ class BestOfNJudgeEnv(BestOfNEnv, vf.Env[BestOfNJudgeEnvConfig]):
|
|
|
246
243
|
"best-of-n-judge requires a judge harness that can execute code, but "
|
|
247
244
|
f"harness {judge.config.id!r} is a tool-less chat loop"
|
|
248
245
|
)
|
|
249
|
-
if not backend_cls(config.judge.runtime).SUPPORTS_TASK_IMAGES:
|
|
250
|
-
raise ValueError(
|
|
251
|
-
"best-of-n-judge requires a container judge runtime: "
|
|
252
|
-
"--env.judge.runtime.type docker|prime"
|
|
253
|
-
)
|
|
254
246
|
|
|
255
247
|
async def setup(self, agents: vf.Agents) -> None:
|
|
256
248
|
# The judges grade the policy; their tokens are never training data.
|
|
257
249
|
agents.judge.trainable = False
|
|
258
250
|
|
|
259
251
|
async def run(self, task: vf.Task, agents: vf.Agents) -> None:
|
|
260
|
-
# Artifacts need a runtime with its own filesystem; a subprocess attempt
|
|
261
|
-
# is ranked on its trace alone.
|
|
262
|
-
collect = backend_cls(self.config.agent.runtime).SUPPORTS_TASK_IMAGES
|
|
263
252
|
async with asyncio.TaskGroup() as tg:
|
|
264
253
|
runs = [
|
|
265
|
-
tg.create_task(agents.agent.run(task, collect_artifacts=
|
|
254
|
+
tg.create_task(agents.agent.run(task, collect_artifacts=True))
|
|
266
255
|
for _ in range(self.config.n)
|
|
267
256
|
]
|
|
268
257
|
attempts = [run.result() for run in runs]
|
verifiers/v1/grading.py
CHANGED
|
@@ -13,7 +13,6 @@ from verifiers.v1.runtimes import (
|
|
|
13
13
|
PrimeConfig,
|
|
14
14
|
Runtime,
|
|
15
15
|
RuntimeConfig,
|
|
16
|
-
backend_cls,
|
|
17
16
|
)
|
|
18
17
|
from verifiers.v1.task import Task
|
|
19
18
|
from verifiers.v1.trace import Error, Trace
|
|
@@ -57,26 +56,21 @@ def verifier_runtime(
|
|
|
57
56
|
# A task without its own image/workdir inherits the actual workspace's values,
|
|
58
57
|
# including a Compose image or split execution configuration.
|
|
59
58
|
task = task.with_data(
|
|
60
|
-
image=task.data.image or
|
|
61
|
-
workdir=task.data.workdir or
|
|
59
|
+
image=task.data.image or solver_runtime.config.image,
|
|
60
|
+
workdir=task.data.workdir or solver_runtime.config.workdir,
|
|
62
61
|
)
|
|
63
62
|
if policy.network is not None:
|
|
64
63
|
task = task.with_data(network=policy.network)
|
|
65
64
|
config = resolve_runtime_config(source, task)
|
|
66
65
|
if policy.runtime is not None and "image" in policy.runtime.model_fields_set:
|
|
67
66
|
config = config.model_copy(update={"image": policy.runtime.image})
|
|
68
|
-
if not backend_cls(config).SUPPORTS_TASK_IMAGES:
|
|
69
|
-
raise TaskError(
|
|
70
|
-
f"isolated verification requires an isolated filesystem; the "
|
|
71
|
-
f"{config.type} runtime cannot run images"
|
|
72
|
-
)
|
|
73
67
|
relative = [
|
|
74
68
|
a.source
|
|
75
69
|
for a in task.data.artifacts
|
|
76
70
|
if not PurePosixPath(a.source).is_absolute()
|
|
77
71
|
]
|
|
78
|
-
solver_dir = PurePosixPath(
|
|
79
|
-
grader_dir = PurePosixPath(
|
|
72
|
+
solver_dir = PurePosixPath(solver_runtime.config.workdir or "/app")
|
|
73
|
+
grader_dir = PurePosixPath(config.workdir or "/app")
|
|
80
74
|
if relative and solver_dir != grader_dir:
|
|
81
75
|
raise TaskError(
|
|
82
76
|
f"cannot restore relative artifacts {relative!r} from {solver_dir} into {grader_dir}; use matching workdirs or absolute paths"
|
verifiers/v1/harness.py
CHANGED
|
@@ -56,17 +56,11 @@ class Harness(ABC, Generic[ConfigT]):
|
|
|
56
56
|
EXECUTES_CODE: ClassVar[bool] = True
|
|
57
57
|
"""Whether the program hands the model local execution in the runtime — true for
|
|
58
58
|
every real harness; the tool-less chat loops (`null`) override to False. Read
|
|
59
|
-
where model-directed execution changes the rules
|
|
60
|
-
warning, the judge env's sandbox requirement."""
|
|
59
|
+
where model-directed execution changes the rules, e.g. the judge envs."""
|
|
61
60
|
SUPPORTS_SKILLS: ClassVar[bool] = False
|
|
62
61
|
"""Whether the program discovers SKILL.md skills — it calls
|
|
63
62
|
`install_skills` with a run-scoped discovery location; configuring
|
|
64
63
|
`skills` on a harness without support is rejected up front."""
|
|
65
|
-
NEEDS_CONTAINER: ClassVar[bool] = True
|
|
66
|
-
"""Whether the program must run in a container runtime: True for every harness
|
|
67
|
-
that installs and drives a third-party program — on the host (subprocess) it
|
|
68
|
-
leaks host state (auth, config, processes) both ways. Only the minimal
|
|
69
|
-
in-house loops (`bash`, `null`) override to False."""
|
|
70
64
|
|
|
71
65
|
def __init__(self, config: ConfigT) -> None:
|
|
72
66
|
self.config = config
|
|
@@ -53,7 +53,6 @@ class BashHarness(Harness[BashHarnessConfig]):
|
|
|
53
53
|
SUPPORTS_MCP = True
|
|
54
54
|
SUPPORTS_RESUME = True
|
|
55
55
|
SUPPORTS_TOOL_INTERCEPTION = True
|
|
56
|
-
NEEDS_CONTAINER = False
|
|
57
56
|
|
|
58
57
|
async def setup(self, runtime: Runtime) -> None:
|
|
59
58
|
await runtime.prepare_uv_script(CHAT_PROGRAM_SOURCE, self.config.resolved_env)
|
|
@@ -57,7 +57,6 @@ class BrowserUseHarness(Harness[BrowserUseHarnessConfig]):
|
|
|
57
57
|
SUPPORTS_MCP = True
|
|
58
58
|
SUPPORTS_RESUME = True
|
|
59
59
|
# The browser tool executes model-authored Python through a third-party daemon.
|
|
60
|
-
NEEDS_CONTAINER = True
|
|
61
60
|
|
|
62
61
|
async def setup(self, runtime: Runtime) -> None:
|
|
63
62
|
await runtime.prepare_uv_script(PROGRAM_SOURCE, self.config.resolved_env)
|
|
@@ -28,7 +28,6 @@ class NullHarness(Harness[NullHarnessConfig]):
|
|
|
28
28
|
SUPPORTS_RESUME = True
|
|
29
29
|
SUPPORTS_TOOL_INTERCEPTION = True
|
|
30
30
|
EXECUTES_CODE = False
|
|
31
|
-
NEEDS_CONTAINER = False
|
|
32
31
|
|
|
33
32
|
async def setup(self, runtime: Runtime) -> None:
|
|
34
33
|
await runtime.prepare_uv_script(CHAT_PROGRAM_SOURCE, self.config.resolved_env)
|