verifiers 0.4.1.dev77__py3-none-any.whl → 0.4.1.dev79__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.
Files changed (41) hide show
  1. verifiers/v1/__init__.py +5 -7
  2. verifiers/v1/clients/client.py +2 -1
  3. verifiers/v1/clients/eval.py +2 -1
  4. verifiers/v1/clients/train.py +25 -9
  5. verifiers/v1/configs/agent.py +12 -5
  6. verifiers/v1/configs/cli/eval.py +1 -1
  7. verifiers/v1/configs/env.py +1 -2
  8. verifiers/v1/configs/harness.py +6 -1
  9. verifiers/v1/configs/judge.py +2 -1
  10. verifiers/v1/configs/sampling.py +35 -0
  11. verifiers/v1/configs/taskset.py +1 -1
  12. verifiers/v1/dialects/anthropic.py +1 -2
  13. verifiers/v1/dialects/base.py +3 -7
  14. verifiers/v1/dialects/chat.py +1 -2
  15. verifiers/v1/dialects/responses.py +1 -2
  16. verifiers/v1/gepa/config.py +1 -1
  17. verifiers/v1/graph.py +177 -133
  18. verifiers/v1/harness.py +2 -2
  19. verifiers/v1/harnesses/claude_code/harness.py +2 -2
  20. verifiers/v1/harnesses/hermes_agent/harness.py +2 -2
  21. verifiers/v1/harnesses/kimi_code/harness.py +2 -2
  22. verifiers/v1/harnesses/opencode/harness.py +2 -2
  23. verifiers/v1/harnesses/pi/harness.py +7 -2
  24. verifiers/v1/harnesses/prime_agent/harness.py +2 -2
  25. verifiers/v1/judge.py +2 -1
  26. verifiers/v1/judges/decision.py +2 -1
  27. verifiers/v1/judges/reference.py +1 -1
  28. verifiers/v1/judges/rubric.py +1 -1
  29. verifiers/v1/serve/client.py +1 -1
  30. verifiers/v1/serve/delta.py +9 -5
  31. verifiers/v1/serve/server.py +1 -1
  32. verifiers/v1/serve/types.py +1 -1
  33. verifiers/v1/session.py +1 -1
  34. verifiers/v1/trace.py +45 -48
  35. verifiers/v1/types.py +74 -63
  36. verifiers/v1/utils/generic.py +1 -1
  37. {verifiers-0.4.1.dev77.dist-info → verifiers-0.4.1.dev79.dist-info}/METADATA +2 -2
  38. {verifiers-0.4.1.dev77.dist-info → verifiers-0.4.1.dev79.dist-info}/RECORD +41 -40
  39. {verifiers-0.4.1.dev77.dist-info → verifiers-0.4.1.dev79.dist-info}/WHEEL +0 -0
  40. {verifiers-0.4.1.dev77.dist-info → verifiers-0.4.1.dev79.dist-info}/entry_points.txt +0 -0
  41. {verifiers-0.4.1.dev77.dist-info → verifiers-0.4.1.dev79.dist-info}/licenses/LICENSE +0 -0
verifiers/v1/__init__.py CHANGED
@@ -30,7 +30,7 @@ if TYPE_CHECKING:
30
30
  SingleAgentEnvConfig,
31
31
  default_agent_harness,
32
32
  )
33
- from verifiers.v1.configs.harness import HarnessConfig
33
+ from verifiers.v1.configs.harness import ID, HarnessConfig
34
34
  from verifiers.v1.configs.judge import JudgeConfig, Judges
35
35
  from verifiers.v1.configs.retries import RetryConfig, RetryRule
36
36
  from verifiers.v1.configs.runtime import (
@@ -43,6 +43,7 @@ if TYPE_CHECKING:
43
43
  RuntimeConfig,
44
44
  SubprocessConfig,
45
45
  )
46
+ from verifiers.v1.configs.sampling import Sampling, SamplingConfig
46
47
  from verifiers.v1.configs.scoring import ScoringConfig
47
48
  from verifiers.v1.configs.select import (
48
49
  SelectCLIConfig,
@@ -145,7 +146,6 @@ if TYPE_CHECKING:
145
146
  WireTrace,
146
147
  )
