verifiers 0.4.2.dev119__py3-none-any.whl → 0.4.2.dev123__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.
@@ -1,5 +1,6 @@
1
1
  """Run Hermes Agent against interception through its native ACP server."""
2
2
 
3
+ import hashlib
3
4
  import json
4
5
  from pathlib import Path
5
6
  from typing import Literal
@@ -16,20 +17,39 @@ from verifiers.v1.trace import Trace
16
17
  from verifiers.v1.types import Message
17
18
 
18
19
  PROGRAM_SOURCE = (Path(__file__).resolve().parent / "program.py").read_text()
19
- HERMES_DIR = "/var/tmp/vf-hermes-agent-{version}"
20
+ HERMES_DIR = "/var/tmp/vf-hermes-agent-{version}-{digest}"
20
21
  INSTALL = f"""
21
22
  set -e
22
23
  {_ENSURE_UV}
23
24
  command -v curl >/dev/null || (apt-get update -qq && apt-get install -y -qq curl ca-certificates >/dev/null)
24
25
  curl -fsSL "https://github.com/NousResearch/hermes-agent/archive/refs/tags/$AGENT_HERMES_VERSION.tar.gz" \\
25
26
  | tar -xz --strip-components=1 -C "$AGENT_HERMES_DIR"
26
- # Replay one reasoning key: strict providers reject Hermes' duplicated aliases on custom routes.
27
+ # Replay reasoning_content and reasoning_details (not the duplicated `reasoning` alias) on custom routes.
27
28
  # Recheck: https://github.com/NousResearch/hermes-agent/blob/v0.23.2/agent/message_sanitization.py#L733
28
29
  sed -i '/^_REASONING_CARRIER_ROUTES: tuple = (/a\\
29
- (_DEFAULT_CARRIERS, frozenset({{"custom"}}), ()),' "$AGENT_HERMES_DIR/agent/message_sanitization.py"
30
+ (frozenset({{RC, RD}}), frozenset({{"custom"}}), ()),' "$AGENT_HERMES_DIR/agent/message_sanitization.py"
31
+ grep -qF '(frozenset({{RC, RD}}), frozenset({{"custom"}}), ())' "$AGENT_HERMES_DIR/agent/message_sanitization.py"
32
+ # Interception relays to the configured upstream; keep Claude on native and other unmatched models on minimax (signed + invalidation).
33
+ # Recheck: https://github.com/NousResearch/hermes-agent/blob/v0.23.2/agent/anthropic_thinking_policy.py#L80-L91
34
+ sed -i 's/_is_claude_platform_endpoint(url)),/_is_claude_platform_endpoint(url) or (isinstance(model, str) and "claude" in model.lower())),/' "$AGENT_HERMES_DIR/agent/anthropic_thinking_policy.py"
35
+ sed -i 's/), "third_party")/), "minimax")/' "$AGENT_HERMES_DIR/agent/anthropic_thinking_policy.py"
36
+ grep -qF '"claude" in model.lower()' "$AGENT_HERMES_DIR/agent/anthropic_thinking_policy.py"
37
+ grep -qF '), "minimax")' "$AGENT_HERMES_DIR/agent/anthropic_thinking_policy.py"
38
+ # Preserve empty-string signatures (e.g. `signature: ""`) verbatim on Anthropic thinking replay without bypassing invalidation.
39
+ # Recheck: https://github.com/NousResearch/hermes-agent/blob/v0.23.2/agent/anthropic_message_convert.py#L301
40
+ # Recheck: https://github.com/NousResearch/hermes-agent/blob/v0.23.2/agent/anthropic_message_convert.py#L571
41
+ sed -i 's/if b.get("signature") else out/if isinstance(b.get("signature"), str) else out/' "$AGENT_HERMES_DIR/agent/anthropic_message_convert.py"
42
+ sed -i 's/signed = b.get("data") if is_redacted else b.get("signature")/signed = bool(b.get("data")) if is_redacted else isinstance(b.get("signature"), str)/' "$AGENT_HERMES_DIR/agent/anthropic_message_convert.py"
43
+ grep -qF 'if isinstance(b.get("signature"), str) else out' "$AGENT_HERMES_DIR/agent/anthropic_message_convert.py"
44
+ grep -qF 'signed = bool(b.get("data")) if is_redacted else isinstance(b.get("signature"), str)' "$AGENT_HERMES_DIR/agent/anthropic_message_convert.py"
45
+ # Replay tool-call ids verbatim: the upstream minted them and takes them back, and rewriting Kimi's `functions.<name>:<n>` ids forks the trace.
46
+ # Recheck: https://github.com/NousResearch/hermes-agent/blob/v0.23.2/agent/anthropic_message_convert.py#L117
47
+ sed -i 's/return (re\\.sub(r"\\[^a-zA-Z0-9_-]", "_", tool_id) if tool_id else "") or "tool_0"/return tool_id or "tool_0"/' "$AGENT_HERMES_DIR/agent/anthropic_message_convert.py"
48
+ grep -qF 'return tool_id or "tool_0"' "$AGENT_HERMES_DIR/agent/anthropic_message_convert.py"
30
49
  uv sync --project "$AGENT_HERMES_DIR" --python 3.14 --locked --no-dev --extra acp --extra mcp --extra anthropic
31
50
  touch "$AGENT_HERMES_DIR/.ready"
32
51
  """
