verifiers 0.4.2.dev4__py3-none-any.whl → 0.4.2.dev6__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/agent.py +19 -4
- verifiers/v1/env.py +16 -1
- verifiers/v1/episode.py +3 -0
- verifiers/v1/rollout.py +4 -0
- verifiers/v1/runtimes/backends/subprocess.py +5 -2
- verifiers/v1/trace.py +3 -1
- verifiers/v1/utils/retries.py +4 -4
- {verifiers-0.4.2.dev4.dist-info → verifiers-0.4.2.dev6.dist-info}/METADATA +2 -2
- {verifiers-0.4.2.dev4.dist-info → verifiers-0.4.2.dev6.dist-info}/RECORD +12 -12
- {verifiers-0.4.2.dev4.dist-info → verifiers-0.4.2.dev6.dist-info}/WHEEL +0 -0
- {verifiers-0.4.2.dev4.dist-info → verifiers-0.4.2.dev6.dist-info}/entry_points.txt +0 -0
- {verifiers-0.4.2.dev4.dist-info → verifiers-0.4.2.dev6.dist-info}/licenses/LICENSE +0 -0
verifiers/v1/agent.py
CHANGED
|
@@ -9,6 +9,7 @@ server; un-entered, each run brings its own."""
|
|
|
9
9
|
|
|
10
10
|
import asyncio
|
|
11
11
|
import logging
|
|
12
|
+
import uuid
|
|
12
13
|
from collections.abc import AsyncIterator, Awaitable, Callable, Mapping
|
|
13
14
|
from contextlib import asynccontextmanager, nullcontext
|
|
14
15
|
from contextvars import ContextVar
|
|
@@ -675,7 +676,8 @@ class Agent:
|
|
|
675
676
|
moment it's minted, before any I/O. `collect_artifacts` captures the task's
|
|
676
677
|
declared artifacts after its finalizer while its container runtime is still
|
|
677
678
|
alive. Retries whole while the trace ends with a retryable error
|
|
678
|
-
(`config.retries`) — never into a borrowed box;
|
|
679
|
+
(`config.retries`) — never into a borrowed box; every attempt's trace keeps
|
|
680
|
+
the run's id with its own `attempt`, and the final trace keeps earlier
|
|
679
681
|
attempts' errors. `on_score(trace, runtime)` runs after task scoring in
|
|
680
682
|
the selected verifier workspace, inside its timeout and retry boundary."""
|
|
681
683
|
if self._closed:
|
|
@@ -683,9 +685,17 @@ class Agent:
|
|
|
683
685
|
retry = self.config.retries
|
|
684
686
|
retry_state = RetryState(retry)
|
|
685
687
|
history: list = []
|
|
688
|
+
trace_id = uuid.uuid4().hex
|
|
686
689
|
for attempt in range(retry_state.max_retries + 1):
|
|
687
690
|
trace = await self._run_once(
|
|
688
|
-
task,
|
|
691
|
+
task,
|
|
692
|
+
runtime,
|
|
693
|
+
tools,
|
|
694
|
+
on_trace,
|
|
695
|
+
collect_artifacts,
|
|
696
|
+
on_score,
|
|
697
|
+
trace_id=trace_id,
|
|
698
|
+
attempt=attempt + 1,
|
|
689
699
|
)
|
|
690
700
|
if attempt == retry_state.max_retries or trace.ok:
|
|
691
701
|
break
|
|
@@ -722,6 +732,9 @@ class Agent:
|
|
|
722
732
|
on_trace: Callable[[Trace], None] | None,
|
|
723
733
|
collect_artifacts: bool,
|
|
724
734
|
on_score: Callable[[Trace, Runtime], Awaitable[None]] | None,
|
|
735
|
+
*,
|
|
736
|
+
trace_id: str,
|
|
737
|
+
attempt: int,
|
|
725
738
|
) -> Trace:
|
|
726
739
|
params = self._rollout_params(task, runtime, dict(shared_tools or {}))
|
|
727
740
|
if (
|
|
@@ -737,6 +750,8 @@ class Agent:
|
|
|
737
750
|
on_trace=on_trace,
|
|
738
751
|
collect_artifacts=collect_artifacts,
|
|
739
752
|
on_score=on_score,
|
|
753
|
+
trace_id=trace_id,
|
|
754
|
+
attempt=attempt,
|
|
740
755
|
**params,
|
|
741
756
|
)
|
|
742
757
|
try:
|
|
@@ -921,8 +936,8 @@ class _EpisodeAgent(Agent):
|
|
|
921
936
|
if trace.agent is not None:
|
|
922
937
|
trace.agent.name = self._name
|
|
923
938
|
trace.agent.trainable = self.trainable
|
|
924
|
-
# A per-agent retry
|
|
925
|
-
# must leave live views (only the final one joins the episode).
|
|
939
|
+
# A per-agent retry replaces the trace under the same id: the abandoned
|
|
940
|
+
# attempt must leave live views (only the final one joins the episode).
|
|
926
941
|
if last is not None and self._on_discard is not None:
|
|
927
942
|
self._on_discard(last)
|
|
928
943
|
last = trace
|
verifiers/v1/env.py
CHANGED
|
@@ -4,6 +4,7 @@ import asyncio
|
|
|
4
4
|
import contextlib
|
|
5
5
|
import logging
|
|
6
6
|
import traceback
|
|
7
|
+
import uuid
|
|
7
8
|
from abc import ABC, abstractmethod
|
|
8
9
|
from collections.abc import Awaitable, Callable
|
|
9
10
|
from dataclasses import dataclass, field
|
|
@@ -58,6 +59,8 @@ class RunSlot:
|
|
|
58
59
|
at dispatch so the slot still reads as running."""
|
|
59
60
|
|
|
60
61
|
task: Task
|
|
62
|
+
id: str = field(default_factory=lambda: uuid.uuid4().hex)
|
|
63
|
+
"""The episode's id. Stable across retries."""
|
|
61
64
|
traces: list[Trace] = field(default_factory=list)
|
|
62
65
|
episode: Episode | None = None
|
|
63
66
|
done: bool = False
|
|
@@ -67,6 +70,7 @@ class RunSlot:
|
|
|
67
70
|
def finished(cls, episode: Episode) -> "RunSlot":
|
|
68
71
|
return cls(
|
|
69
72
|
task=Task(episode.task.data),
|
|
73
|
+
id=episode.id,
|
|
70
74
|
traces=list(episode.traces),
|
|
71
75
|
episode=episode,
|
|
72
76
|
done=True,
|
|
@@ -238,6 +242,8 @@ class Env(ABC, Generic[ConfigT]):
|
|
|
238
242
|
*,
|
|
239
243
|
on_trace: Callable[[Trace], None] | None = None,
|
|
240
244
|
on_discard: Callable[[Trace], None] | None = None,
|
|
245
|
+
episode_id: str | None = None,
|
|
246
|
+
attempt: int = 1,
|
|
241
247
|
) -> Episode:
|
|
242
248
|
"""One episode of `task`, minted as the wire atom: `setup()` then `run()`
|
|
243
249
|
over fresh agents, then `finalize()`. Its agents run one at a time
|
|
@@ -246,8 +252,11 @@ class Env(ABC, Generic[ConfigT]):
|
|
|
246
252
|
Traces join the episode as runs complete — a hook raising mid-way yields the
|
|
247
253
|
completed subset, its exception on the episode's `errors`. `on_trace` observes
|
|
248
254
|
each agent-run's trace at mint; `on_discard` its abandonment (a per-agent
|
|
249
|
-
retry
|
|
255
|
+
retry replaces it). `episode_id` and `attempt` place a retry under the
|
|
256
|
+
episode it repeats."""
|
|
250
257
|
episode = Episode(
|
|
258
|
+
**({"id": episode_id} if episode_id is not None else {}),
|
|
259
|
+
attempt=attempt,
|
|
251
260
|
env=EnvInfo(id=self.config.env_id),
|
|
252
261
|
task=TraceTask(
|
|
253
262
|
type=type(task).__name__,
|
|
@@ -319,7 +328,11 @@ class Env(ABC, Generic[ConfigT]):
|
|
|
319
328
|
`on_complete` (the runners' persistence hook, which fires when final).
|
|
320
329
|
`on_trace` sees each trace at mint, after it joined `slot.traces`."""
|
|
321
330
|
|
|
331
|
+
attempts = 0
|
|
332
|
+
|
|
322
333
|
async def attempt() -> Episode:
|
|
334
|
+
nonlocal attempts
|
|
335
|
+
attempts += 1
|
|
323
336
|
slot.traces = [] # a retry shows the fresh attempt's traces
|
|
324
337
|
live = slot.traces
|
|
325
338
|
|
|
@@ -339,6 +352,8 @@ class Env(ABC, Generic[ConfigT]):
|
|
|
339
352
|
ctx,
|
|
340
353
|
on_trace=minted,
|
|
341
354
|
on_discard=discard,
|
|
355
|
+
episode_id=slot.id,
|
|
356
|
+
attempt=attempts,
|
|
342
357
|
)
|
|
343
358
|
|
|
344
359
|
episode = await run_episode_with_retry(attempt, self.config.retries)
|
verifiers/v1/episode.py
CHANGED
|
@@ -46,6 +46,9 @@ class Episode(BaseModel, Generic[DataT, StateT, AgentConfigT]):
|
|
|
46
46
|
"""The artifact Env.run produces. Contains multiple agents' traces."""
|
|
47
47
|
|
|
48
48
|
id: str = Field(default_factory=lambda: uuid.uuid4().hex)
|
|
49
|
+
"""Unique ID for this episode, auto-generated. Stable across retries."""
|
|
50
|
+
attempt: int = 1
|
|
51
|
+
"""Which attempt of the episode this is, from 1."""
|
|
49
52
|
|
|
50
53
|
env: EnvInfo = Field(default_factory=EnvInfo)
|
|
51
54
|
"""The env that produced this episode."""
|
verifiers/v1/rollout.py
CHANGED
|
@@ -115,6 +115,8 @@ class Rollout:
|
|
|
115
115
|
on_trace: Callable[[Trace], None] | None = None,
|
|
116
116
|
collect_artifacts: bool = False,
|
|
117
117
|
on_score: Callable[[Trace, Runtime], Awaitable[None]] | None = None,
|
|
118
|
+
trace_id: str | None = None,
|
|
119
|
+
attempt: int = 1,
|
|
118
120
|
) -> None:
|
|
119
121
|
self._on_score = on_score
|
|
120
122
|
self.task = task
|
|
@@ -136,6 +138,8 @@ class Rollout:
|
|
|
136
138
|
self._borrowed_runtime = runtime
|
|
137
139
|
self._collect_artifacts = collect_artifacts
|
|
138
140
|
self.trace: Trace = Trace(
|
|
141
|
+
**({"id": trace_id} if trace_id is not None else {}),
|
|
142
|
+
attempt=attempt,
|
|
139
143
|
task=TraceTask(
|
|
140
144
|
type=type(task).__name__,
|
|
141
145
|
data=task.data,
|
|
@@ -8,6 +8,7 @@ import os
|
|
|
8
8
|
import shutil
|
|
9
9
|
import signal
|
|
10
10
|
import stat
|
|
11
|
+
import tempfile
|
|
11
12
|
from collections.abc import AsyncIterator
|
|
12
13
|
from pathlib import Path
|
|
13
14
|
from typing import ClassVar
|
|
@@ -99,8 +100,10 @@ class SubprocessBackend(RuntimeBackend):
|
|
|
99
100
|
self._children: list[asyncio.subprocess.Process] = []
|
|
100
101
|
|
|
101
102
|
async def start(self) -> None:
|
|
102
|
-
|
|
103
|
-
|
|
103
|
+
root = CACHE_DIR / "runtimes" / "subprocess"
|
|
104
|
+
root.mkdir(parents=True, exist_ok=True)
|
|
105
|
+
# Names repeat across retries, and a failed teardown can leave a workdir behind.
|
|
106
|
+
self.workdir = Path(tempfile.mkdtemp(prefix=f"{self.name}-", dir=root))
|
|
104
107
|
self.info.id = str(self.workdir)
|
|
105
108
|
|
|
106
109
|
async def run(
|
verifiers/v1/trace.py
CHANGED
|
@@ -576,7 +576,9 @@ class Trace(BaseModel, Generic[DataT, StateT, AgentConfigT]):
|
|
|
576
576
|
version: int = TRACE_VERSION
|
|
577
577
|
"""The trace schema this trace serializes as."""
|
|
578
578
|
id: str = Field(default_factory=lambda: uuid.uuid4().hex)
|
|
579
|
-
"""Unique ID for this
|
|
579
|
+
"""Unique ID for this agent run, auto-generated. Stable across retries."""
|
|
580
|
+
attempt: int = 1
|
|
581
|
+
"""Which attempt of the agent run this trace records, from 1."""
|
|
580
582
|
verifiers: VersionInfo = Field(default_factory=_current_build)
|
|
581
583
|
"""The verifiers version that produced this trace."""
|
|
582
584
|
task: TraceTask[DataT]
|
verifiers/v1/utils/retries.py
CHANGED
|
@@ -121,10 +121,10 @@ async def run_episode_with_retry(
|
|
|
121
121
|
run: Callable[[], Awaitable[Episode]],
|
|
122
122
|
retry: RetryConfig,
|
|
123
123
|
) -> Episode:
|
|
124
|
-
"""Run one episode (each attempt
|
|
125
|
-
it ends with a retryable error. When the final attempt fails
|
|
126
|
-
attempts' errors are prepended so the episode shows the full
|
|
127
|
-
good attempt returns clean."""
|
|
124
|
+
"""Run one episode (each attempt builds a fresh one under the same id),
|
|
125
|
+
retrying while it ends with a retryable error. When the final attempt fails
|
|
126
|
+
too, the earlier attempts' errors are prepended so the episode shows the full
|
|
127
|
+
history; a final good attempt returns clean."""
|
|
128
128
|
history: list = []
|
|
129
129
|
state = RetryState(retry)
|
|
130
130
|
for attempt in range(state.max_retries + 1):
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.5
|
|
2
2
|
Name: verifiers
|
|
3
|
-
Version: 0.4.2.
|
|
3
|
+
Version: 0.4.2.dev6
|
|
4
4
|
Summary: Verifiers: Environments for LLM Reinforcement Learning
|
|
5
5
|
Project-URL: Homepage, https://github.com/primeintellect-ai/verifiers
|
|
6
6
|
Project-URL: Documentation, https://github.com/primeintellect-ai/verifiers
|
|
@@ -35,7 +35,7 @@ Requires-Dist: numpy>=2.1.0
|
|
|
35
35
|
Requires-Dist: openai<3.0.0,>=2.54.0
|
|
36
36
|
Requires-Dist: orjson>=3.10.0
|
|
37
37
|
Requires-Dist: prime-pydantic-config[toml]>=0.4.3
|
|
38
|
-
Requires-Dist: prime-sandboxes>=0.5.
|
|
38
|
+
Requires-Dist: prime-sandboxes>=0.5.7
|
|
39
39
|
Requires-Dist: prime-tunnel>=0.1.17
|
|
40
40
|
Requires-Dist: pydantic>=2.12.3
|
|
41
41
|
Requires-Dist: renderers[multimodal]>=0.2.0
|
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
verifiers/__init__.py,sha256=F5IVMw6mhGaPBMCw7QKk0la_r5mMwydP2hdTTdQucik,352
|
|
2
2
|
verifiers/v1/__init__.py,sha256=gVnDxIQXsDjha93fZzdLw2b1G5i8i28drSf75JHmmHY,18617
|
|
3
|
-
verifiers/v1/agent.py,sha256=
|
|
4
|
-
verifiers/v1/env.py,sha256=
|
|
5
|
-
verifiers/v1/episode.py,sha256=
|
|
3
|
+
verifiers/v1/agent.py,sha256=M5Ja5vU7dFBpX3pcBfH6BqDvAYHjQ8GETQ-avDIekzw,47693
|
|
4
|
+
verifiers/v1/env.py,sha256=cTCK5f4gPNBfUYT2RtIEsMgslYgtzXtam2coCPsOzqc,18631
|
|
5
|
+
verifiers/v1/episode.py,sha256=U87tUbAKbZYKyNJLXi2h2_tX0u14ZHgV2CmpzYO67Ag,6944
|
|
6
6
|
verifiers/v1/errors.py,sha256=OieUBIOZ6FW7oKygbXIRoag6RrPxKYpMPfEYPcCnVVE,5863
|
|
7
7
|
verifiers/v1/grading.py,sha256=Z8J9-UiQA_P8MOMn1CAGsD_SgmrQd6-H_VPmD27ezss,9685
|
|
8
8
|
verifiers/v1/graph.py,sha256=wsVUZmCSfu6FuEwEI1cDrroABFbBRnJX9yNVdNOi45A,48126
|
|
9
9
|
verifiers/v1/harness.py,sha256=Hvul6cbb9uWQl4GmHubvcRHqKdfeCY3n44r_ga0csfI,16806
|
|
10
10
|
verifiers/v1/judge.py,sha256=T-TyYVcLGIoyUADYKy_pCBj2CTLhERlct5pmmWqPpTA,10507
|
|
11
|
-
verifiers/v1/rollout.py,sha256=
|
|
11
|
+
verifiers/v1/rollout.py,sha256=icIjp62QKkImVyJ-ypmNh1Jj2qdpKWAZ6ZDrmg54ev8,46206
|
|
12
12
|
verifiers/v1/semantic.py,sha256=nqKPPUoPL5Oh8Es_XjtcbDiQiIMKTYayXEm-EPB-jAE,5129
|
|
13
13
|
verifiers/v1/session.py,sha256=fuw4eEVxTw_KlkSspxbgejEhmSXJYjX7bUquq2LJ_CU,29640
|
|
14
14
|
verifiers/v1/state.py,sha256=EckF2bWp-vV4b1jYJ9sLI5xrfGuI5spIgYYwW926toI,595
|
|
15
15
|
verifiers/v1/task.py,sha256=emEKiNthgFKyJA3k-omloxSnFGbRR7cXkTiKXJh_3U4,15529
|
|
16
16
|
verifiers/v1/taskset.py,sha256=LE_3ogL7itU2Amk-N20cHkZ7Ev6MznJ0HpC8B1xb4w0,9482
|
|
17
|
-
verifiers/v1/trace.py,sha256=
|
|
17
|
+
verifiers/v1/trace.py,sha256=4OC13ee0oBWkBDQzZ2GIGBpUwgMD3LkpPv-jfsf4Ycc,40767
|
|
18
18
|
verifiers/v1/types.py,sha256=mEy4C9Hl3fK9091kxqalqbVZNRnSI5A0npRHchpsFsM,14800
|
|
19
19
|
verifiers/v1/acp/__init__.py,sha256=jY7nLAbB6uzSl-f6YCz05zBH5tarBLErNTkvV0vlaho,16613
|
|
20
20
|
verifiers/v1/acp/runner.py,sha256=sFsg0UgWeDjpjihejUidIV2yTapVj1Ap0cDTaEktjkI,15484
|
|
@@ -152,7 +152,7 @@ verifiers/v1/runtimes/strategies.py,sha256=nQC_dsuYwpPz46js2LNY5nuGyFXv8znKU7_xH
|
|
|
152
152
|
verifiers/v1/runtimes/backends/custom.py,sha256=Iz1Brd4dBTpO1zYVc2KA0u5sxz5ZUROY_Cdme5W33hM,2875
|
|
153
153
|
verifiers/v1/runtimes/backends/docker.py,sha256=S6xwCYUR8RwNcdG45H0Bw_lNDo7_049MG0Y3CznoMtM,31476
|
|
154
154
|
verifiers/v1/runtimes/backends/prime.py,sha256=Lf92Wo64W9rgejTE5KBVZFqfCDaQYmRYiAmiyGnn9S8,24444
|
|
155
|
-
verifiers/v1/runtimes/backends/subprocess.py,sha256=
|
|
155
|
+
verifiers/v1/runtimes/backends/subprocess.py,sha256=naOWJGmcaOlu2ZdRbUwhJicJdxASDRAUhDT0jzDff3w,8591
|
|
156
156
|
verifiers/v1/tasksets/__init__.py,sha256=2ijE3qIlLoUA02g6iysOwWQylyBBQL1GhSpjv8_bp0w,521
|
|
157
157
|
verifiers/v1/tasksets/harbor/__init__.py,sha256=FjW4tM3rgGALMK-8p7ux26G4-d4ZFVmaAmO6Fni6e_g,214
|
|
158
158
|
verifiers/v1/tasksets/harbor/taskset.py,sha256=Ganz72MxzVn7zfdk-GCK3KMULAelGRtDQBdE6tXYMjc,42720
|
|
@@ -184,13 +184,13 @@ verifiers/v1/utils/memory.py,sha256=ZkIvGk6uITAH5sKon65LifKPbvZr8mJ__PVc23FZpOQ,
|
|
|
184
184
|
verifiers/v1/utils/network.py,sha256=SI6_PXHIAPows6VBpK75N6dMbPw6lWQQ3OjBQkSDGN4,1463
|
|
185
185
|
verifiers/v1/utils/paths.py,sha256=it_4JWf_8bPZe4TRcyvL7_KJ4fsbEsxhhIY_xA8Ikus,308
|
|
186
186
|
verifiers/v1/utils/prime.py,sha256=UTYRjp9cbjNb6CVmBHda-1wWZAIIfxNOmTyNuT7_wL4,970
|
|
187
|
-
verifiers/v1/utils/retries.py,sha256=
|
|
187
|
+
verifiers/v1/utils/retries.py,sha256=eoYF1r4SCWVdAq8tEQkE4ZJGBlzy5r8HWllQqMDTdYU,6071
|
|
188
188
|
verifiers/v1/utils/scope.py,sha256=ivYGJ8GhzyRKbP4L48VsUDWFxpmFsjeaE_7KYBKJ_c0,826
|
|
189
189
|
verifiers/v1/utils/score.py,sha256=493yJVMw8teCu9JxapxMFPFzI0hNUqdo0Y2nGW4kckk,6200
|
|
190
190
|
verifiers/v1/utils/trace_store.py,sha256=Qo9qvsJAl8PoRUavjQAfUB2VNxmUtYQtU2ejLKPzY9c,3382
|
|
191
191
|
verifiers/v1/utils/version.py,sha256=-obEo_-l9-D8FLef4hYxncOe-uJpxrM1g2Hig_37Sgs,1607
|
|
192
|
-
verifiers-0.4.2.
|
|
193
|
-
verifiers-0.4.2.
|
|
194
|
-
verifiers-0.4.2.
|
|
195
|
-
verifiers-0.4.2.
|
|
196
|
-
verifiers-0.4.2.
|
|
192
|
+
verifiers-0.4.2.dev6.dist-info/METADATA,sha256=GszcL_rPeQd2n_l8gV-GL4yBQ51iPGm6LdSA7ycRtDg,5136
|
|
193
|
+
verifiers-0.4.2.dev6.dist-info/WHEEL,sha256=2iZrJkDIkeDh0k9SikKMqFuRP-ua6mb4Ir1AsER4BEw,87
|
|
194
|
+
verifiers-0.4.2.dev6.dist-info/entry_points.txt,sha256=3M8Wr0w1cUKiB-fJ6YHB6eK5WuKYg-Y3OC4wCuUje_c,174
|
|
195
|
+
verifiers-0.4.2.dev6.dist-info/licenses/LICENSE,sha256=v0RrUsdV3IDoZhrRce297IXS3xMHNJ-_LdLpFAUWb9k,1072
|
|
196
|
+
verifiers-0.4.2.dev6.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|