@tangle-network/agent-bench 2.0.0 → 4.0.0

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 (222) hide show
  1. package/CHANGELOG.md +27 -0
  2. package/README.md +32 -2
  3. package/dist/adapters.d.ts +3 -3
  4. package/dist/adapters.js +3 -5
  5. package/dist/adapters.js.map +1 -1
  6. package/dist/benchmarks/_harness.d.ts +4 -4
  7. package/dist/benchmarks/_harness.js +5 -2
  8. package/dist/benchmarks/_harness.js.map +1 -1
  9. package/dist/benchmarks/aec-bench.d.ts +2 -2
  10. package/dist/benchmarks/aec-bench.js +49 -42
  11. package/dist/benchmarks/aec-bench.js.map +1 -1
  12. package/dist/benchmarks/agentbench.d.ts +2 -2
  13. package/dist/benchmarks/agentbench.js +41 -34
  14. package/dist/benchmarks/agentbench.js.map +1 -1
  15. package/dist/benchmarks/appworld.d.ts +4 -4
  16. package/dist/benchmarks/appworld.js +67 -53
  17. package/dist/benchmarks/appworld.js.map +1 -1
  18. package/dist/benchmarks/bfcl.d.ts +2 -2
  19. package/dist/benchmarks/bfcl.js +52 -44
  20. package/dist/benchmarks/bfcl.js.map +1 -1
  21. package/dist/benchmarks/cad-design.d.ts +2 -2
  22. package/dist/benchmarks/cad-design.js +53 -44
  23. package/dist/benchmarks/cad-design.js.map +1 -1
  24. package/dist/benchmarks/cadbench.d.ts +2 -2
  25. package/dist/benchmarks/cadbench.js +1 -1
  26. package/dist/benchmarks/cadgenbench.d.ts +2 -2
  27. package/dist/benchmarks/cadgenbench.js +1 -1
  28. package/dist/benchmarks/commit0.d.ts +2 -2
  29. package/dist/benchmarks/commit0.js +38 -31
  30. package/dist/benchmarks/commit0.js.map +1 -1
  31. package/dist/benchmarks/crag.d.ts +2 -2
  32. package/dist/benchmarks/crag.js +37 -32
  33. package/dist/benchmarks/crag.js.map +1 -1
  34. package/dist/benchmarks/dabstep.d.ts +2 -2
  35. package/dist/benchmarks/dabstep.js +41 -34
  36. package/dist/benchmarks/dabstep.js.map +1 -1
  37. package/dist/benchmarks/finresearchbench.d.ts +4 -4
  38. package/dist/benchmarks/finresearchbench.js +61 -48
  39. package/dist/benchmarks/finresearchbench.js.map +1 -1
  40. package/dist/benchmarks/finsearchcomp.d.ts +3 -3
  41. package/dist/benchmarks/finsearchcomp.js +54 -43
  42. package/dist/benchmarks/finsearchcomp.js.map +1 -1
  43. package/dist/benchmarks/frames.d.ts +2 -2
  44. package/dist/benchmarks/frames.js +66 -51
  45. package/dist/benchmarks/frames.js.map +1 -1
  46. package/dist/benchmarks/hotpotqa.d.ts +2 -2
  47. package/dist/benchmarks/hotpotqa.js +59 -47
  48. package/dist/benchmarks/hotpotqa.js.map +1 -1
  49. package/dist/benchmarks/humaneval.d.ts +3 -3
  50. package/dist/benchmarks/humaneval.js +39 -35
  51. package/dist/benchmarks/humaneval.js.map +1 -1
  52. package/dist/benchmarks/mcad-bench.d.ts +2 -2
  53. package/dist/benchmarks/mcad-bench.js +68 -56
  54. package/dist/benchmarks/mcad-bench.js.map +1 -1
  55. package/dist/benchmarks/mcad-cq-bench.d.ts +2 -2
  56. package/dist/benchmarks/mcad-cq-bench.js +69 -57
  57. package/dist/benchmarks/mcad-cq-bench.js.map +1 -1
  58. package/dist/benchmarks/mcad-cq-golds.d.ts +1 -1
  59. package/dist/benchmarks/mcad-cq-golds.js +1 -1
  60. package/dist/benchmarks/mcad-cq-golds.js.map +1 -1
  61. package/dist/benchmarks/mcad-golds.d.ts +1 -1
  62. package/dist/benchmarks/mcad-golds.js.map +1 -1
  63. package/dist/benchmarks/mind2web.d.ts +3 -3
  64. package/dist/benchmarks/mind2web.js +62 -49
  65. package/dist/benchmarks/mind2web.js.map +1 -1
  66. package/dist/benchmarks/nomiracl.d.ts +2 -2
  67. package/dist/benchmarks/nomiracl.js +43 -36
  68. package/dist/benchmarks/nomiracl.js.map +1 -1
  69. package/dist/benchmarks/open-rag-bench.d.ts +2 -2
  70. package/dist/benchmarks/open-rag-bench.js +37 -32
  71. package/dist/benchmarks/open-rag-bench.js.map +1 -1
  72. package/dist/benchmarks/programbench.d.ts +2 -2
  73. package/dist/benchmarks/programbench.js +28 -23
  74. package/dist/benchmarks/programbench.js.map +1 -1
  75. package/dist/benchmarks/rag-shared.d.ts +2 -2
  76. package/dist/benchmarks/rag-shared.js +15 -13
  77. package/dist/benchmarks/rag-shared.js.map +1 -1
  78. package/dist/benchmarks/ragbench.d.ts +2 -2
  79. package/dist/benchmarks/ragbench.js +34 -29
  80. package/dist/benchmarks/ragbench.js.map +1 -1
  81. package/dist/benchmarks/simpleqa.d.ts +2 -2
  82. package/dist/benchmarks/simpleqa.js +62 -51
  83. package/dist/benchmarks/simpleqa.js.map +1 -1
  84. package/dist/benchmarks/swe-bench.d.ts +4 -4
  85. package/dist/benchmarks/swe-bench.js +47 -41
  86. package/dist/benchmarks/swe-bench.js.map +1 -1
  87. package/dist/benchmarks/t2-ragbench.d.ts +2 -2
  88. package/dist/benchmarks/t2-ragbench.js +37 -32
  89. package/dist/benchmarks/t2-ragbench.js.map +1 -1
  90. package/dist/benchmarks/tau-bench-shared.d.ts +2 -2
  91. package/dist/benchmarks/tau-bench-shared.js +43 -36
  92. package/dist/benchmarks/tau-bench-shared.js.map +1 -1
  93. package/dist/benchmarks/tau2-bench.d.ts +2 -2
  94. package/dist/benchmarks/tau2-bench.js.map +1 -1
  95. package/dist/benchmarks/tau3-banking.d.ts +2 -2
  96. package/dist/benchmarks/tau3-banking.js.map +1 -1
  97. package/dist/benchmarks/terminal-bench.d.ts +2 -2
  98. package/dist/benchmarks/terminal-bench.js +29 -23
  99. package/dist/benchmarks/terminal-bench.js.map +1 -1
  100. package/dist/benchmarks/toollm.d.ts +2 -2
  101. package/dist/benchmarks/toollm.js +40 -34
  102. package/dist/benchmarks/toollm.js.map +1 -1
  103. package/dist/benchmarks/trata-hedge.d.ts +2 -2
  104. package/dist/benchmarks/trata-hedge.js +46 -38
  105. package/dist/benchmarks/trata-hedge.js.map +1 -1
  106. package/dist/benchmarks/types.d.ts +33 -63
  107. package/dist/benchmarks/types.js +36 -1
  108. package/dist/benchmarks/types.js.map +1 -0
  109. package/dist/benchmarks/webarena-verified.d.ts +2 -2
  110. package/dist/benchmarks/webarena-verified.js +29 -24
  111. package/dist/benchmarks/webarena-verified.js.map +1 -1
  112. package/dist/{cadbench-Byr5gO1M.js → cadbench-htzAmMaI.js} +39 -32
  113. package/dist/cadbench-htzAmMaI.js.map +1 -0
  114. package/dist/{cadgenbench-Tvk16YKT.js → cadgenbench-BLvEtnxU.js} +28 -22
  115. package/dist/cadgenbench-BLvEtnxU.js.map +1 -0
  116. package/dist/cli.d.ts +1 -0
  117. package/dist/cli.js +667 -0
  118. package/dist/cli.js.map +1 -0
  119. package/dist/index.d.ts +43 -22
  120. package/dist/index.js +297 -144
  121. package/dist/index.js.map +1 -1
  122. package/package.json +7 -4
  123. package/pier_agents/candidate_contract.py +226 -74
  124. package/pier_agents/tangle_candidate.py +79 -1
  125. package/pier_agents/workspace_boundary.py +29 -1
  126. package/scripts/enterpriseops-gym-run.sh +82 -0
  127. package/scripts/grade-recorded-evidence.mjs +6 -6
  128. package/scripts/harvey-lab-judge.py +50 -0
  129. package/scripts/harvey-lab-run.sh +53 -0
  130. package/scripts/harvey-lab-sandbox.sh +21 -0
  131. package/scripts/healthbench-professional-run.sh +30 -0
  132. package/scripts/healthbench_professional_run.py +112 -0
  133. package/scripts/mlcr-run.sh +17 -0
  134. package/scripts/mlcr_run.py +133 -0
  135. package/scripts/prbench-run.sh +39 -0
  136. package/scripts/prbench_run.py +53 -0
  137. package/scripts/verify-packed-consumer.mjs +32 -27
  138. package/scripts/verify-pier-agent.mts +142 -25
  139. package/src/adapters.ts +5 -7
  140. package/src/benchmarks/_harness.test.mts +18 -1
  141. package/src/benchmarks/_harness.ts +12 -7
  142. package/src/benchmarks/aec-bench.test.mts +14 -14
  143. package/src/benchmarks/aec-bench.ts +62 -56
  144. package/src/benchmarks/agent-eval-contract.test.mts +38 -0
  145. package/src/benchmarks/agentbench.ts +44 -37
  146. package/src/benchmarks/appworld.test.mts +7 -7
  147. package/src/benchmarks/appworld.ts +88 -75
  148. package/src/benchmarks/bfcl.ts +60 -53
  149. package/src/benchmarks/cad-design.ts +34 -32
  150. package/src/benchmarks/cadbench.ts +34 -32
  151. package/src/benchmarks/cadgenbench.ts +30 -28
  152. package/src/benchmarks/commit0.test.mts +9 -9
  153. package/src/benchmarks/commit0.ts +50 -43
  154. package/src/benchmarks/crag.ts +45 -40
  155. package/src/benchmarks/dabstep-official.test.mts +8 -8
  156. package/src/benchmarks/dabstep.test.mts +11 -11
  157. package/src/benchmarks/dabstep.ts +47 -40
  158. package/src/benchmarks/external-adapters.test.mts +43 -44
  159. package/src/benchmarks/finresearchbench.ts +57 -47
  160. package/src/benchmarks/finsearchcomp.ts +72 -67
  161. package/src/benchmarks/frames.ts +76 -69
  162. package/src/benchmarks/hotpotqa.ts +69 -64
  163. package/src/benchmarks/humaneval.ts +37 -35
  164. package/src/benchmarks/mcad-bench.test.mts +30 -30
  165. package/src/benchmarks/mcad-bench.ts +66 -60
  166. package/src/benchmarks/mcad-cq-bench.ts +69 -63
  167. package/src/benchmarks/mcad-cq-golds.ts +1 -1
  168. package/src/benchmarks/mcad-cq.test.mts +40 -40
  169. package/src/benchmarks/mcad-golds.ts +1 -1
  170. package/src/benchmarks/mind2web.ts +66 -58
  171. package/src/benchmarks/nomiracl.ts +53 -46
  172. package/src/benchmarks/open-rag-bench.ts +47 -42
  173. package/src/benchmarks/programbench.test.mts +10 -10
  174. package/src/benchmarks/programbench.ts +38 -33
  175. package/src/benchmarks/rag-benchmarks.test.mts +31 -31
  176. package/src/benchmarks/rag-shared.ts +13 -16
  177. package/src/benchmarks/ragbench.ts +44 -39
  178. package/src/benchmarks/simpleqa.ts +78 -73
  179. package/src/benchmarks/swe-bench.test.mts +3 -3
  180. package/src/benchmarks/swe-bench.ts +66 -61
  181. package/src/benchmarks/t2-ragbench.ts +47 -42
  182. package/src/benchmarks/tau-bench-shared.ts +51 -44
  183. package/src/benchmarks/tau-pin.test.mts +1 -1
  184. package/src/benchmarks/tau2-bench.ts +2 -2
  185. package/src/benchmarks/tau3-banking.ts +2 -2
  186. package/src/benchmarks/terminal-bench.test.mts +3 -3
  187. package/src/benchmarks/terminal-bench.ts +41 -36
  188. package/src/benchmarks/toollm.ts +54 -47
  189. package/src/benchmarks/trata-hedge.ts +57 -52
  190. package/src/benchmarks/types.ts +70 -59
  191. package/src/benchmarks/webarena-verified.ts +49 -42
  192. package/src/cli.ts +74 -0
  193. package/src/corpus-replay.mts +9 -9
  194. package/src/examples/benchmark-matrix.mts +13 -10
  195. package/src/gate-cli.mts +5 -5
  196. package/src/gate.test.mts +14 -12
  197. package/src/gate.ts +23 -22
  198. package/src/index.ts +20 -11
  199. package/src/pier-agent.ts +108 -38
  200. package/src/pier-trial-controller.test.mts +48 -1
  201. package/src/pier-trial-controller.ts +121 -8
  202. package/src/published.test.mts +534 -0
  203. package/src/published.ts +524 -0
  204. package/src/run-benchmarks-cli.mts +2 -2
  205. package/src/run-benchmarks.test.mts +58 -48
  206. package/src/run-benchmarks.ts +64 -57
  207. package/src/swe-bench-env.ts +6 -6
  208. package/src/worker.ts +1 -1
  209. package/dist/benchmarks/enterpriseops-gym.d.ts +0 -6
  210. package/dist/benchmarks/enterpriseops-gym.js +0 -236
  211. package/dist/benchmarks/enterpriseops-gym.js.map +0 -1
  212. package/dist/cadbench-Byr5gO1M.js.map +0 -1
  213. package/dist/cadgenbench-Tvk16YKT.js.map +0 -1
  214. package/fixtures/enterpriseops-gym.json +0 -103
  215. package/scripts/enterpriseops_gym_judge.py +0 -281
  216. package/src/benchmarks/enterpriseops-gym.test.mts +0 -77
  217. package/src/benchmarks/enterpriseops-gym.ts +0 -343
  218. package/src/eops-skills/address-every-subtask.md +0 -5
  219. package/src/eops-skills/exact-tools-and-args.md +0 -5
  220. package/src/eops-skills/full-sequence-to-goal.md +0 -5
  221. package/src/eops-skills/ground-every-value.md +0 -5
  222. package/src/eops-skills/honor-the-policies.md +0 -5