52
+ INSTALL_DIGEST = hashlib.sha256(INSTALL.encode()).hexdigest()[:12]
33
53
 
34
54
 
35
55
  class HermesAgentHarnessConfig(HarnessConfig):
@@ -57,7 +77,9 @@ class HermesAgentHarness(ACPHarness[HermesAgentHarnessConfig]):
57
77
 
58
78
  async def setup(self, runtime: Runtime) -> None:
59
79
  # Hermes needs its source-tree assets and supports editable installs only.
60
- directory = HERMES_DIR.format(version=self.config.version)
80
+ directory = HERMES_DIR.format(
81
+ version=self.config.version, digest=INSTALL_DIGEST
82
+ )
61
83
  await ensure_installed(
62
84
  runtime,
63
85
  directory=directory,
@@ -141,7 +163,7 @@ class HermesAgentHarness(ACPHarness[HermesAgentHarnessConfig]):
141
163
  return ACPConfig(
142
164
  env=env,
143
165
  command=[
144
- f"{HERMES_DIR.format(version=self.config.version)}/.venv/bin/python",
166
+ f"{HERMES_DIR.format(version=self.config.version, digest=INSTALL_DIGEST)}/.venv/bin/python",
145
167
  "-P", # Keep task files from shadowing installed Hermes modules.
146
168
  "-c",
147
169
  PROGRAM_SOURCE,
@@ -6,8 +6,42 @@
6
6
  import sys
7
7
  from pathlib import Path
8
8
 
9
+ from minisweagent.models.litellm_model import LitellmModel
9
10
  from minisweagent.run.mini import app
10
11
 
12
+ # LiteLLM nests OpenRouter `reasoning` and `reasoning_details` under
13
+ # `provider_specific_fields` and sends them nested on replay; promote them back
14
+ # to top-level wire keys without altering `reasoning_content`-only turns.
15
+ _orig_prepare = LitellmModel._prepare_messages_for_api
16
+
17
+
18
+ def _prepare_with_reasoning_details(self, messages):
19
+ prepared = _orig_prepare(self, messages)
20
+ for msg in prepared:
21
+ psf = msg.get("provider_specific_fields")
22
+ if msg.get("role") != "assistant" or not isinstance(psf, dict):
23
+ continue
24
+ details = psf.get("reasoning_details")
25
+ reasoning = psf.get("reasoning")
26
+ if not details and not reasoning:
27
+ continue
28
+ remaining = {
29
+ k: v for k, v in psf.items() if k not in ("reasoning_details", "reasoning")
30
+ }
31
+ if remaining:
32
+ msg["provider_specific_fields"] = remaining
33
+ else:
34
+ msg.pop("provider_specific_fields", None)
35
+ if isinstance(details, list) and details:
36
+ msg["reasoning_details"] = details
37
+ if isinstance(reasoning, str) and reasoning:
38
+ msg["reasoning"] = reasoning
39
+ msg.pop("reasoning_content", None) # LiteLLM's copy of `reasoning`
40
+ return prepared
41
+
42
+
43
+ LitellmModel._prepare_messages_for_api = _prepare_with_reasoning_details
44
+
11
45
  # The harness passes the task as a file. Expanding it in sys.argv keeps it out of
12
46
  # this process's /proc/<pid>/cmdline, which stays as exec'd.
13
47
  index = sys.argv.index("--task-file")
@@ -142,6 +142,11 @@ class PiHarness(ACPHarness[PiHarnessConfig]):
142
142
  model_config["compat"] = {
143
143
  "supportsDeveloperRole": self.config.supports_developer_role
144
144
  }
145
+ elif (
146
+ self.config.dialect == "anthropic_messages"
147
+ and "claude" not in ctx.model.lower()
148
+ ):
149
+ model_config["compat"] = {"allowEmptySignature": True}
145
150
  models = {
146
151
  "providers": {
147
152
  provider: {
@@ -15,6 +15,7 @@ import os
15
15
  import signal
16
16
  import sys
17
17
  from contextlib import redirect_stdout, suppress
18
+ from contextvars import ContextVar
18
19
  from pathlib import Path
19
20
  from uuid import uuid4
20
21
 
@@ -38,6 +39,7 @@ from acp.schema import (
38
39
  )
39
40
  from openai import APIError
40
41
  from stirrup import Agent
42
+ from stirrup.clients import chat_completions_client as _stirrup_cc
41
43
  from stirrup.clients.chat_completions_client import ChatCompletionsClient
42
44
  from stirrup.core.agent import SessionAgent
43
45
  from stirrup.core.exceptions import OutputTokenLimitError
@@ -128,6 +130,72 @@ class RuntimeCodeExecToolProvider(LocalCodeExecToolProvider):
128
130
  await asyncio.wait_for(process.wait(), COMMAND_CLEANUP_TIMEOUT)
129
131
 
130
132
 
133
+ _RAW_REASONING_KEY = "_vf_raw_reasoning"
134
+ _raw_reasoning: ContextVar[list[dict] | None] = ContextVar(
135
+ "_vf_raw_reasoning", default=None
136
+ )
137
+ _orig_to_openai_messages = _stirrup_cc.to_openai_messages
138
+
139
+
140
+ def _to_openai_messages_with_raw_reasoning(msgs, *args, **kwargs):
141
+ wire_messages = _orig_to_openai_messages(msgs, *args, **kwargs)
142
+ for msg, wire in zip(msgs, wire_messages, strict=True):
143
+ metadata = getattr(msg, "metadata", None)
144
+ raw = metadata.get(_RAW_REASONING_KEY) if isinstance(metadata, dict) else None
145
+ if not raw:
146
+ continue
147
+ if raw.get("reasoning"):
148
+ wire.pop("reasoning_content", None) # Stirrup's copy of `reasoning`
149
+ wire.update(raw)
150
+ return wire_messages
151
+
152
+
153
+ _stirrup_cc.to_openai_messages = _to_openai_messages_with_raw_reasoning
154
+
155
+
156
+ class _ReasoningChatClient(ChatCompletionsClient):
157
+ """Replay the provider's `reasoning` and `reasoning_details` fields verbatim."""
158
+
159
+ def __init__(self, *args, **kwargs):
160
+ super().__init__(*args, **kwargs)
161
+ orig_create = self._client.chat.completions.create
162
+
163
+ async def _create(**req_kwargs):
164
+ resp = await orig_create(**req_kwargs)
165
+ msg = resp.choices[0].message if resp.choices else None
166
+ raw = {}
167
+ if msg is not None:
168
+ details = getattr(msg, "reasoning_details", None)
169
+ if isinstance(details, list) and details:
170
+ raw["reasoning_details"] = details
171
+ reasoning = getattr(msg, "reasoning", None)
172
+ if isinstance(reasoning, str) and reasoning:
173
+ raw["reasoning"] = reasoning
174
+ slot = _raw_reasoning.get()
175
+ if raw and slot is not None:
176
+ slot.append(raw)
177
+ if (
178
+ msg is not None
179
+ and not getattr(msg, "reasoning_content", None)
180
+ and "reasoning" in raw
181
+ ):
182
+ msg.reasoning_content = raw["reasoning"]
183
+ return resp
184
+
185
+ self._client.chat.completions.create = _create
186
+
187
+ async def generate(self, messages, tools):
188
+ slot: list[dict] = []
189
+ token = _raw_reasoning.set(slot)
190
+ try:
191
+ result = await super().generate(messages, tools)
192
+ finally:
193
+ _raw_reasoning.reset(token)
194
+ if slot:
195
+ result.metadata[_RAW_REASONING_KEY] = slot[-1]
196
+ return result
197
+
198
+
131
199
  class RuntimeSessionAgent(SessionAgent):
132
200
  """Retain accepted history when a model or summarizer hits its output limit."""
133
201
 
@@ -167,7 +235,7 @@ class Session:
167
235
  client = None
168
236
  try:
169
237
  args = self.args
170
- client = ChatCompletionsClient(
238
+ client = _ReasoningChatClient(
171
239
  model=args.model,
172
240
  base_url=args.base_url,
173
241
  api_key=args.api_key,
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: verifiers
3
- Version: 0.4.2.dev119
3
+ Version: 0.4.2.dev123
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
@@ -87,13 +87,13 @@ verifiers/v1/harnesses/deepseek/gate.mjs,sha256=BxGyYQKOPnZRruI6C-okOeerpoNDGdfN
87
87
  verifiers/v1/harnesses/deepseek/harness.py,sha256=pJfO3f6_ff_UA-nwIXEaD3ufuOdAMZE6fmNYoc9lFVc,5850
88
88
  verifiers/v1/harnesses/deepseek/usage.mjs,sha256=nm6FU0wm25qti5gN2zDJZoDR7Vmug6z_UQFIdZux-qg,2649
89
89
  verifiers/v1/harnesses/hermes_agent/__init__.py,sha256=k84Y8UTTf1KOw5LGqPb2dk-hYFagPevDJBOF7qsR_vo,176
90
- verifiers/v1/harnesses/hermes_agent/harness.py,sha256=62Uh8FPX-Hk_g6ZZjrUE_l6FX_Fy8frc1m2m5waj2hM,6626
90
+ verifiers/v1/harnesses/hermes_agent/harness.py,sha256=onRz5e4rjuoAoHi3FdIpbj2gJ0Wnxch967VjBHjy59o,9122
91
91
  verifiers/v1/harnesses/hermes_agent/program.py,sha256=wqU6U4UR8Eo_xjNKLPx0L2Hnx5-b1LT0ulvEFRHDUEI,573
92
92
  verifiers/v1/harnesses/kimi_code/__init__.py,sha256=1BEotSfuzmVcE7UrxHeAREM5d7J20cGkonHuowlrzu4,161
93
93
  verifiers/v1/harnesses/kimi_code/harness.py,sha256=4qUc7N7jnQOklMSOujT6tpsRN1AHVnPQ76CG8BzlT1I,5734
94
94
  verifiers/v1/harnesses/mini_swe_agent/__init__.py,sha256=1OBu2Y-XqL72-dGhFdgB6sr5uX_peEEXT9vEjPy1ovU,182
95
95
  verifiers/v1/harnesses/mini_swe_agent/harness.py,sha256=cwYYARBOyG38kTMPTOKlNR_CCtzMhLL8BNtH7Gdy2T0,3416
96
- verifiers/v1/harnesses/mini_swe_agent/program.py,sha256=X2Lv2HnBliz8VqLkC2SMAYoUfbBz5vLbzl_CaGZgPAw,809
96
+ verifiers/v1/harnesses/mini_swe_agent/program.py,sha256=5KNg8nYmfAYG8KbtLqk99S3G1gT0QcSWoH1AeoCgbVs,2198
97
97
  verifiers/v1/harnesses/null/__init__.py,sha256=XDeKOPeoXUQi9US9_Z3_yH9YaZ4EiOMKJmUtNNdtD7s,127
98
98
  verifiers/v1/harnesses/null/harness.py,sha256=ch6Um481rl4opxH04CHa1ZkoS_uHFweBusreR3DDE2g,2062
99
99
  verifiers/v1/harnesses/openclaw/__init__.py,sha256=kNyfPB1sGwEf4K3mTfKN0VEyxun3SGvNpvArVKvH-x8,160
@@ -103,14 +103,14 @@ verifiers/v1/harnesses/opencode/harness.py,sha256=7nojW6Yoc2Dh_J6rX5v7MNmrLPXdMi
103
103
  verifiers/v1/harnesses/opencode/mcp-ready.js,sha256=QpAJcego5pNOZJu1dfpRLd873xitYGYwE9qwmgmvMvI,1904
104
104
  verifiers/v1/harnesses/pi/__init__.py,sha256=1mSnzOf-RdEchdeg6IHtcdobG5KIpAhuTdUIgsCIn74,117
105
105
  verifiers/v1/harnesses/pi/gate.mjs,sha256=vk_OqHXhRdYzQL7YMX8Teajm0fh9tokzDvLHVOd2I9o,449
106
- verifiers/v1/harnesses/pi/harness.py,sha256=tMEQTCp366ZVXVSLHmTZ_etWBgLexxmsV6jQ0miSfWs,8052
106
+ verifiers/v1/harnesses/pi/harness.py,sha256=HPU8-NWG6-1i1zVwNago31VAc6OQNvSGWjQhSIrMo5g,8251
107
107
  verifiers/v1/harnesses/prime_agent/__init__.py,sha256=xfPC4RrlnyYWaf38tPAOZq4YL6M55lMpj5BoRLmaK8I,171
108
108
  verifiers/v1/harnesses/prime_agent/harness.py,sha256=D75GCL3MlavLlSKmpBdqKCDldLhz-ozqKnaxLVmjgV8,13453
109
109
  verifiers/v1/harnesses/rlm/__init__.py,sha256=hwx51xTdEWzzYgMj-p4ETNcptoub3IPMDbEdJ4uB8Ns,122
110
110
  verifiers/v1/harnesses/rlm/harness.py,sha256=JxXBoHV35V2ytW8Qym55mKUwKuRBbhLC1s5pPmanj1E,15839
111
111
  verifiers/v1/harnesses/stirrup/__init__.py,sha256=a-NQxX1bOwaGx8QHj2jWcRJEGiLIxdY6XUMbojr9dOk,142
112
112
  verifiers/v1/harnesses/stirrup/harness.py,sha256=Bcm7m1IzFnseiAa6xRKHSFKYrqSRpvxkP07R4GTryfM,3458
113
- verifiers/v1/harnesses/stirrup/program.py,sha256=0xj35Teph6BW_4ydW921J18MPCBRXNfI62J21nh0dFw,15148
113
+ verifiers/v1/harnesses/stirrup/program.py,sha256=zjrg6aJqtgXxiRPVFYGiRxuz72gDKvd2xmEYq9eZ7pM,17673
114
114
  verifiers/v1/harnesses/utils/__init__.py,sha256=eTS-Ft2HwoLiYn5u1t_KueLmaZB_W12cdYmcVsE-G5A,364
115
115
  verifiers/v1/harnesses/utils/compaction.py,sha256=DeY6CYLEsv7-vJm26sT2mRaPHu3W2ywiZhvFr_pi6Hg,10495
116
116
  verifiers/v1/harnesses/utils/core.py,sha256=Q3xsnk3PtYYcA73p6by7QbjfcfaQVIhRyg3Qi6Ca-H4,26923
@@ -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.dev119.dist-info/METADATA,sha256=-iKOxFnAqMfiBmjtR6NWizMRNpEinvnDhxDHANjKRNA,5118
192
- verifiers-0.4.2.dev119.dist-info/WHEEL,sha256=2iZrJkDIkeDh0k9SikKMqFuRP-ua6mb4Ir1AsER4BEw,87
193
- verifiers-0.4.2.dev119.dist-info/entry_points.txt,sha256=qdMg7ajiFpDsHf7tuPMRclJXizu1J6LTWawS5YS0B0I,137
194
- verifiers-0.4.2.dev119.dist-info/licenses/LICENSE,sha256=v0RrUsdV3IDoZhrRce297IXS3xMHNJ-_LdLpFAUWb9k,1072
195
- verifiers-0.4.2.dev119.dist-info/RECORD,,
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,,