verifiers 0.2.2.dev12__py3-none-any.whl → 0.2.2.dev13__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
@@ -147,13 +147,15 @@ class Agent:
147
147
  harness_config = harness_config_type("bash")(id="bash")
148
148
  self.config = config
149
149
  self.harness = load_harness(harness_config)
150
- if client is None:
150
+ self._owns_client = client is None
151
+ if self._owns_client:
151
152
  client = resolve_client(config.client or EvalClientConfig())
152
153
  self.ctx = ModelContext(
153
154
  model=config.model,
154
155
  client=client,
155
156
  sampling=config.sampling if config.sampling is not None else Sampling(),
156
157
  )
158
+ self._closed = False
157
159
  self.runtime_config: RuntimeConfig = self.harness.config.runtime
158
160
  self.interception = interception
159
161
  self.limits = RolloutLimits(
@@ -173,6 +175,8 @@ class Agent:
173
175
  async def __aenter__(self) -> "Agent":
174
176
  if self._entered:
175
177
  raise RuntimeError("Agent is already entered; enter it once and share it")
178
+ if self._closed:
179
+ raise RuntimeError("Agent is closed; create a new agent")
176
180
  self._entered = True
177
181
  if self.interception is None:
178
182
  # Sized to the runtime policy (remote needs the tunnel); runs the
@@ -186,14 +190,22 @@ class Agent:
186
190
  # A failed __aenter__ gets no __aexit__ from `async with`: unwind
187
191
  # here, or the agent stays "already entered" forever.
188
192
  self._entered, self._server = False, None
193
+ if self._owns_client:
194
+ self._closed = True
195
+ await self.ctx.client.close()
189
196
  raise
190
197
  return self
191
198
 
192
199
  async def __aexit__(self, *exc) -> None:
193
200
  self._entered = False
194
201
  server, self._server = self._server, None
195
- if server is not None:
196
- await server.__aexit__(*exc)
202
+ try:
203
+ if server is not None:
204
+ await server.__aexit__(*exc)
205
+ finally:
206
+ if self._owns_client:
207
+ self._closed = True
208
+ await self.ctx.client.close()
197
209
 
198
210
  def _interception_for(
199
211
  self, run_is_local: bool, task: Task, shared_tools: Mapping
@@ -230,6 +242,8 @@ class Agent:
230
242
  `on_trace` observes the trace the moment it's minted, before any I/O.
231
243
  Retries whole while the trace ends with a retryable error (`config.retries`)
232
244
  — never into a borrowed box; the final trace keeps earlier attempts' errors."""
245
+ if self._closed:
246
+ raise RuntimeError("Agent is closed; create a new agent")
233
247
  retry = self.config.retries
234
248
  history: list = []
235
249
  for attempt in range(retry.max_retries + 1):
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: verifiers
3
- Version: 0.2.2.dev12
3
+ Version: 0.2.2.dev13
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
@@ -168,7 +168,7 @@ verifiers/utils/tool_utils.py,sha256=gInWZODWQUZN4TyEMuuITyOUm9qlHJxtcvr1zZl_zJs
168
168
  verifiers/utils/usage_utils.py,sha256=GPLC0xGY_Obrr8X7huWY-2iODZ7tgX-MtO8WSDN4rXI,3904
169
169
  verifiers/utils/version_utils.py,sha256=am3hZLnlaUWTFdllGZR1VMN91hEhiiE8FDmPf1cOG1k,2642
170
170
  verifiers/v1/__init__.py,sha256=r8khgi7_KSY4AfevEefSslyxytScmMzzCBA6kjqvd1I,6653
171
- verifiers/v1/agent.py,sha256=149ex6npYxa0Jba3zJARiS4bt-56zAR5YfSdbCmHmmA,19378
171
+ verifiers/v1/agent.py,sha256=EapDEWf0yeCaSYjD7vZPECbO2L4pd3FAYwhYzcSdzXU,19925
172
172
  verifiers/v1/decorators.py,sha256=XRMkUQSyvXCYP5fOwzBYV5qEOlxLg6rzYhnhrHHHTIQ,3838
173
173
  verifiers/v1/env.py,sha256=XQHzcTCNLmAbupkFp3edvUJqtSxs6U3mJHVz3hAI6Y4,24734
174
174
  verifiers/v1/episode.py,sha256=a-8IwYecfaBAD0NPbPREQWUybx-KrgLev2JHC-shjgU,2301
@@ -315,8 +315,8 @@ verifiers/v1/utils/logging.py,sha256=OcMHA6NsYux3oIzjPuI95rDWmFBHNcHDjZeNIhXTX-Y
315
315
  verifiers/v1/utils/memory.py,sha256=ZkIvGk6uITAH5sKon65LifKPbvZr8mJ__PVc23FZpOQ,1835
316
316
  verifiers/v1/utils/sampling.py,sha256=JczGzBn6s3wsIrSY2Hy3hE8m6NreNgsNzhSjDikQqX0,1037
317
317
  verifiers/v1/utils/version.py,sha256=75ZtI2NHBmlb52KpcKLUpiSXp8q4bASr7uKeXoCKlT8,1582
318
- verifiers-0.2.2.dev12.dist-info/METADATA,sha256=BeDnNkyFfjrP8k6-vAVe8-xauUQKgE7aYy4sAmFielc,4541
319
- verifiers-0.2.2.dev12.dist-info/WHEEL,sha256=lCkmxWfQsSc9CfIClYeavTdQeEX2toPqufh9gI35EQA,87
320
- verifiers-0.2.2.dev12.dist-info/entry_points.txt,sha256=dF82JUYEFslR1AOW8LZfuBWeZeQoyX4wCRrduklg8-I,551
321
- verifiers-0.2.2.dev12.dist-info/licenses/LICENSE,sha256=v0RrUsdV3IDoZhrRce297IXS3xMHNJ-_LdLpFAUWb9k,1072
322
- verifiers-0.2.2.dev12.dist-info/RECORD,,
318
+ verifiers-0.2.2.dev13.dist-info/METADATA,sha256=COLxgdKb_Q39fmAy3uwjXxCy4YGakvCyrZFF2W0p1W4,4541
319
+ verifiers-0.2.2.dev13.dist-info/WHEEL,sha256=lCkmxWfQsSc9CfIClYeavTdQeEX2toPqufh9gI35EQA,87
320
+ verifiers-0.2.2.dev13.dist-info/entry_points.txt,sha256=dF82JUYEFslR1AOW8LZfuBWeZeQoyX4wCRrduklg8-I,551
321
+ verifiers-0.2.2.dev13.dist-info/licenses/LICENSE,sha256=v0RrUsdV3IDoZhrRce297IXS3xMHNJ-_LdLpFAUWb9k,1072
322
+ verifiers-0.2.2.dev13.dist-info/RECORD,,