@@ -1,281 +0,0 @@
1
- # EnterpriseOps-Gym judge driver.
2
- #
3
- # Scores a worker's tool-call transcript against a task's verifiers, deterministically,
4
- # by REPLAYING the transcript into a FRESHLY-SEEDED gym database and then reading the
5
- # verifier SQL back. The full deployable-checker loop (matches the official benchmark/
6
- # executor.py protocol):
7
- #
8
- # 1. SEED per gym: create an isolated database (its own database_id) from the task's
9
- # seed_database_file SQL snapshot via POST /api/seed-database. Every later call
10
- # targets that database via the `x-database-id` header, so concurrent judges on
11
- # one container never collide.
12
- # 2. REPLAY each transcript call as an MCP JSON-RPC `tools/call` to /mcp (NOT a bare
13
- # {tool,arguments} POST, which the server accepts as a no-op 204 and never
14
- # executes). A tool-call HTTP error is the AGENT's mistake (wrong args / policy
15
- # violation) — counted + surfaced, never fatal; the verifiers score the result.
16
- # A transport failure (server down) IS fatal (fail loud, never a fake score).
17
- # 3. VERIFY each database_state verifier's SQL via /api/sql-runner (parsing the server's
18
- # {"data":[{...}]} shape), compared to expected_value under comparison_type.
19
- # 4. CLEAN delete each seeded database (best-effort).
20
- #
21
- # Seed snapshots are resolved against EOPS_GYM_DBS_DIR (the unzipped gym_dbs.zip). A task
22
- # whose server has no seed_database_file, or an unset EOPS_GYM_DBS_DIR, fails loud — an
23
- # unseeded run would score every solve against the same default state (no signal).
24
-
25
- import argparse
26
- import json
27
- import os
28
- import re
29
- import sys
30
- import urllib.error
31
- import urllib.request
32
- import uuid
33
-
34
-
35
- def fail(msg: str) -> None:
36
- print(json.dumps({"error": msg}))
37
- sys.exit(1)
38
-
39
-
40
- def request(url: str, payload: dict, headers: dict, method: str = "POST", timeout: float = 60.0) -> str:
41
- body = json.dumps(payload).encode("utf-8")
42
- req = urllib.request.Request(url, data=body, method=method)
43
- req.add_header("Content-Type", "application/json")
44
- req.add_header("Accept", "application/json, text/event-stream")
45
- for k, v in (headers or {}).items():
46
- req.add_header(k, str(v))
47
- with urllib.request.urlopen(req, timeout=timeout) as resp:
48
- return resp.read().decode("utf-8")
49
-
50
-
51
- def parse_body(raw: str) -> object:
52
- """Parse a JSON body OR an SSE `data: {...}` stream (the /mcp endpoint streams SSE)."""
53
- raw = raw.strip()
54
- if not raw:
55
- return {}
56
- if raw.startswith("event:") or raw.startswith("data:") or "\ndata:" in raw:
57
- matches = re.findall(r"data:\s*(\{.*\})", raw)
58
- if matches:
59
- return json.loads(matches[-1])
60
- return json.loads(raw)
61
-
62
-
63
- def auth_headers(server: dict) -> dict:
64
- """Context auth headers (e.g. x-itsm-user-token) plus the per-run x-database-id."""
65
- headers = dict(server.get("context") or {})
66
- db_id = server.get("_database_id")
67
- if db_id:
68
- headers["x-database-id"] = db_id
69
- return headers
70
-
71
-
72
- def server_for_gym(servers: list, gym_name: str) -> dict:
73
- by_name = {s.get("mcp_server_name"): s for s in servers}
74
- if gym_name in by_name:
75
- return by_name[gym_name]
76
- if len(servers) == 1:
77
- return servers[0]
78
- fail(f"verifier gym_name {gym_name!r} not in gym_servers_config ({sorted(by_name)})")
79
-
80
-
81
- def seed_databases(servers: list, gym_dbs_dir: str) -> None:
82
- for s in servers:
83
- seed_file = s.get("seed_database_file")
84
- if not seed_file:
85
- fail(
86
- f"server {s.get('mcp_server_name')!r} has no seed_database_file — cannot seed a "
87
- "deterministic state (an unseeded run scores every solve against the same default DB)"
88
- )
89
- if not gym_dbs_dir:
90
- fail(
91
- "EOPS_GYM_DBS_DIR is unset — cannot resolve seed_database_file. Unzip gym_dbs.zip "
92
- "(from ServiceNow/EnterpriseOps-Gym) and set EOPS_GYM_DBS_DIR to its directory."
93
- )
94
- path = seed_file if os.path.isabs(seed_file) else os.path.join(gym_dbs_dir, seed_file)
95
- try:
96
- sql = open(path, encoding="utf-8").read()
97
- except Exception as e: # noqa: BLE001
98
- fail(f"reading seed file {path} failed: {e}")
99
- db_id = "gate_" + uuid.uuid4().hex[:12]
100
- url = s["mcp_server_url"].rstrip("/") + "/api/seed-database"
101
- payload = {
102
- "database_id": db_id,
103
- "name": f"gate_{db_id}",
104
- "description": f"gate seed from {os.path.basename(seed_file)}",
105
- "sql_content": sql,
106
- }
107
- try:
108
- request(url, payload, {}, timeout=max(300.0, len(sql) / 1024))
109
- except Exception as e: # noqa: BLE001
110
- fail(f"seed-database POST to {url} failed: {e}")
111
- s["_database_id"] = db_id
112
-
113
-
114
- def delete_databases(servers: list) -> None:
115
- for s in servers:
116
- db_id = s.get("_database_id")
117
- if not db_id:
118
- continue
119
- url = s["mcp_server_url"].rstrip("/") + "/api/delete-database"
120
- try:
121
- request(url, {"database_id": db_id}, {}, method="DELETE", timeout=30)
122
- except Exception: # noqa: BLE001
123
- pass # best-effort cleanup; a leaked db never corrupts a future run (unique id)
124
-
125
-
126
- def replay_transcript(servers: list, transcript: list) -> int:
127
- """Replay each call as an MCP tools/call. Returns the count of agent-side call errors
128
- (surfaced, never fatal). A transport failure fails loud."""
129
- errors = 0
130
- for i, call in enumerate(transcript):
131
- tool = call.get("tool")
132
- if not isinstance(tool, str) or not tool:
133
- errors += 1
134
- continue
135
- gym_name = call.get("gym_name")
136
- server = server_for_gym(servers, gym_name) if gym_name else servers[0]
137
- url = server["mcp_server_url"].rstrip("/") + "/mcp"
138
- payload = {
139
- "jsonrpc": "2.0",
140
- "id": i + 1,
141
- "method": "tools/call",
142
- "params": {"name": tool, "arguments": call.get("arguments") or {}},
143
- }
144
- try:
145
- raw = request(url, payload, auth_headers(server), timeout=60)
146
- result = parse_body(raw)
147
- # A JSON-RPC error or an isError tool result is the agent's mistake, not a judge
148
- # failure — count it so a wholesale replay failure is visible, but keep going.
149
- if isinstance(result, dict) and (result.get("error") or (result.get("result") or {}).get("isError")):
150
- errors += 1
151
- except urllib.error.HTTPError:
152
- errors += 1 # the agent issued a bad call (wrong args / policy) — verifiers score it
153
- except urllib.error.URLError as e:
154
- fail(f"gym server unreachable at {url} replaying tool {tool!r}: {e}")
155
- except Exception as e: # noqa: BLE001
156
- fail(f"tool call {tool!r} against {url} failed unexpectedly: {e}")
157
- return errors
158
-
159
-
160
- def run_sql(server: dict, query: str) -> object:
161
- url = server["mcp_server_url"].rstrip("/") + "/api/sql-runner"
162
- payload = {"query": query, "database_id": server.get("_database_id")}
163
- try:
164
- out = parse_body(request(url, payload, auth_headers(server), timeout=60))
165
- except urllib.error.URLError as e:
166
- fail(f"gym server unreachable at {url}: {e}")
167
- except Exception as e: # noqa: BLE001
168
- fail(f"sql-runner POST to {url} failed: {e}")
169
- if isinstance(out, dict):
170
- if out.get("error"):
171
- fail(f"sql-runner error for query {query!r}: {out['error']}")
172
- # The gym server returns {"data":[{col:val}], ...}; older/other shapes use result/rows.
173
- for key in ("data", "rows"):
174
- rows = out.get(key)
175
- if rows:
176
- first = rows[0]
177
- if isinstance(first, dict) and first:
178
- return next(iter(first.values()))
179
- if isinstance(first, list) and first:
180
- return first[0]
181
- return first
182
- if "result" in out:
183
- return out["result"]
184
- return out
185
-
186
-
187
- def compare(actual: object, expected: object, comparison_type: str) -> bool:
188
- if comparison_type == "equals":
189
- try:
190
- return float(actual) == float(expected)
191
- except (TypeError, ValueError):
192
- return str(actual) == str(expected)
193
- if comparison_type == "greater_than":
194
- return float(actual) > float(expected)
195
- if comparison_type == "less_than":
196
- return float(actual) < float(expected)
197
- if comparison_type == "contains":
198
- return str(expected) in str(actual)
199
- fail(f"unsupported comparison_type {comparison_type!r}")
200
-
201
-
202
- def cmd_judge(args) -> None:
203
- raw_transcript = sys.stdin.read()
204
- try:
205
- task = json.load(open(args.task_json, encoding="utf-8"))
206
- except Exception as e: # noqa: BLE001
207
- fail(f"reading task json {args.task_json} failed: {e}")
208
-
209
- servers = task.get("gym_servers_config")
210
- if isinstance(servers, str):
211
- servers = json.loads(servers)
212
- if not isinstance(servers, list) or not servers:
213
- fail("task has no gym_servers_config list")
214
-
215
- verifiers = task.get("verifiers")
216
- if isinstance(verifiers, str):
217
- verifiers = json.loads(verifiers)
218
- if not isinstance(verifiers, list) or not verifiers:
219
- fail("task has no verifiers list")
220
-
221
- transcript: list = []
222
- if raw_transcript.strip():
223
- try:
224
- parsed = json.loads(raw_transcript)
225
- except Exception as e: # noqa: BLE001
226
- fail(f"transcript is not valid JSON: {e}")
227
- transcript = parsed.get("calls", []) if isinstance(parsed, dict) else parsed
228
- if not isinstance(transcript, list):
229
- fail('transcript must be a JSON list of tool calls (or {"calls":[...]})')
230
-
231
- gym_dbs_dir = os.environ.get("EOPS_GYM_DBS_DIR", "")
232
- seed_databases(servers, gym_dbs_dir)
233
- try:
234
- replay_errors = replay_transcript(servers, transcript)
235
-
236
- results = []
237
- passes = 0
238
- for v in verifiers:
239
- vtype = v.get("verifier_type")
240
- if vtype != "database_state":
241
- fail(f"verifier {v.get('name')!r} has non-deterministic verifier_type {vtype!r}")
242
- cfg = v.get("validation_config") or {}
243
- query = cfg.get("query")
244
- if not isinstance(query, str) or not query.strip():
245
- fail(f"verifier {v.get('name')!r} has no SQL query")
246
- server = server_for_gym(servers, v.get("gym_name"))
247
- actual = run_sql(server, query)
248
- ok = compare(actual, cfg.get("expected_value"), cfg.get("comparison_type", "equals"))
249
- if ok:
250
- passes += 1
251
- results.append({"name": v.get("name"), "passed": bool(ok)})
252
-
253
- total = len(verifiers)
254
- print(
255
- json.dumps(
256
- {
257
- "success": passes == total,
258
- "passes": passes,
259
- "total": total,
260
- "replay_calls": len(transcript),
261
- "replay_errors": replay_errors,
262
- "verifiers": results,
263
- }
264
- )
265
- )
266
- finally:
267
- delete_databases(servers)
268
-
269
-
270
- def main() -> None:
271
- ap = argparse.ArgumentParser(description="EnterpriseOps-Gym judge driver")
272
- sub = ap.add_subparsers(dest="cmd", required=True)
273
- p = sub.add_parser("judge")
274
- p.add_argument("--task-json", required=True)
275
- args = ap.parse_args()
276
- if args.cmd == "judge":
277
- cmd_judge(args)
278
-
279
-
280
- if __name__ == "__main__":
281
- main()
@@ -1,77 +0,0 @@
1
- /**
2
- * Offline EnterpriseOps-Gym adapter test. The judge needs a live, freshly-seeded
3
- * gym MCP server (Docker), not installed in CI, so this exercises the parts that
4
- * run offline (fixtures loadTasks, the transcript OutputAdapter, goldArtifact) and
5
- * asserts the judge FAILS LOUD with the documented docker fix when no server is
6
- * reachable — never a fake score. Run:
7
- * EOPS_FIXTURES=1 npx tsx --test src/benchmarks/enterpriseops-gym.test.mts
8
- */
9
- import assert from 'node:assert/strict'
10
- import { test } from 'node:test'
11
- import { createEnterpriseOpsGymAdapter, enterpriseOpsTranscriptOutput } from './enterpriseops-gym'
12
-
13
- process.env.EOPS_FIXTURES = '1'
14
-
15
- type Events = Parameters<typeof enterpriseOpsTranscriptOutput.parse>[0]
16
- const stream = (text: string): Events => [{ data: { finalText: text } }] as unknown as Events
17
-
18
- const itsmId = 'task_20251212_172511_458_e6427839_47076c15'
19
-
20
- test('loadTasks (fixtures) yields enterprise tasks with tool-list + SQL-verifier metadata', async () => {
21
- const a = createEnterpriseOpsGymAdapter()
22
- const tasks = await a.loadTasks({ ids: [itsmId] })
23
- assert.equal(tasks.length, 1)
24
- const t = tasks[0]
25
- assert.equal(t.id, itsmId)
26
- assert.equal(t.split, 'itsm')
27
- assert.match(t.prompt, /```json/)
28
- assert.match(t.prompt, /update_incident/)
29
- const md = t.metadata as Record<string, unknown>
30
- assert.equal(md.taskId, itsmId)
31
- assert.equal(md.domain, 'itsm')
32
- assert.ok(Array.isArray(md.servers) && (md.servers as unknown[]).length === 1)
33
- const verifiers = md.verifiers as Array<{ verifier_type: string; validation_config: { query: string } }>
34
- assert.equal(verifiers.length, 2)
35
- assert.equal(verifiers[0].verifier_type, 'database_state')
36
- assert.match(verifiers[0].validation_config.query, /SELECT COUNT/)
37
- })
38
-
39
- test('loadTasks scopes by domain split and limit', async () => {
40
- const a = createEnterpriseOpsGymAdapter()
41
- const cal = await a.loadTasks({ split: 'calendar' })
42
- assert.equal(cal.length, 1)
43
- assert.equal(cal[0].split, 'calendar')
44
- const capped = await a.loadTasks({ limit: 1 })
45
- assert.equal(capped.length, 1)
46
- })
47
-
48
- test('transcript OutputAdapter: last fenced ```json wins; fence-less falls back to trimmed text', () => {
49
- const fenced = enterpriseOpsTranscriptOutput.parse(
50
- stream('preamble\n```json\n{"calls":[{"tool":"update_incident","arguments":{}}]}\n```\n'),
51
- )
52
- assert.equal(fenced, '{"calls":[{"tool":"update_incident","arguments":{}}]}')
53
- const last = enterpriseOpsTranscriptOutput.parse(stream('```json\nFIRST\n```\nmid\n```json\nSECOND\n```'))
54
- assert.equal(last, 'SECOND')
55
- const raw = enterpriseOpsTranscriptOutput.parse(stream(' {"calls":[]} '))
56
- assert.equal(raw, '{"calls":[]}')
57
- })
58
-
59
- test('goldArtifact is undefined — oracle is the seeded DB state, documented, not a fabricated transcript', async () => {
60
- const a = createEnterpriseOpsGymAdapter()
61
- const [t] = await a.loadTasks({ ids: [itsmId] })
62
- assert.equal(await a.goldArtifact(t), undefined)
63
- })
64
-
65
- test('judge FAILS LOUD with the docker fix when no gym server is reachable (no fake score)', async () => {
66
- const a = createEnterpriseOpsGymAdapter()
67
- const [t] = await a.loadTasks({ ids: [itsmId] })
68
- // Point the metadata at a definitely-dead port so the SQL-runner POST is refused.
69
- const md = t.metadata as Record<string, unknown>
70
- const servers = md.servers as Array<{ mcp_server_url: string }>
71
- servers[0].mcp_server_url = 'http://127.0.0.1:1'
72
- await assert.rejects(a.judge(t, '{"calls":[]}'), (e: Error) => {
73
- assert.match(e.message, /enterpriseops-gym judge failed/)
74
- assert.match(e.message, /docker pull shivakrishnareddyma225\/enterpriseops-gym-mcp-itsm/)
75
- return true
76
- })
77
- })