147
148
  from verifiers.v1.types import (
148
- ID,
149
149
  AssistantMessage,
150
150
  ContentPart,
151
151
  ImageUrlContentPart,
@@ -155,8 +155,6 @@ if TYPE_CHECKING:
155
155
  Messages,
156
156
  Request,
157
157
  Response,
158
- Sampling,
159
- SamplingConfig,
160
158
  SamplingMask,
161
159
  SystemMessage,
162
160
  TextContentPart,
@@ -244,7 +242,7 @@ _NAME_TO_MODULE = {
244
242
  "HarnessConfig": "verifiers.v1.configs.harness",
245
243
  "HarnessError": "verifiers.v1.errors",
246
244
  "HarnessSession": "verifiers.v1.harness",
247
- "ID": "verifiers.v1.types",
245
+ "ID": "verifiers.v1.configs.harness",
248
246
  "ImageUrlContentPart": "verifiers.v1.types",
249
247
  "ImageUrlSource": "verifiers.v1.types",
250
248
  "Interaction": "verifiers.v1.agent",
@@ -286,8 +284,8 @@ _NAME_TO_MODULE = {
286
284
  "RuntimeConfig": "verifiers.v1.configs.runtime",
287
285
  "RuntimeInfo": "verifiers.v1.runtimes",
288
286
  "RuntimeProcess": "verifiers.v1.runtimes",
289
- "Sampling": "verifiers.v1.types",
290
- "SamplingConfig": "verifiers.v1.types",
287
+ "Sampling": "verifiers.v1.configs.sampling",
288
+ "SamplingConfig": "verifiers.v1.configs.sampling",
291
289
  "SamplingMask": "verifiers.v1.types",
292
290
  "SandboxError": "verifiers.v1.errors",
293
291
  "ScoringConfig": "verifiers.v1.configs.scoring",
@@ -9,9 +9,10 @@ from verifiers.v1.configs.client import (
9
9
  ClientConfig,
10
10
  TrainClientConfig,
11
11
  )
12
+ from verifiers.v1.configs.sampling import Sampling, SamplingConfig
12
13
  from verifiers.v1.dialects import Dialect
13
14
  from verifiers.v1.graph import PendingTurn
14
- from verifiers.v1.types import Response, Sampling, SamplingConfig
15
+ from verifiers.v1.types import Response
15
16
 
16
17
  SESSION_ID_HEADER = "X-Session-ID"
17
18
  """Per-rollout routing header (the trace id, same value every turn), so a session-affinity
@@ -14,11 +14,12 @@ from verifiers.v1.configs.client import (
14
14
  resolve_api_key,
15
15
  resolve_headers,
16
16
  )
17
+ from verifiers.v1.configs.sampling import SamplingConfig
17
18
  from verifiers.v1.dialects import Dialect
18
19
  from verifiers.v1.errors import model_error
19
20
  from verifiers.v1.graph import PendingTurn
20
21
  from verifiers.v1.semantic import ACP_EXTENSION_HEADERS
21
- from verifiers.v1.types import Response, SamplingConfig
22
+ from verifiers.v1.types import Response
22
23
 
23
24
  # These fields describe the localhost request, its original bytes, or its connection. HTTPX
24
25
  # rebuilds the provider request from JSON; endpoint configuration and provider auth apply last.
@@ -9,6 +9,7 @@ from contextlib import asynccontextmanager
9
9
  from dataclasses import dataclass, field
10
10
  from typing import Any, ClassVar, TypeVar
11
11
 
12
+ import numpy as np
12
13
  from openai import OpenAIError
13
14
  from renderers import OverlongPromptError, RenderedTokens, Renderer, RendererConfig
14
15
  from renderers.base import ToolCallParseStatus, is_multimodal
@@ -16,6 +17,7 @@ from renderers.base import ToolCallParseStatus, is_multimodal
16
17
  from verifiers.v1.clients.base import build_async_openai
17
18
  from verifiers.v1.clients.client import SESSION_ID_HEADER, Client
18
19
  from verifiers.v1.configs.client import TrainClientConfig
20
+ from verifiers.v1.configs.sampling import SamplingConfig
19
21
  from verifiers.v1.dialects import FINISH_REASONS, ChatDialect, Dialect
20
22
  from verifiers.v1.dialects.chat import message_to_wire
21
23
  from verifiers.v1.errors import ProviderError, model_error
@@ -24,7 +26,6 @@ from verifiers.v1.types import (
24
26
  AssistantMessage,
25
27
  FinishReason,
26
28
  Response,
27
- SamplingConfig,
28
29
  SamplingMask,
29
30
  Tool,
30
31
  ToolCall,
@@ -131,8 +132,11 @@ def response_from_generate(
131
132
  # TODO: we need a better way for renderers to expose this
132
133
  and getattr(tc, "status", None) != ToolCallParseStatus.UNKNOWN_TOOL
133
134
  ] or None
134
- prompt_ids = result.get("prompt_ids") or []
135
- completion_ids = result.get("completion_ids") or []
135
+ # The renderer tokenizes into lists; the turn's streams hold one array each from here on.
136
+ prompt_ids = np.asarray(result.get("prompt_ids") or (), dtype=np.int32)
137
+ completion_ids = np.asarray(result.get("completion_ids") or (), dtype=np.int32)
138
+ renderer_prompt_ids = result.get("renderer_prompt_ids")
139
+ completion_logprobs = result.get("completion_logprobs")
136
140
  # Per-message token spans (the renderer's attribution) let the trace graph store each
137
141
  # message's tokens once; carried transiently on TurnTokens and consumed by turn.commit().
138
142
  attribution = result.get("prompt_attribution")
@@ -167,16 +171,22 @@ def response_from_generate(
167
171
  usage=Usage(
168
172
  prompt_tokens=len(prompt_ids), completion_tokens=len(completion_ids)
169
173
  ),
170
- # generate() returns owned, typed lists. Skip revalidation here to avoid copying
171
- # million-token contexts synchronously on the event loop.
174
+ # The streams are already typed arrays, so skip revalidation.
172
175
  tokens=TurnTokens.model_construct(
173
176
  prompt_ids=prompt_ids,
174
- renderer_prompt_ids=result.get("renderer_prompt_ids"),
177
+ renderer_prompt_ids=np.asarray(renderer_prompt_ids, dtype=np.int32)
178
+ if renderer_prompt_ids is not None
179
+ else None,
175
180
  bridged=bridged_turn is not None,
176
181
  completion_ids=completion_ids,
177
- completion_logprobs=result.get("completion_logprobs") or [],
182
+ completion_logprobs=np.asarray(
183
+ () if completion_logprobs is None else completion_logprobs,
184
+ dtype=np.float32,
185
+ ),
178
186
  message_spans=message_spans,
179
- is_content=attribution.is_content if attribution is not None else None,
187
+ is_content=np.asarray(attribution.is_content, dtype=np.bool_)
188
+ if attribution is not None and attribution.is_content is not None
189
+ else None,
180
190
  mm_placeholders=mm_placeholders,
181
191
  mm_token_type_id_map=mm_token_type_id_map,
182
192
  routed_experts=result.get("routed_experts"),
@@ -381,7 +391,13 @@ class TrainClient(Client):
381
391
  prompt_ids: list[int] | None = None
382
392
  prompt_attribution: RenderedTokens | None = None
383
393
  model = body["model"]
384
- sampling_params = sampling.model_dump(exclude_none=True)
394
+ # Neutral defaults stop vLLM from applying the model's generation_config
395
+ # top_k/min_p, so the sampled distribution is the one the trainer replays.
396
+ sampling_params = {
397
+ "top_k": -1,
398
+ "min_p": 0.0,
399
+ **sampling.model_dump(exclude_none=True),
400
+ }
385
401
  chat_template_kwargs = sampling_params.pop("chat_template_kwargs", None)
386
402
  cache_salt = sampling_params.pop("cache_salt", None)
387
403
  pool = ElasticRendererPool(
@@ -17,8 +17,8 @@ from verifiers.v1.configs.deployment import DeploymentConfig
17
17
  from verifiers.v1.configs.harness import HarnessConfig, WireHarnessConfig
18
18
  from verifiers.v1.configs.retries import RetryConfig
19
19
  from verifiers.v1.configs.runtime import PrimeConfig, RuntimeConfig
20
+ from verifiers.v1.configs.sampling import SamplingConfig
20
21
  from verifiers.v1.configs.scoring import ScoringConfig
21
- from verifiers.v1.types import SamplingConfig
22
22
  from verifiers.v1.utils.generic import merge_defaults
23
23
 
24
24
 
@@ -54,9 +54,10 @@ class AgentConfig(BaseConfig):
54
54
  model: str | None = None
55
55
  """Model id (None = the run's model, i.e. the policy under evaluation/training)."""
56
56
  client: ClientConfig | None = None
57
- """Endpoint override (None = the run's client)."""
57
+ """Endpoint override (None = the run's client, with the run's sampling)."""
58
58
  sampling: SamplingConfig | None = None
59
- """Sampling values merged onto the run's sampling."""
59
+ """Sampling values merged onto the run's sampling. A seat with its own `client`
60
+ does not inherit the run's sampling: it uses only these values."""
60
61
 
61
62
  max_turns: int | None = None
62
63
  """Max model turns per run (None = no limit)."""
@@ -148,8 +149,14 @@ def resolve_agent(
148
149
  ) -> AgentConfig:
149
150
  """`spec` with what it leaves unset filled from the run's defaults; its own
150
151
  sampling values merge over the run's. The one place a seat's identity resolves,
151
- for configured agent roles."""
152
- defaults = sampling or SamplingConfig()
152
+ for configured agent roles.
153
+
154
+ The run's sampling belongs to the run's client: it can carry endpoint-specific
155
+ keys (e.g. vLLM's `top_k`) that another provider rejects. A seat that pins its
156
+ own `client` therefore starts from empty sampling."""
157
+ defaults = (
158
+ sampling if sampling is not None and spec.client is None else SamplingConfig()
159
+ )
153
160
  overrides = (spec.sampling or SamplingConfig()).model_dump(exclude_unset=True)
154
161
  merged = {**defaults.model_dump(), **merge_defaults(defaults, overrides)}
155
162
  if spec.max_turn_tokens is not None:
@@ -9,8 +9,8 @@ from pydantic_config import BaseConfig
9
9
  from verifiers.v1.configs.cli.env import narrowed_env_annotation, resolve_env_field
10
10
  from verifiers.v1.configs.client import ClientConfig, EvalClientConfig
11
11
  from verifiers.v1.configs.env import EnvConfig, SingleAgentEnvConfig
12
+ from verifiers.v1.configs.sampling import SamplingConfig
12
13
  from verifiers.v1.configs.select import SelectCLIConfig
13
- from verifiers.v1.types import SamplingConfig
14
14
 
15
15
 
16
16
  def default_run_name(env: EnvConfig, model: str) -> str:
@@ -12,14 +12,13 @@ from verifiers.v1.configs.agent import (
12
12
  agent_config_fields,
13
13
  merge_agent_defaults,
14
14
  )
15
- from verifiers.v1.configs.harness import HarnessConfig
15
+ from verifiers.v1.configs.harness import ID, HarnessConfig
16
16
  from verifiers.v1.configs.interception import (
17
17
  ElasticInterceptionPoolConfig,
18
18
  InterceptionConfig,
19
19
  )
20
20
  from verifiers.v1.configs.retries import RetryConfig
21
21
  from verifiers.v1.configs.taskset import SharedTasksetConfig, TasksetConfig
22
- from verifiers.v1.types import ID
23
22
 
24
23
 
25
24
  class TimeoutConfig(BaseConfig):
@@ -9,7 +9,12 @@ from typing import Annotated, Literal
9
9
  from pydantic import ConfigDict, Field, FiniteFloat
10
10
  from pydantic_config import BaseConfig
11
11
 
12
- from verifiers.v1.types import ID, DialectName
12
+ ID = str
13
+ """Plugin id: the name of an installed package exporting the plugin."""
14
+
15
+ DialectName = Literal["chat_completions", "responses", "anthropic_messages"]
16
+ """A model API wire format: a `Dialect.name`, and the values of the harness `dialect`
17
+ setting."""
13
18
 
14
19
  PinnedVersion = Annotated[str, Field(pattern=r"^[A-Za-z0-9._+-]+$")]
15
20
  """A release/tag a harness pins its program install to."""
@@ -8,7 +8,8 @@ from typing import Any
8
8
  from pydantic import BaseModel, FiniteFloat, SerializeAsAny
9
9
 
10
10
  from verifiers.v1.configs.client import BaseClientConfig
11
- from verifiers.v1.types import ID, SamplingConfig
11
+ from verifiers.v1.configs.harness import ID
12
+ from verifiers.v1.configs.sampling import SamplingConfig
12
13
 
13
14
 
14
15
  class JudgeConfig(BaseClientConfig):
@@ -0,0 +1,35 @@
1
+ """Sampling knobs for model requests."""
2
+
3
+ from typing import Any
4
+
5
+ from pydantic import AliasChoices, BaseModel, ConfigDict, Field, model_validator
6
+
7
+
8
+ class SamplingConfig(BaseModel):
9
+ """Typed sampling knobs; provider-specific keys pass through (extra='allow')."""
10
+
11
+ model_config = ConfigDict(extra="allow")
12
+ temperature: float | None = None
13
+ top_p: float | None = None
14
+ reasoning_effort: str | None = None
15
+ max_tokens: int | None = Field(
16
+ None, validation_alias=AliasChoices("max_tokens", "max_completion_tokens")
17
+ )
18
+
19
+ @model_validator(mode="before")
20
+ @classmethod
21
+ def normalize(cls, data: Any) -> Any:
22
+ """Use one key per parameter before merging overrides, retaining null clears."""
23
+ if not isinstance(data, dict):
24
+ return data
25
+ normalized = {}
26
+ for layer in (data.get("extra_body") or {}, data):
27
+ layer = dict(layer)
28
+ if "max_completion_tokens" in layer:
29
+ layer.setdefault("max_tokens", layer.pop("max_completion_tokens"))
30
+ layer.pop("extra_body", None)
31
+ normalized.update(layer)
32
+ return normalized
33
+
34
+
35
+ Sampling = SamplingConfig
@@ -5,8 +5,8 @@ from pathlib import Path
5
5
  from pydantic import SerializeAsAny
6
6
  from pydantic_config import BaseConfig
7
7
 
8
+ from verifiers.v1.configs.harness import ID
8
9
  from verifiers.v1.configs.task import TaskConfig
9
- from verifiers.v1.types import ID
10
10
 
11
11
 
12
12
  class SharedTasksetConfig(BaseConfig):
@@ -15,6 +15,7 @@ from anthropic.types import Message as AnthropicMessage
15
15
  from anthropic.types import Usage as AnthropicUsage
16
16
 
17
17
  from verifiers.v1.configs.runtime import NetworkPolicyConfig
18
+ from verifiers.v1.configs.sampling import Sampling, SamplingConfig
18
19
  from verifiers.v1.dialects.base import (
19
20
  Dialect,
20
21
  RawRequest,
@@ -34,8 +35,6 @@ from verifiers.v1.types import (
34
35
  Messages,
35
36
  Request,
36
37
  Response,
37
- Sampling,
38
- SamplingConfig,
39
38
  SystemMessage,
40
39
  TextContentPart,
41
40
  Tool,
@@ -22,18 +22,14 @@ from typing import Any, ClassVar, Generic, TypeVar
22
22
  from pydantic import AnyHttpUrl, BaseModel, ValidationError
23
23
  from pydantic_core import from_json
24
24
 
25
+ from verifiers.v1.configs.harness import DialectName
25
26
  from verifiers.v1.configs.runtime import (
26
27
  NetworkPolicyConfig,
27
28
  intersect_network_hosts,
28
29
  parse_network_rule,
29
30
  )
30
- from verifiers.v1.types import (
31
- DialectName,
32
- Request,
33
- Response,
34
- Sampling,
35
- SamplingConfig,
36
- )
31
+ from verifiers.v1.configs.sampling import Sampling, SamplingConfig
32
+ from verifiers.v1.types import Request, Response
37
33
 
38
34
  RespT = TypeVar("RespT", bound=BaseModel)
39
35
  RawRequest = dict[str, Any]
@@ -18,6 +18,7 @@ from openai.types.chat import ChatCompletion
18
18
  from openai.types.chat.chat_completion import Choice
19
19
 
20
20
  from verifiers.v1.configs.runtime import NetworkPolicyConfig
21
+ from verifiers.v1.configs.sampling import Sampling, SamplingConfig
21
22
  from verifiers.v1.dialects.base import (
22
23
  Dialect,
23
24
  RawRequest,
@@ -33,8 +34,6 @@ from verifiers.v1.types import (
33
34
  Messages,
34
35
  Request,
35
36
  Response,
36
- Sampling,
37
- SamplingConfig,
38
37
  SystemMessage,
39
38
  Tool,
40
39
  ToolCall,
@@ -19,6 +19,7 @@ from openai.types.responses.response_usage import (
19
19
  from pydantic import BaseModel, ConfigDict
20
20
 
21
21
  from verifiers.v1.configs.runtime import NetworkPolicyConfig
22
+ from verifiers.v1.configs.sampling import Sampling, SamplingConfig
22
23
  from verifiers.v1.dialects.base import (
23
24
  Dialect,
24
25
  RawRequest,
@@ -38,8 +39,6 @@ from verifiers.v1.types import (
38
39
  Messages,
39
40
  Request,
40
41
  Response,
41
- Sampling,
42
- SamplingConfig,
43
42
  SystemMessage,
44
43
  TextContentPart,
45
44
  Tool,
@@ -17,9 +17,9 @@ from verifiers.v1.clients import EvalClientConfig
17
17
  from verifiers.v1.configs.cli.env import narrowed_env_annotation, resolve_env_field
18
18
  from verifiers.v1.configs.cli.eval import RunConfig, default_run_name
19
19
  from verifiers.v1.configs.env import EnvConfig
20
+ from verifiers.v1.configs.sampling import SamplingConfig
20
21
  from verifiers.v1.configs.select import SelectCLIConfig
21
22
  from verifiers.v1.envs.single_agent import SingleAgentEnvConfig
22
- from verifiers.v1.types import SamplingConfig
23
23
 
24
24
 
25
25
  class GEPAConfig(BaseConfig):