verifiers 0.3.2.dev31__py3-none-any.whl → 0.3.2.dev32__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 CHANGED
@@ -362,21 +362,26 @@ class Agent:
362
362
  runtime: Runtime | None = None,
363
363
  tools: Mapping[str, SharedToolServer] | None = None,
364
364
  on_trace: Callable[[Trace], None] | None = None,
365
+ collect_artifacts: bool = False,
365
366
  ) -> Trace:
366
367
  """Run this agent on `task` once and return the trace: one segment — the
367
368
  program runs on the task's prompt until it exits (a multi-turn exchange
368
369
  is `interaction()`). `runtime` places it into a live borrowed box instead of
369
370
  provisioning one; `tools` are live servers borrowed from their
370
371
  owner, counted in the pairing check; `on_trace` observes the trace the
371
- moment it's minted, before any I/O. Retries whole while the trace ends
372
- with a retryable error (`config.retries`) — never into a borrowed box;
373
- the final trace keeps earlier attempts' errors."""
372
+ moment it's minted, before any I/O. `collect_artifacts` captures the task's
373
+ declared artifacts after its finalizer while its container runtime is still
374
+ alive. Retries whole while the trace ends with a retryable error
375
+ (`config.retries`) — never into a borrowed box; the final trace keeps earlier
376
+ attempts' errors."""
374
377
  if self._closed:
375
378
  raise RuntimeError("Agent is closed; create a new agent")
376
379
  retry = self.config.retries
377
380
  history: list = []
378
381
  for attempt in range(retry.max_retries + 1):
379
- trace = await self._run_once(task, runtime, tools, on_trace)
382
+ trace = await self._run_once(
383
+ task, runtime, tools, on_trace, collect_artifacts
384
+ )
380
385
  if attempt == retry.max_retries or not trace_should_retry(trace, retry):
381
386
  break
382
387
  if runtime is not None:
@@ -407,9 +412,20 @@ class Agent:
407
412
  runtime: Runtime | None,
408
413
  shared_tools: Mapping[str, SharedToolServer] | None,
409
414
  on_trace: Callable[[Trace], None] | None,
415
+ collect_artifacts: bool,
410
416
  ) -> Trace:
411
417
  params = self._rollout_params(task, runtime, dict(shared_tools or {}))
412
- run = Rollout(task=task, on_trace=on_trace, **params)
418
+ if collect_artifacts and isinstance(params["runtime_config"], SubprocessConfig):
419
+ raise TypeError(
420
+ "artifact collection requires a container runtime; subprocess "
421
+ "artifacts live in a host-only temporary working directory"
422
+ )
423
+ run = Rollout(
424
+ task=task,
425
+ on_trace=on_trace,
426
+ collect_artifacts=collect_artifacts,
427
+ **params,
428
+ )
413
429
  try:
414
430
  if await run.open():
415
431
  await run.step()
@@ -626,6 +642,7 @@ class _EpisodeAgent(Agent):
626
642
  runtime: Runtime | None = None,
627
643
  tools: Mapping[str, SharedToolServer] | None = None,
628
644
  on_trace: Callable[[Trace], None] | None = None,
645
+ collect_artifacts: bool = False,
629
646
  ) -> Trace:
630
647
  async with self._gate or nullcontext():
631
648
  trace = await super().run(
@@ -633,6 +650,7 @@ class _EpisodeAgent(Agent):
633
650
  runtime=runtime,
634
651
  tools=tools if tools is not None else self._shared_for(task),
635
652
  on_trace=self._watch(on_trace),
653
+ collect_artifacts=collect_artifacts,
636
654
  )
637
655
  self._completed.append(trace)
638
656
  return trace
@@ -342,7 +342,7 @@ class IsolatedAgenticJudgeEnv(AgenticJudgeEnv):
342
342
  """Judge only collected artifacts in a fresh box with the solver's policy."""
343
343
 
344
344
  async def run(self, task: vf.Task, agents: vf.Agents) -> None:
345
- solution = await agents.solver.run(task)
345
+ solution = await agents.solver.run(task, collect_artifacts=True)
346
346
  if not solution.ok:
347
347
  raise RuntimeError("the solver's rollout failed, so the judge never ran")
