verifiers 0.4.1.dev72__py3-none-any.whl → 0.4.1.dev74__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.
@@ -198,16 +198,10 @@ def response_from_generate(
198
198
 
199
199
 
200
200
  def _is_valid_incremental_tail(messages: list[dict[str, Any]]) -> bool:
201
- """Renderer bridges may extend sampled assistant turns with tool calls and/or a new user."""
202
- if not messages:
203
- return False
204
- roles = []
205
- for message in messages:
206
- role = message.get("role")
207
- roles.append(role if isinstance(role, str) else None)
208
- if roles[-1] == "user":
209
- return all(role == "tool" for role in roles[:-1])
210
- return all(role == "tool" for role in roles)
201
+ """Let the renderer extend append-only tool results and user messages."""
202
+ return bool(messages) and all(
203
+ message.get("role") in ("tool", "user") for message in messages
204
+ )
211
205
 
212
206
 
213
207
  def _has_multimodal_content(messages) -> bool:
@@ -22,6 +22,7 @@ from prime_sandboxes.models import validate_egress_lists
22
22
  from verifiers.v1.configs.runtime import NetworkPolicyConfig, PrimeConfig
23
23
  from verifiers.v1.errors import SandboxError
24
24
  from verifiers.v1.runtimes.base import (
25
+ SERVICE_PORT,
25
26
  BaseRuntimeInfo,
26
27
  ProgramResult,
27
28
  RuntimeBackend,
@@ -49,6 +50,10 @@ _OUTPUT_DEADLINE_SECONDS = 300
49
50
  _OUTPUT_RETRIES = 10
50
51
  """Re-reads of a finished job's output that the SDK still failed to fetch, before the
51
52
  exec is reported as failed."""
53
+ _PUBLIC_DOMAIN = "sandbox-v2-prod.pinfra.io"
54
+ """Domain of the public URLs `https://<port>-<sandbox-id>.<domain>` that a LAN network's
55
+ `internet` rule publishes ports at."""
56
+ _EXPOSE_TAG = "vf-exposed"
52
57
 
53
58
 
54
59
  BASE_LABELS: list[str] = []
@@ -143,6 +148,7 @@ class PrimeBackend(RuntimeBackend):
143
148
  SUPPORTS_TASK_IMAGES: ClassVar[bool] = True
144
149
  SUPPORTS_COMPOSE: ClassVar[bool] = True
145
150
  SUPPORTS_USER_SWITCHING: ClassVar[bool] = True
151
+ SUPPORTS_PORT_EXPOSURE: ClassVar[bool] = True
146
152
 
147
153
  def __init__(self, config: PrimeConfig, name: str | None = None) -> None:
148
154
  ensure_prime_auth()
@@ -153,6 +159,17 @@ class PrimeBackend(RuntimeBackend):
153
159
  # A LAN network (id, tags) to join as the sandbox boots: prime-sandboxes joins it
154
160
  # once it is running, within `wait_for_creation` on the creating client.
155
161
  self.lan: tuple[str, list[str]] | None = None
162
+ # Exposure state: a LAN network created on the first `expose`, separate from
163
+ # `lan`, and the ports its `internet` rule publishes.
164
+ self._expose_network_id: str | None = None
165
+ self._exposed_ports: list[int] = []
166
+ self._expose_lock = asyncio.Lock()
167
+
168
+ @property
169
+ def published_port(self) -> int:
170
+ # Any port can be exposed, but the public URL reaches only servers bound to
171
+ # 0.0.0.0, which `launch` arranges for a fixed published port.
172
+ return SERVICE_PORT
156
173
 
157
174
  async def start(self) -> None:
158
175
  from prime_sandboxes import CreateSandboxRequest
@@ -347,10 +364,38 @@ class PrimeBackend(RuntimeBackend):
347
364
  return PrimeProcess(process)
348
365
 
349
366
  async def expose(self, port: int) -> str:
350
- raise SandboxError(
351
- "the prime runtime cannot expose a port; colocate the service with its "
352
- "consumer"
353
- )
367
+ """Publish `port` through a LAN network whose `internet` rule exposes it on this
368
+ sandbox. The URL has no Prime authentication."""
369
+ from prime_sandboxes import LanRule
370
+
371
+ async with self._expose_lock:
372
+ if port not in self._exposed_ports:
373
+ ports = [*self._exposed_ports, port]
374
+ rules = [
375
+ LanRule(from_="internet", to=f"tag:{_EXPOSE_TAG}", ports=ports)
376
+ ]
377
+ try:
378
+ if self._expose_network_id is None:
379
+ # Shielded through the id capture, as in `start()`: a cancel
380
+ # mid-POST would leave a network teardown cannot delete.
381
+ async def create_and_capture_id() -> None:
382
+ network = await self._client.create_lan_network(
383
+ f"{self.name}-exposed", rules=rules
384
+ )
385
+ self._expose_network_id = network.id
386
+
387
+ await run_shielded(create_and_capture_id())
388
+ else:
389
+ await self._client.set_lan_rules(self._expose_network_id, rules)
390
+ # Joins (an idempotent PUT, so a retry re-adds a failed join) and
391
+ # waits until the platform has pushed the membership and rules.
392
+ await self._client._join_lan(
393
+ self._expose_network_id, self.info.id, [_EXPOSE_TAG]
394
+ )
395
+ except Exception as e:
396
+ raise SandboxError(f"prime expose port {port} failed: {e}") from e
397
+ self._exposed_ports = ports
398
+ return f"https://{port}-{self.info.id}.{_PUBLIC_DOMAIN}"
354
399
 
355
400
  async def run_background(
356
401
  self, runtime: Runtime, argv: list[str], env: dict[str, str], log: str
@@ -455,8 +500,12 @@ class PrimeBackend(RuntimeBackend):
455
500
  from prime_sandboxes import SandboxClient
456
501
  from prime_sandboxes.core import APIClient
457
502
 
503
+ client = SandboxClient(APIClient())
458
504
  with contextlib.suppress(Exception):
459
- SandboxClient(APIClient()).delete(self.info.id)
505
+ client.delete(self.info.id)
506
+ if self._expose_network_id is not None:
507
+ with contextlib.suppress(Exception):
508
+ client.delete_lan_network(self._expose_network_id)
460
509
 
461
510
  async def teardown(self) -> None:
462
511
  # Best-effort, idempotent teardown: delete the sandbox (the costly resource). Runs via
@@ -465,9 +514,22 @@ class PrimeBackend(RuntimeBackend):
465
514
  if client is None:
466
515
  return
467
516
  try:
468
- if self.info.id is not None: # keep info.id available after teardown
469
- await client.delete(self.info.id)
470
- except Exception as e: # noqa: BLE001 - provider teardown is best-effort
471
- logger.warning("prime: failed to delete sandbox %s: %s", self.info.id, e)
517
+ try:
518
+ if self.info.id is not None: # keep info.id available after teardown
519
+ await client.delete(self.info.id)
520
+ except Exception as e: # noqa: BLE001 - provider teardown is best-effort
521
+ logger.warning(
522
+ "prime: failed to delete sandbox %s: %s", self.info.id, e
523
+ )
524
+ if self._expose_network_id is not None:
525
+ try:
526
+ await client.delete_lan_network(self._expose_network_id)
527
+ self._expose_network_id = None
528
+ except Exception as e: # noqa: BLE001 - provider teardown is best-effort
529
+ logger.warning(
530
+ "prime: failed to delete LAN network %s: %s",
531
+ self._expose_network_id,
532
+ e,
533
+ )
472
534
  finally:
473
535
  await _release_client(client)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: verifiers
3
- Version: 0.4.1.dev72
3
+ Version: 0.4.1.dev74
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
@@ -40,7 +40,7 @@ verifiers/v1/clients/__init__.py,sha256=Ysig0tE_0E4Jsfgfes1XHN-fK1s_RCXdqZD6E7lK
40
40
  verifiers/v1/clients/base.py,sha256=C0G5lRm3nxt1xmPoA2cweBgCnN2KcLepmCYq1vdDrnU,1691
41
41
  verifiers/v1/clients/client.py,sha256=zqC_AkiD9pl0kxxIbupNiehbS-YnVdp3EMZ0LOHTd8U,3125
42
42
  verifiers/v1/clients/eval.py,sha256=qMm1W4H1JN2xa6e-aSUL19iQ_QHCB7MxEofUD7_MsEU,8299
43
- verifiers/v1/clients/train.py,sha256=Rf-BQLiI193H_oKVUaMNPJSFTRmnSIr6JSVfSgwRuIY,19981
43
+ verifiers/v1/clients/train.py,sha256=hIZUsJTG8n94nn5y57Uk0pCtvSqPHyj7mrDRLw3medk,19757
44
44
  verifiers/v1/configs/__init__.py,sha256=X7u6X7B3ieD1HZl79Tv1kg-yPHbT0QLvAebaGqxVtvA,317
45
45
  verifiers/v1/configs/agent.py,sha256=akq7QDFmSnkfqS378VJnmH2Wgcfat4moxbQ8xyi7Ygg,7115
46
46
  verifiers/v1/configs/client.py,sha256=5OW_kAmFf2DkmzH2cerd4bINrIL2t68MKKcREUdrQyQ,6224
@@ -159,7 +159,7 @@ verifiers/v1/runtimes/runtime.py,sha256=-CvhH42y0F0dPeNgDRVBeajkRK_vZYp2qxKY1XVf
159
159
  verifiers/v1/runtimes/strategies.py,sha256=2iNG5-myd7htwPf-fsV4HnPWfFmE96WURQovyAjoAdc,5815
160
160
  verifiers/v1/runtimes/backends/custom.py,sha256=Iz1Brd4dBTpO1zYVc2KA0u5sxz5ZUROY_Cdme5W33hM,2875
161
161
  verifiers/v1/runtimes/backends/docker.py,sha256=i720pjrRuzCWCrQooA4teQMrfcKQl8Z92YlUJZJ3pgk,33223
162
- verifiers/v1/runtimes/backends/prime.py,sha256=SVzxCpdqqe4DPtsNG9B09YBIioqlnbSpSknjQMP3tgI,19875
162
+ verifiers/v1/runtimes/backends/prime.py,sha256=23FnkgUui3GEjC0b2Ft1yJu2wd0zndmVWalz3XYagOE,23033
163
163
  verifiers/v1/runtimes/backends/subprocess.py,sha256=dCfazoyJHwrfb2fMNRv6QzD6EsYlZXcEDT0x-8MAp3I,8419
164
164
  verifiers/v1/serve/__init__.py,sha256=wOKuwfugzmDT4yIniwzCXlf4G6tv6Cg8Kc--WMa38Bs,553
165
165
  verifiers/v1/serve/client.py,sha256=BL_1PAW9zgtEq0c93BNxh2EdrdsRQfnMgz1QVlwA_X8,10317
@@ -204,8 +204,8 @@ verifiers/v1/utils/scope.py,sha256=bzUEiWDOVdbj7dXOwGOlzsQ_-Xu0j9NR5TalQB-8TS8,8
204
204
  verifiers/v1/utils/score.py,sha256=493yJVMw8teCu9JxapxMFPFzI0hNUqdo0Y2nGW4kckk,6200
205
205
  verifiers/v1/utils/trace_store.py,sha256=Qo9qvsJAl8PoRUavjQAfUB2VNxmUtYQtU2ejLKPzY9c,3382
206
206
  verifiers/v1/utils/version.py,sha256=-obEo_-l9-D8FLef4hYxncOe-uJpxrM1g2Hig_37Sgs,1607
207
- verifiers-0.4.1.dev72.dist-info/METADATA,sha256=wBWRnSyyNYEOQaRrR0qGW8Cme2Iv18FIlIbKMffF5q0,5234
208
- verifiers-0.4.1.dev72.dist-info/WHEEL,sha256=W3fkpkm7-wf9vBI5Z-7s0eWkeM-spu78I8Neb98DeEg,87
209
- verifiers-0.4.1.dev72.dist-info/entry_points.txt,sha256=O1bIO0gyJWuLfWtTGF0h-JkNz6FkyXP7Z9iMFYnjeMI,222
210
- verifiers-0.4.1.dev72.dist-info/licenses/LICENSE,sha256=v0RrUsdV3IDoZhrRce297IXS3xMHNJ-_LdLpFAUWb9k,1072
211
- verifiers-0.4.1.dev72.dist-info/RECORD,,
207
+ verifiers-0.4.1.dev74.dist-info/METADATA,sha256=6nnbwxJ4oOTaMH5joL7s685L3gJ92X7YI8aYP5BAwRo,5234
208
+ verifiers-0.4.1.dev74.dist-info/WHEEL,sha256=W3fkpkm7-wf9vBI5Z-7s0eWkeM-spu78I8Neb98DeEg,87
209
+ verifiers-0.4.1.dev74.dist-info/entry_points.txt,sha256=O1bIO0gyJWuLfWtTGF0h-JkNz6FkyXP7Z9iMFYnjeMI,222
210
+ verifiers-0.4.1.dev74.dist-info/licenses/LICENSE,sha256=v0RrUsdV3IDoZhrRce297IXS3xMHNJ-_LdLpFAUWb9k,1072
211
+ verifiers-0.4.1.dev74.dist-info/RECORD,,