verifiers 0.4.2.dev56__py3-none-any.whl → 0.4.2.dev58__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/__init__.py CHANGED
@@ -14,7 +14,13 @@ if TYPE_CHECKING:
14
14
 
15
15
  from verifiers.v1.acp import ACPConfig, ACPHarness, ACPTurn
16
16
  from verifiers.v1.agent import Agent, Agents, Interaction, Segment, make_agent
17
- from verifiers.v1.clients import Client, ModelContext, resolve_client
17
+ from verifiers.v1.clients import (
18
+ Client,
19
+ ModelContext,
20
+ ModelRoute,
21
+ RouteRejected,
22
+ resolve_client,
23
+ )
18
24
  from verifiers.v1.configs.agent import AgentConfig
19
25
  from verifiers.v1.configs.cli.env import narrowed_env_annotation, resolve_env_field
20
26
  from verifiers.v1.configs.client import (
@@ -41,7 +47,6 @@ if TYPE_CHECKING:
41
47
  PrimeConfig,
42
48
  PrimeVolume,
43
49
  RuntimeConfig,
44
- SubprocessConfig,
45
50
  )
46
51
  from verifiers.v1.configs.sampling import Sampling, SamplingConfig
47
52
  from verifiers.v1.configs.scoring import ScoringConfig