348
348
  await agents.judge.run(
verifiers/v1/rollout.py CHANGED
@@ -32,6 +32,7 @@ from verifiers.v1.state import state_cls
32
32
  from verifiers.v1.task import Task
33
33
  from verifiers.v1.trace import AgentInfo, Trace, TraceTask
34
34
  from verifiers.v1.types import Messages, Request, Response, SystemMessage, UserMessage
35
+ from verifiers.v1.utils.artifacts import collect
35
36
  from verifiers.v1.utils.decorators import discover_decorated, invoke
36
37
 
37
38
  logger = logging.getLogger(__name__)
@@ -69,6 +70,7 @@ class Rollout:
69
70
  interception: Interception | None = None,
70
71
  runtime: Runtime | None = None,
71
72
  on_trace: Callable[[Trace], None] | None = None,
73
+ collect_artifacts: bool = False,
72
74
  ) -> None:
73
75
  self.task = task
74
76
  self.harness = harness
@@ -81,6 +83,7 @@ class Rollout:
81
83
  self._interception = interception
82
84
  self.runtime = runtime
83
85
  self._borrowed_runtime = runtime
86
+ self._collect_artifacts = collect_artifacts
84
87
  self.trace: Trace = Trace(
85
88
  task=TraceTask(
86
89
  type=type(task).__name__,
@@ -466,12 +469,14 @@ class Rollout:
466
469
  if not self._failed and self._opened:
467
470
  trace.timing.finalize.start = time.time()
468
471
  async with boundary(TaskError, "task finalize"):
469
- await asyncio.wait_for(
470
- invoke(
472
+ async with asyncio.timeout(self._timeouts.finalize):
473
+ await invoke(
471
474
  self.task.finalize, {"trace": trace, "runtime": runtime}
472
- ),
473
- self._timeouts.finalize,
474
- )
475
+ )
476
+ if self._collect_artifacts and not trace.state.artifacts:
477
+ trace.state.artifacts = await collect(
478
+ runtime, self.task.data.artifacts
479
+ )
475
480
  now = time.time()
476
481
  trace.timing.finalize.end = now
477
482
  trace.timing.scoring.start = now
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: verifiers
3
- Version: 0.3.2.dev31
3
+ Version: 0.3.2.dev32
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
@@ -1,13 +1,13 @@
1
1
  verifiers/__init__.py,sha256=yDYsckVQbUkwoh9mU_hBeCLGvS_aWgAxuoNm5LxQpDI,517
2
2
  verifiers/v1/__init__.py,sha256=AYjjpOBfpSlWZRN51V1KaxMYMBWSZhBEIOzvNk23pxg,8348
3
- verifiers/v1/agent.py,sha256=AfjyYmcGpVaOlZkElIz1JZeNRQuZsE_KMZ-LV3uLvzA,31644
3
+ verifiers/v1/agent.py,sha256=QvP7jJMR1NQEzAdcqSxcPRgYYTZYt6gxst3vxmXymOE,32384
4
4
  verifiers/v1/env.py,sha256=CEhzjojhg5jqbOYruUnc5U7TtgDHDSx8NiiFA0qfbt8,18234
5
5
  verifiers/v1/episode.py,sha256=uStvI4WqgJT50hmHIB55m5B-ASqqLz-fZ-ynBz9uzEY,5474
6
6
  verifiers/v1/errors.py,sha256=uQySmCUrjDYFkBIii1vBFPiEcPFPQZ9EGpas_6HvcQI,5279
7
7
  verifiers/v1/graph.py,sha256=09uysIuX7kHCt9XRndpACkQtWocgVbtiLewcEmnzmD4,35787
8
8
  verifiers/v1/harness.py,sha256=ziECqEBWV34UWbLlxrkhY6MwkbVYkoXBOoaY7mZxwTs,14753
9
9
  verifiers/v1/judge.py,sha256=Pvr0C41ah1qkNSZ0WXdkDvBMfv5YSfY1REHncwlJ8cg,9346
10
- verifiers/v1/rollout.py,sha256=EnF3RuBfMyKNjJIs0LZaImkSvfe9LYLXc8dYP-1a2Ew,23628
10
+ verifiers/v1/rollout.py,sha256=hoKGn1CbShbyjEM9PgYq8pdKgoC91VebTkBSgUHLtiE,23978
11
11
  verifiers/v1/semantic.py,sha256=wssvBSEpY_tgzpFUADG9-N4HkDXgCZvNQ1pdf6qAsS0,4680
12
12
  verifiers/v1/session.py,sha256=xM7JJJVJACk0JfH9RAN1Ts8gJJKr2tGGRiIgQTrdieY,18692
13
13
  verifiers/v1/state.py,sha256=EckF2bWp-vV4b1jYJ9sLI5xrfGuI5spIgYYwW926toI,595
@@ -65,7 +65,7 @@ verifiers/v1/dialects/chat.py,sha256=_pMsNpbffiXiK0_0tboAKtuj7-smUnkS9H0LPK4j1mU
65
65
  verifiers/v1/dialects/responses.py,sha256=KRuS9TKw2uoNz4NsG7E-H6eyhm_EJQwVtZ5_XW9iB3c,29090
66
66
  verifiers/v1/envs/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
67
67
  verifiers/v1/envs/agentic_judge/__init__.py,sha256=LfEcRHLG_siKzhzWmODDXWSLpLgfum3UFdQDK9XG0gk,325
68
- verifiers/v1/envs/agentic_judge/env.py,sha256=yVMdq0zBOX7vkEkhnhHTUDM-KKcoOIHUt7yEggOs4ng,14615
68
+ verifiers/v1/envs/agentic_judge/env.py,sha256=IZ8G8OgMI4P5JKJhXM0rrsBloWKgqUSzYiKHpqhEPDY,14639
69
69
  verifiers/v1/envs/best_of_n/__init__.py,sha256=mubASiwXMNIhnQFDccNAc7yZ0OFsOVK8hH8WIx9b2A4,119
70
70
  verifiers/v1/envs/best_of_n/env.py,sha256=KEUJBCVqblnXP_lEwm3mjGdaikBMkecz8UjOFPBhxc0,1987
71
71
  verifiers/v1/envs/shared_agentic_judge/__init__.py,sha256=9T4vyYAuqgZSQjqTIceghxnpauvqeW6XGhZSQDCttMA,168
@@ -185,8 +185,8 @@ verifiers/v1/utils/prime.py,sha256=UTYRjp9cbjNb6CVmBHda-1wWZAIIfxNOmTyNuT7_wL4,9
185
185
  verifiers/v1/utils/retries.py,sha256=Y2ZgrAjn-qNkRKZP_RVNL_7EK0iaRcZeCa404lpGYi4,5417
186
186
  verifiers/v1/utils/score.py,sha256=493yJVMw8teCu9JxapxMFPFzI0hNUqdo0Y2nGW4kckk,6200
187
187
  verifiers/v1/utils/version.py,sha256=-obEo_-l9-D8FLef4hYxncOe-uJpxrM1g2Hig_37Sgs,1607
188
- verifiers-0.3.2.dev31.dist-info/METADATA,sha256=0h0tNHbRYVLoDa0whEvfRNXDH9SkdX41bAn-Ct2aC2A,4144
189
- verifiers-0.3.2.dev31.dist-info/WHEEL,sha256=zOwg4jB6zX2kU910N-cMawjivD6tO8NEWvE12je1bVk,87
190
- verifiers-0.3.2.dev31.dist-info/entry_points.txt,sha256=uqQje0TMsr7k6nXlWxlPs13Si0evb3pVCEDF6c-YL80,241
191
- verifiers-0.3.2.dev31.dist-info/licenses/LICENSE,sha256=v0RrUsdV3IDoZhrRce297IXS3xMHNJ-_LdLpFAUWb9k,1072
192
- verifiers-0.3.2.dev31.dist-info/RECORD,,
188
+ verifiers-0.3.2.dev32.dist-info/METADATA,sha256=d9DcoI2d4e5C0TSyk5lbWqDmU37zuU8GZp5dh0IEJIM,4144
189
+ verifiers-0.3.2.dev32.dist-info/WHEEL,sha256=zOwg4jB6zX2kU910N-cMawjivD6tO8NEWvE12je1bVk,87
190
+ verifiers-0.3.2.dev32.dist-info/entry_points.txt,sha256=uqQje0TMsr7k6nXlWxlPs13Si0evb3pVCEDF6c-YL80,241
191
+ verifiers-0.3.2.dev32.dist-info/licenses/LICENSE,sha256=v0RrUsdV3IDoZhrRce297IXS3xMHNJ-_LdLpFAUWb9k,1072
192
+ verifiers-0.3.2.dev32.dist-info/RECORD,,