verifiers 0.4.2.dev123__py3-none-any.whl → 0.4.2.dev124__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.
@@ -817,25 +817,26 @@ class InterceptionServer(Interception):
817
817
  # A malformed harness knob must not kill recording (this runs in the
818
818
  # exchange's `finally`); the provider rejects the request on its own.
819
819
  logger.warning("Could not record call settings", exc_info=True)
820
- session.trace.calls.append(
821
- ModelCall(
822
- node=node,
823
- model=request.get("model") if request is not None else None,
824
- sampling=sampling,
825
- endpoint=dialect.upstream_path,
826
- finish_reason=finish_reason,
827
- usage=usage,
828
- time=TimeSpan(start=started, end=time.time()),
829
- error=None if error is None else Error.from_exception(error),
830
- policy=PolicyEvent(
831
- code=PROVIDER_CAPABILITY_POLICY_CODE,
832
- paths=policy_paths,
833
- )
834
- if policy_paths
835
- else None,
836
- acp=acp,
820
+ call = ModelCall(
821
+ node=node,
822
+ model=request.get("model") if request is not None else None,
823
+ sampling=sampling,
824
+ endpoint=dialect.upstream_path,
825
+ finish_reason=finish_reason,
826
+ usage=usage,
827
+ time=TimeSpan(start=started, end=time.time()),
828
+ error=None if error is None else Error.from_exception(error),
829
+ policy=PolicyEvent(
830
+ code=PROVIDER_CAPABILITY_POLICY_CODE,
831
+ paths=policy_paths,
837
832
  )
833
+ if policy_paths
834
+ else None,
835
+ acp=acp,
838
836
  )
837
+ session.trace.calls.append(call)
838
+ if not session.judge_only and session.limits.turn_capped(call):
839
+ session.trace.stop("max_turn_tokens")
839
840
  session.trace.notify()
840
841
 
841
842
  async def handle_request(
verifiers/v1/session.py CHANGED
@@ -39,7 +39,7 @@ from verifiers.v1.configs.runtime import NetworkPolicyConfig
39
39
  from verifiers.v1.dialects.base import CAPABILITY_NOTICE
40
40
  from verifiers.v1.errors import HarnessError, RolloutError, TaskError
41
41
  from verifiers.v1.harnesses.utils.compaction import bound_tool_message
42
- from verifiers.v1.trace import InterceptRecord, Trace
42
+ from verifiers.v1.trace import InterceptRecord, ModelCall, Trace
43
43
  from verifiers.v1.types import (
44
44
  AssistantMessage,
45
45
  Message,
@@ -259,8 +259,9 @@ class RolloutLimits:
259
259
  `max_turns` -> num_turns, `max_input_tokens` -> num_input_tokens, `max_output_tokens` ->
260
260
  num_output_tokens, `max_total_tokens` -> num_total_tokens. Token caps are soft by one turn:
261
261
  they're checked between turns, so the turn that crosses a cap still completes.
262
- `max_turn_tokens` caps each response (applied through sampling) and refuses the turn
263
- after a response that hit it."""
262
+ `max_turn_tokens` caps each response (applied through sampling) and stops the trace
263
+ as soon as a response hits it, so a clean end after that response cannot name the
264
+ trace instead."""
264
265
 
265
266
  max_turns: int | None = None
266
267
  max_input_tokens: int | None = None
@@ -287,20 +288,24 @@ class RolloutLimits:
287
288
  and trace.num_total_tokens >= self.max_total_tokens
288
289
  ):
289
290
  return "max_total_tokens"
290
- if self.max_turn_tokens is not None:
291
- last = next((c for c in reversed(trace.calls) if c.error is None), None)
292
- # A length finish below the cap ran out of context, not turn tokens.
293
- if (
294
- last is not None
295
- and last.finish_reason == "length"
296
- and (
297
- last.usage is None
298
- or last.usage.completion_tokens >= self.max_turn_tokens
299
- )
300
- ):
301
- return "max_turn_tokens"
291
+ last = next((c for c in reversed(trace.calls) if c.error is None), None)
292
+ if last is not None and self.turn_capped(last):
293
+ return "max_turn_tokens"
302
294
  return None
303
295
 
296
+ def turn_capped(self, call: ModelCall) -> bool:
297
+ """Whether `call`'s response hit `max_turn_tokens`. A length finish below the cap
298
+ ran out of context, not turn tokens."""
299
+ return (
300
+ self.max_turn_tokens is not None
301
+ and call.error is None
302
+ and call.finish_reason == "length"
303
+ and (
304
+ call.usage is None
305
+ or call.usage.completion_tokens >= self.max_turn_tokens
306
+ )
307
+ )
308
+
304
309
 
305
310
  @dataclass
306
311
  class IdempotentRequest:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: verifiers
3
- Version: 0.4.2.dev123
3
+ Version: 0.4.2.dev124
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
@@ -12,7 +12,7 @@ verifiers/v1/judge.py,sha256=T-TyYVcLGIoyUADYKy_pCBj2CTLhERlct5pmmWqPpTA,10507
12
12
  verifiers/v1/restore.py,sha256=kg7TM5J2LlVoQhKpkVAT6PXroOqCOjNqH3wlGV-DOtA,8339
13
13
  verifiers/v1/rollout.py,sha256=N99M_wp4XbpWj4HxsYzbiXmVT-cBgZ6JmgkqzITsaNA,87623
14
14
  verifiers/v1/semantic.py,sha256=nqKPPUoPL5Oh8Es_XjtcbDiQiIMKTYayXEm-EPB-jAE,5129
15
- verifiers/v1/session.py,sha256=W39D3WfQgIZGekzt7-2bBVrF-Kb_Uapdy5cnWepEcyw,52241
15
+ verifiers/v1/session.py,sha256=4O7JOFFoy2GvUOhJgWHn6FNwmpMv7tDflDA_0ffBS9k,52457
16
16
  verifiers/v1/state.py,sha256=EckF2bWp-vV4b1jYJ9sLI5xrfGuI5spIgYYwW926toI,595
17
17
  verifiers/v1/submission.py,sha256=zgSRbGVz82Efwz4nX4tlJ-i02AmjtKyu_vHfwfLaByw,7989
18
18
  verifiers/v1/task.py,sha256=zcWjBjhJrkGIL29JTnxxw6v2pbJoiek_tF5RVAVV2ZY,15919
@@ -121,7 +121,7 @@ verifiers/v1/harnesses/utils/replay.py,sha256=m2EXxd24aH3Y5DAi9tEV1teREXGcPHsXhp
121
121
  verifiers/v1/interception/__init__.py,sha256=Ca5bxP_wWeeVyX8HXbMfqdwUbq7iXPhGXBCje-huHkM,4148
122
122
  verifiers/v1/interception/base.py,sha256=zxkkve4UeD5J_14rirLg2ypik2tiwut9E4uqn8J0z5I,2330
123
123
  verifiers/v1/interception/pool.py,sha256=QVkt_XKhKhZJnwmXu1MmnbMR5kiffZt0uo0tSj2zZf4,6716
124
- verifiers/v1/interception/server.py,sha256=vF2wej6EyRbPTo3MCezCakXlFTvisyygaQ_Arqc8QbY,63676
124
+ verifiers/v1/interception/server.py,sha256=UHPt-SMf_XfjWhk4Wq559bx96kk9qkCUwqvOGENPxDs,63732
125
125
  verifiers/v1/interception/relay/__init__.py,sha256=wSloZcQqjjLCAVommZ5zdyjwGVUfdrh6se5QTEuU_4E,8652
126
126
  verifiers/v1/interception/relay/server.py,sha256=yIhHlrhkPSnpGTTd5vj565naxgW4Cqqd-P1wud_H6N8,28932
127
127
  verifiers/v1/interception/tunnel/__init__.py,sha256=4ZqR9F7cmLUg17qvk4sXtLpWAN4epdiMgA2l9jetMbU,721
@@ -188,8 +188,8 @@ verifiers/v1/utils/scope.py,sha256=zbs4pj6AVk4jywlAJ3AX0Q0_kzB9dBB02nY-9H4ELdQ,8
188
188
  verifiers/v1/utils/score.py,sha256=493yJVMw8teCu9JxapxMFPFzI0hNUqdo0Y2nGW4kckk,6200
189
189
  verifiers/v1/utils/trace_store.py,sha256=7F6xMhYgl3qmylnCU8-ekqswH16fUat1uegeM1OR9QQ,2563
190
190
  verifiers/v1/utils/version.py,sha256=-obEo_-l9-D8FLef4hYxncOe-uJpxrM1g2Hig_37Sgs,1607
191
- verifiers-0.4.2.dev123.dist-info/METADATA,sha256=0yn061QStOqN_CzWwfS8hy9ew_cCer5tw1vMmSkgm7w,5118
192
- verifiers-0.4.2.dev123.dist-info/WHEEL,sha256=2iZrJkDIkeDh0k9SikKMqFuRP-ua6mb4Ir1AsER4BEw,87
193
- verifiers-0.4.2.dev123.dist-info/entry_points.txt,sha256=qdMg7ajiFpDsHf7tuPMRclJXizu1J6LTWawS5YS0B0I,137
194
- verifiers-0.4.2.dev123.dist-info/licenses/LICENSE,sha256=v0RrUsdV3IDoZhrRce297IXS3xMHNJ-_LdLpFAUWb9k,1072
195
- verifiers-0.4.2.dev123.dist-info/RECORD,,
191
+ verifiers-0.4.2.dev124.dist-info/METADATA,sha256=gwkwNHYV33wglnNkw_x29HK4r_gFvfaFlo0dVrUURQA,5118
192
+ verifiers-0.4.2.dev124.dist-info/WHEEL,sha256=2iZrJkDIkeDh0k9SikKMqFuRP-ua6mb4Ir1AsER4BEw,87
193
+ verifiers-0.4.2.dev124.dist-info/entry_points.txt,sha256=qdMg7ajiFpDsHf7tuPMRclJXizu1J6LTWawS5YS0B0I,137
194
+ verifiers-0.4.2.dev124.dist-info/licenses/LICENSE,sha256=v0RrUsdV3IDoZhrRce297IXS3xMHNJ-_LdLpFAUWb9k,1072
195
+ verifiers-0.4.2.dev124.dist-info/RECORD,,