@@ -253,6 +258,8 @@ _NAME_TO_MODULE = {
253
258
  "Messages": "verifiers.v1.types",
254
259
  "ModelCall": "verifiers.v1.trace",
255
260
  "ModelContext": "verifiers.v1.clients",
261
+ "ModelRoute": "verifiers.v1.clients",
262
+ "RouteRejected": "verifiers.v1.clients",
256
263
  "NetworkPolicyConfig": "verifiers.v1.configs.runtime",
257
264
  "PATCH_CAP_BYTES": "verifiers.v1.utils.git",
258
265
  "ParentLink": "verifiers.v1.semantic",
@@ -297,7 +304,6 @@ _NAME_TO_MODULE = {
297
304
  "State": "verifiers.v1.state",
298
305
  "StateT": "verifiers.v1.state",
299
306
  "StopFunctionConfig": "verifiers.v1.configs.task",
300
- "SubprocessConfig": "verifiers.v1.configs.runtime",
301
307
  "SystemMessage": "verifiers.v1.types",
302
308
  "TRACE_VERSION": "verifiers.v1.trace",
303
309
  "Task": "verifiers.v1.task",
@@ -481,12 +487,13 @@ __all__ = [ # noqa: RUF022 - grouped by public API area
481
487
  "ACPHarness",
482
488
  "ACPTurn",
483
489
  "ModelContext",
490
+ "ModelRoute",
491
+ "RouteRejected",
484
492
  "Runtime",
485
493
  "RuntimeProcess",
486
494
  "RuntimeConfig",
487
495
  "RuntimeInfo",
488
496
  "ProgramResult",
489
- "SubprocessConfig",
490
497
  "DockerConfig",
491
498
  "BindMount",
492
499
  "CustomRuntimeConfig",
verifiers/v1/agent.py CHANGED
@@ -21,6 +21,7 @@ from typing_extensions import TypeVar
21
21
  from verifiers.v1.clients import (
22
22
  EvalClientConfig,
23
23
  ModelContext,
24
+ ModelRoute,
24
25
  )
25
26
  from verifiers.v1.configs.agent import (
26
27
  AgentConfig,
@@ -685,6 +686,7 @@ class Agent:
685
686
  on_trace: Callable[[Trace], None] | None = None,
686
687
  collect_artifacts: bool = False,
687
688
  on_score: Callable[[Trace, Runtime], Awaitable[None]] | None = None,
689
+ route: ModelRoute | None = None,
688
690
  ) -> Trace:
689
691
  """Run this agent on `task` once and return the trace: one segment — the
690
692
  program runs on the task's prompt until it exits (a multi-turn exchange
@@ -697,9 +699,13 @@ class Agent:
697
699
  (`config.retries`) — never into a borrowed box; every attempt's trace keeps
698
700
  the run's id with its own `attempt`, and the final trace keeps earlier
699
701
  attempts' errors. `on_score(trace, runtime)` runs after task scoring in
700
- the selected verifier workspace, inside its timeout and retry boundary."""
702
+ the selected verifier workspace, inside its timeout and retry boundary.
703
+ `route` is where its model turns go, from the agent's model, client and
704
+ sampling unless given; the caller may change it while the rollout runs
705
+ (`ModelRoute.update`), and a retry takes it as it is then."""
701
706
  if self._closed:
702
707
  raise RuntimeError("Agent is closed; create a new agent")
708
+ route = route or ModelRoute(self.ctx)
703
709
  retry = self.config.retries
704
710
  retry_state = RetryState(retry)
705
711
  history: list = []
@@ -713,6 +719,7 @@ class Agent:
713
719
  on_trace,
714
720
  collect_artifacts,
715
721
  on_score,
722
+ route,
716
723
  trace_id=trace_id,
717
724
  attempt=attempt + 1,
718
725
  )
@@ -752,11 +759,12 @@ class Agent:
752
759
  on_trace: Callable[[Trace], None] | None,
753
760
  collect_artifacts: bool,
754
761
  on_score: Callable[[Trace, Runtime], Awaitable[None]] | None,
762
+ route: ModelRoute,
755
763
  *,
756
764
  trace_id: str,
757
765
  attempt: int,
758
766
  ) -> Trace:
759
- params = self._rollout_params(task, runtime, dict(shared_tools or {}))
767
+ params = self._rollout_params(task, runtime, dict(shared_tools or {}), route)
760
768
  if collect_artifacts:
761
769
  _check_artifact_runtime(params["runtime_config"])
762
770
  run = Rollout(
@@ -791,6 +799,7 @@ class Agent:
791
799
  tools: Mapping[str, SharedToolServer] | None = None,
792
800
  on_trace: Callable[[Trace], None] | None = None,
793
801
  collect_artifacts: bool = False,
802
+ route: ModelRoute | None = None,
794
803
  ) -> AsyncIterator[Interaction]:
795
804
  """Interact with this agent turn-by-turn: a full rollout of `task` where
796
805
  the CALLER is the run's user — the one exchange surface. Yields an
@@ -817,13 +826,15 @@ class Agent:
817
826
  included. A failure while opening the rollout raises before the context
818
827
  is entered (the failed trace is still completed and reported through
819
828
  `on_trace`). An exchange is caller-driven, so `config.retries` does not
820
- apply here."""
829
+ apply here. `route` is where its model turns go, as for `run()`."""
821
830
  if self._closed:
822
831
  raise RuntimeError("Agent is closed; create a new agent")
823
832
  self._check_resume_support()
824
833
  trace_id = uuid.uuid4().hex
825
834
  with scope(trace=short_id(trace_id), agent=self._log_name):
826
- params = self._rollout_params(task, runtime, dict(tools or {}))
835
+ params = self._rollout_params(
836
+ task, runtime, dict(tools or {}), route or ModelRoute(self.ctx)
837
+ )
827
838
  if collect_artifacts:
828
839
  _check_artifact_runtime(params["runtime_config"])
829
840
  run = Rollout(
@@ -857,7 +868,11 @@ class Agent:
857
868
  trace.agent.runtime.borrowed = runtime is not None
858
869
 
859
870
  def _rollout_params(
860
- self, task: Task, runtime: Runtime | None, shared_tools: dict
871
+ self,
872
+ task: Task,
873
+ runtime: Runtime | None,
874
+ shared_tools: dict,
875
+ route: ModelRoute,
861
876
  ) -> dict:
862
877
  """Resolve one run's runtime config, pairing checks, timeouts,
863
878
  interception — shared by `run` and `interaction`."""
@@ -887,7 +902,7 @@ class Agent:
887
902
  return {
888
903
  "agent_config": self.config,
889
904
  "harness": harness,
890
- "ctx": self.ctx,
905
+ "route": route,
891
906
  "runtime_config": runtime_config,
892
907
  "timeouts": timeouts,
893
908
  "limits": self.limits,
@@ -1018,6 +1033,7 @@ class _EpisodeAgent(Agent):
1018
1033
  on_trace: Callable[[Trace], None] | None = None,
1019
1034
  collect_artifacts: bool = False,
1020
1035
  on_score: Callable[[Trace, Runtime], Awaitable[None]] | None = None,
1036
+ route: ModelRoute | None = None,
1021
1037
  ) -> Trace:
1022
1038
  async with self._gate or nullcontext():
1023
1039
  trace = await super().run(
@@ -1027,6 +1043,7 @@ class _EpisodeAgent(Agent):
1027
1043
  on_trace=self._watch(on_trace),
1028
1044
  collect_artifacts=collect_artifacts,
1029
1045
  on_score=self._scoring_callback(on_score),
1046
+ route=route,
1030
1047
  )
1031
1048
  self._completed.append(trace)
1032
1049
  return trace
@@ -1040,6 +1057,7 @@ class _EpisodeAgent(Agent):
1040
1057
  tools: Mapping[str, SharedToolServer] | None = None,
1041
1058
  on_trace: Callable[[Trace], None] | None = None,
1042
1059
  collect_artifacts: bool = False,
1060
+ route: ModelRoute | None = None,
1043
1061
  ) -> AsyncIterator[Interaction]:
1044
1062
  """The agent's `interaction`, with every trace stamped with its standing
1045
1063
  at mint and captured in `completed` at close — an interaction driven from
@@ -1062,6 +1080,7 @@ class _EpisodeAgent(Agent):
1062
1080
  tools=tools if tools is not None else self._shared_for(task),
1063
1081
  on_trace=self._watch(remember),
1064
1082
  collect_artifacts=collect_artifacts,
1083
+ route=route,
1065
1084
  ) as interaction:
1066
1085
  yield interaction
1067
1086
  finally:
verifiers/v1/cli/debug.py CHANGED
@@ -25,7 +25,7 @@ from verifiers.v1.cli.resolve import (
25
25
  with_positional_taskset,
26
26
  )
27
27
  from verifiers.v1.configs.cli.debug import DebugConfig
28
- from verifiers.v1.runtimes import ProgramResult, Runtime, make_backend
28
+ from verifiers.v1.runtimes import ProgramResult, Runtime, backend_cls, make_backend
29
29
  from verifiers.v1.state import state_cls
30
30
  from verifiers.v1.task import Task
31
31
  from verifiers.v1.trace import AgentInfo, Error, Trace, TraceTask
@@ -39,7 +39,7 @@ logger = get_logger(__name__)
39
39
 
40
40
  USAGE = (
41
41
  "usage: uv run vf-debug [<taskset-id>] (--command <cmd> | --script-path <path>) "
42
- "[--runtime.type subprocess] [options] [@ file.toml]\n"
42
+ "[--runtime.type docker] [options] [@ file.toml]\n"
43
43
  " runs setup, then one command or uploaded host script, and saves traces"
44
44
  )
45
45
 
@@ -173,9 +173,8 @@ async def run_action(runtime: Runtime, config: DebugConfig) -> dict[str, Any]:
173
173
  **(await run_timed(runtime.run(["sh", "-lc", config.command], {}), config)),
174
174
  }
175
175
  assert config.script_path is not None
176
- # /tmp keyed by the (run-unique) runtime name: outside the task workdir so the script
177
- # doesn't show up in the repo state being inspected, and never shared between runs on
178
- # the subprocess runtime, where an absolute path is a host path.
176
+ # Keep the script outside the task workdir so it doesn't appear in the repo
177
+ # state being inspected; the runtime name separates concurrent runs.
179
178
  remote_path = f"/tmp/{runtime.name}-script.sh"
180
179
  quoted = shlex.quote(remote_path)
181
180
  command = f"chmod +x {quoted} && {quoted}"
@@ -275,7 +274,7 @@ async def run_debug(config: DebugConfig) -> list[Trace]:
275
274
  f"{type(taskset).__name__} is infinite - bound the run with -n"
276
275
  )
277
276
  tasks = list(taskset)
278
- if isinstance(config.runtime, vf.SubprocessConfig) and any(
277
+ if not backend_cls(config.runtime).SUPPORTS_TASK_IMAGES and any(
279
278
  type(t).NEEDS_CONTAINER or t.data.image for t in tasks
280
279
  ):
281
280
  raise SystemExit(
@@ -35,7 +35,7 @@ from verifiers.v1.grading import (
35
35
  scoring_network,
36
36
  verifier_runtime,
37
37
  )
38
- from verifiers.v1.runtimes import make_backend
38
+ from verifiers.v1.runtimes import backend_cls, make_backend
39
39
  from verifiers.v1.runtimes.deployment import Deployment
40
40
  from verifiers.v1.state import state_cls
41
41
  from verifiers.v1.task import Task
@@ -63,7 +63,7 @@ ResultRow = dict[str, Any]
63
63
 
64
64
  USAGE = (
65
65
  "usage: uv run vf-validate [<taskset-id>] [--only-setup | --only-gold | --only-noop] "
66
- "[-o <output-dir>] [--runtime.type subprocess] [options] [@ file.toml]\n"
66
+ "[-o <output-dir>] [--runtime.type docker] [options] [@ file.toml]\n"
67
67
  " uv run vf-validate @ <run-dir>/configs/validate.json --resume (re-run missing/errored/timed-out tasks)\n"
68
68
  " runs persisted gold and noop (untouched scoring) checks per task (no agent)"
69
69
  )
@@ -448,7 +448,7 @@ async def run_validate(config: ValidateConfig) -> list[dict]:
448
448
  f"{type(taskset).__name__} is infinite - bound the run with -n"
449
449
  )
450
450
  tasks = list(taskset)
451
- if isinstance(config.runtime, vf.SubprocessConfig) and any(
451
+ if not backend_cls(config.runtime).SUPPORTS_TASK_IMAGES and any(
452
452
  type(t).NEEDS_CONTAINER or t.data.image for t in tasks
453
453
  ):
454
454
  raise SystemExit(
@@ -1,4 +1,10 @@
1
- from verifiers.v1.clients.client import Client, ModelContext, resolve_client
1
+ from verifiers.v1.clients.client import (
2
+ Client,
3
+ ModelContext,
4
+ ModelRoute,
5
+ RouteRejected,
6
+ resolve_client,
7
+ )
2
8
  from verifiers.v1.clients.eval import EvalClient
3
9
  from verifiers.v1.clients.train import TrainClient
4
10
  from verifiers.v1.configs.client import (
@@ -15,6 +21,8 @@ __all__ = [
15
21
  "EvalClient",
16
22
  "EvalClientConfig",
17
23
  "ModelContext",
24
+ "ModelRoute",
25
+ "RouteRejected",
18
26
  "TrainClient",
19
27
  "TrainClientConfig",
20
28
  "resolve_client",
@@ -1,8 +1,9 @@
1
1
  """Client interfaces for model inference and relay."""
2
2
 
3
+ import asyncio
3
4
  from abc import ABC, abstractmethod
4
5
  from collections.abc import AsyncIterator, Awaitable, Callable, Mapping
5
- from dataclasses import dataclass, field
6
+ from dataclasses import dataclass, field, replace
6
7
 
7
8
  from verifiers.v1.configs.client import (
8
9
  BaseClientConfig,
@@ -11,6 +12,7 @@ from verifiers.v1.configs.client import (
11
12
  )
12
13
  from verifiers.v1.configs.sampling import Sampling, SamplingConfig
13
14
  from verifiers.v1.dialects import Dialect
15
+ from verifiers.v1.errors import ProviderError
14
16
  from verifiers.v1.graph import PendingTurn
15
17
  from verifiers.v1.types import Response
16
18
 
@@ -88,3 +90,95 @@ class ModelContext:
88
90
  model: str
89
91
  client: ClientConfig
90
92
  sampling: Sampling = field(default_factory=Sampling)
93
+
94
+
95
+ class RouteRejected(Exception):
96
+ """A route change the rollout can't take; its route is left as it was."""
97
+
98
+
99
+ PROBE_TOKENS = 16
100
+ """Output tokens a route change's probe asks for (16 is the least Responses accepts)."""
101
+ PROBE_TIMEOUT = 60.0
102
+ """Seconds a route change's probe may take, retries included, before the change is refused."""
103
+ PROBE_RETRY_DELAYS = (1.0, 4.0)
104
+ """Waits before retrying a probe the endpoint failed transiently (429, 5xx, timeout)."""
105
+
106
+
107
+ class ModelRoute:
108
+ """Where one rollout's model turns go while it runs: its `ModelContext`, which the
109
+ caller may change mid-rollout with `update`. The interception server reads the
110
+ current context on every model request, so a change applies from the rollout's
111
+ next turn (and to any retry of it); a new client config gets the server's shared
112
+ client for it. A scheduler moving a running rollout to another endpoint, or a live
113
+ sampling change, is one `update`. The new endpoint starts without the rollout's
114
+ prompt cache, so the first turn after a move pays for its whole prompt. Model and
115
+ client changes are supported for eval clients only; training routes may update sampling."""
116
+
117
+ def __init__(self, ctx: ModelContext) -> None:
118
+ self.ctx = ctx
119
+ self._updating = asyncio.Lock()
120
+ self.dialect: Dialect | None = None
121
+ """The wire format the rollout's harness speaks, set by the interception server
122
+ from its first model request; None until then."""
123
+
124
+ async def update(
125
+ self,
126
+ *,
127
+ model: str | None = None,
128
+ client: ClientConfig | None = None,
129
+ sampling: Sampling | None = None,
130
+ ) -> None:
131
+ """Change the model, client or sampling of the rollout's next turns; a value left
132
+ out stays as it is. Raises `RouteRejected`, leaving the route unchanged, when the
133
+ rollout can't take the change: a client of another type (eval and train clients
134
+ don't mix within a rollout), a model or client change on a training route, or an
135
+ eval endpoint that refuses a request in the dialect the harness speaks. That probe
136
+ is one short request, sent when the model or client changes once the harness has
137
+ made its first request."""
138
+ changes = {"model": model, "client": client, "sampling": sampling}
139
+ changes = {k: v for k, v in changes.items() if v is not None}
140
+ # One update at a time, each from the context as the last one left it, so a change
141
+ # made while another one's probe was in flight is never undone.
142
+ async with self._updating:
143
+ new = replace(self.ctx, **changes)
144
+ if type(new.client) is not type(self.ctx.client):
145
+ raise RouteRejected(
146
+ f"a rollout's client stays {self.ctx.client.type}: it can't move to a "
147
+ f"{new.client.type} client"
148
+ )
149
+ moved = (new.model, new.client) != (self.ctx.model, self.ctx.client)
150
+ if moved and isinstance(self.ctx.client, TrainClientConfig):
151
+ raise RouteRejected(
152
+ "training routes can't change model or client; only sampling may change"
153
+ )
154
+ if moved and self.dialect is not None:
155
+ await _probe(new, self.dialect)
156
+ self.ctx = new
157
+
158
+
159
+ async def _probe(ctx: ModelContext, dialect: Dialect) -> None:
160
+ """Send `ctx`'s model one short request in `dialect`; RouteRejected if the endpoint refuses
161
+ it, or still fails transiently (429, 5xx) after a retry or two, or PROBE_TIMEOUT passes."""
162
+ message = [{"role": "user", "content": "Reply with OK."}]
163
+ body = {"input": message} if dialect.name == "responses" else {"messages": message}
164
+ sampling = SamplingConfig(max_tokens=PROBE_TOKENS)
165
+ request = dialect.apply_overrides(body, ctx.model, sampling)
166
+ client = resolve_client(ctx.client)
167
+ try:
168
+ async with asyncio.timeout(PROBE_TIMEOUT):
169
+ for delay in (*PROBE_RETRY_DELAYS, None):
170
+ try:
171
+ await client.get_response(dialect, request, sampling)
172
+ return
173
+ except ProviderError as e:
174
+ transient = e.status_code == 429 or e.status_code >= 500
175
+ if not transient or delay is None:
176
+ raise
177
+ await asyncio.sleep(delay)
178
+ except Exception as e:
179
+ reason = "no answer in time" if isinstance(e, TimeoutError) else str(e)
180
+ raise RouteRejected(
181
+ f"{ctx.model} at {ctx.client.base_url} failed a {dialect.name} request: {reason}"
182
+ ) from e
183
+ finally:
184
+ await client.close()
@@ -152,10 +152,6 @@ class NetworkPolicyConfig(BaseConfig):
152
152
  return type(self).model_validate({**values, "allow": allow, "block": block})
153
153
 
154
154
 
155
- class SubprocessConfig(BaseConfig):
156
- type: Literal["subprocess"] = "subprocess"
157
-
158
-
159
155
  class DockerConfig(NetworkPolicyConfig):
160
156
  type: Literal["docker"] = "docker"
161
157
  image: str = "python:3.11-slim"
@@ -275,7 +271,7 @@ class CustomRuntimeConfig(BaseConfig):
275
271
  # Serialized by the runtime type, so a custom runtime's typed config keeps its fields.
276
272
  RuntimeConfig = SerializeAsAny[
277
273
  Annotated[
278
- SubprocessConfig | DockerConfig | PrimeConfig | CustomRuntimeConfig,
274
+ DockerConfig | PrimeConfig | CustomRuntimeConfig,
279
275
  Field(discriminator="type"),
280
276
  ]
281
277
  ]
verifiers/v1/env.py CHANGED
@@ -30,7 +30,7 @@ from verifiers.v1.interception import (
30
30
  requires_tunnel,
31
31
  )
32
32
  from verifiers.v1.mcp import SharedToolServer, serve_shared
33
- from verifiers.v1.runtimes import SubprocessConfig, runtime_is_local
33
+ from verifiers.v1.runtimes import runtime_is_local
34
34
  from verifiers.v1.task import Task
35
35
  from verifiers.v1.trace import Error, Trace, TraceTask
36
36
  from verifiers.v1.utils.format import format_time
@@ -131,22 +131,6 @@ class Env(ABC, Generic[ConfigT]):
131
131
  if key not in loaded:
132
132
  loaded[key] = load_harness(cfg)
133
133
  self._harnesses[name] = loaded[key]
134
- warned: set[str] = set()
135
- for name, harness in self._harnesses.items():
136
- # Warn once per distinct harness; tool-less chat loops are exempt.
137
- if (
138
- harness.EXECUTES_CODE
139
- and isinstance(self._agent_specs[name].runtime, SubprocessConfig)
140
- and harness.config.id not in warned
141
- ):
142
- warned.add(harness.config.id)
143
- logger.warning(
144
- "Harness %r is running in the subprocess runtime on the local system. "
145
- "Local files and settings may affect the evaluation; use subprocess only "
146
- "for debugging. Use --env.<role>.runtime.type docker or prime "
147
- "for an isolated run.",
148
- harness.config.id,
149
- )
150
134
  # Serving resources, live only inside `serving()`; the env's agents borrow them.
151
135
  self._shared_tools: dict[str, SharedToolServer] = {}
152
136
  self._interception: Interception | None = None
@@ -23,6 +23,7 @@ from verifiers.v1.judges.rubric import (
23
23
  score_verdicts,
24
24
  weighted_score,
25
25
  )
26
+ from verifiers.v1.runtimes import backend_cls
26
27
  from verifiers.v1.utils.compile import validate_pairing
27
28
 
28
29
  VERDICT_FILE = "/tmp/verdict.json"
@@ -317,7 +318,7 @@ class AgenticJudgeEnv(vf.Env[AgenticJudgeEnvConfig]):
317
318
  workspace = (
318
319
  policy.runtime if policy.mode == "isolated" else None
319
320
  ) or self.config.solver.runtime
320
- if isinstance(workspace, vf.SubprocessConfig):
321
+ if not backend_cls(workspace).SUPPORTS_TASK_IMAGES:
321
322
  raise TypeError("agentic judging requires a container scoring workspace")
322
323
  validate_pairing(self._harnesses["judge"], JudgeTask, workspace)
323
324
 
@@ -758,11 +758,16 @@ class InterceptionServer(Interception):
758
758
  body = from_json(raw)
759
759
  except ValueError:
760
760
  body = json.loads(raw)
761
- body = dialect.apply_overrides(body, session.ctx.model, session.ctx.sampling)
761
+ # One context for the whole request: a route updated while it is in flight applies
762
+ # from the next request, never to half of this one.
763
+ ctx = session.ctx
764
+ session.route.dialect = dialect
765
+ session.client = client = self._client(ctx.client)
766
+ body = dialect.apply_overrides(body, ctx.model, ctx.sampling)
762
767
  streaming = dialect.streaming(body)
763
768
  # A streamed request is served whole once its turn commits: the eval client's
764
769
  # provider stream is read to the end, and the train client generates the response.
765
- relay = streaming and not isinstance(session.ctx.client, TrainClientConfig)
770
+ relay = streaming and not isinstance(ctx.client, TrainClientConfig)
766
771
  req_hash = await _request_digest(raw)
767
772
  # Keep `read()` for aiohttp's size guard, then release its cache and our local
768
773
  # alias after parsing so the wire body does not survive model inference.
@@ -951,7 +956,7 @@ class InterceptionServer(Interception):
951
956
  # What actually goes upstream: the native body with the rollout's model +
952
957
  # sampling imposed — recorded raw on the trace, per call.
953
958
  if relay:
954
- reply = await session.client.relay(
959
+ reply = await client.relay(
955
960
  dialect,
956
961
  body,
957
962
  headers=upstream_headers,
@@ -959,10 +964,10 @@ class InterceptionServer(Interception):
959
964
  )
960
965
  call_response, events = await _collect_stream(dialect, reply)
961
966
  else:
962
- call_response = await session.client.get_response(
967
+ call_response = await client.get_response(
963
968
  dialect,
964
969
  body,
965
- session.ctx.sampling,
970
+ ctx.sampling,
966
971
  headers=upstream_headers,
967
972
  session_id=upstream_session_id,
968
973
  turn=turn,
@@ -1073,9 +1078,10 @@ class InterceptionServer(Interception):
1073
1078
  logger.debug("Received %s request", route)
1074
1079
  try:
1075
1080
  body = await request.json()
1076
- body["model"] = session.ctx.model
1081
+ ctx = session.ctx
1082
+ body["model"] = ctx.model
1077
1083
  body = self.mediate_capabilities(session, dialect, body)[0]
1078
- result = await session.client.relay_aux(
1084
+ result = await self._client(ctx.client).relay_aux(
1079
1085
  dialect, route, body, headers=request.headers
1080
1086
  )
1081
1087
  except RolloutError as e: