-
Notifications
You must be signed in to change notification settings - Fork 5.5k
Expand file tree
/
Copy pathadapters.py
More file actions
3139 lines (2887 loc) · 120 KB
/
adapters.py
File metadata and controls
3139 lines (2887 loc) · 120 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
from __future__ import annotations
import importlib.util
import os
import json
import re
import shlex
import shutil
import subprocess
import sys
import time
from pathlib import Path
from typing import Any
if __package__ == "orchestrator":
from registry import get_benchmark_registry
else:
from benchmarks.registry import get_benchmark_registry
from .scoring import RegistryScoreExtractor, generic_score_extractor
from .types import AdapterDiscovery, BenchmarkAdapter, ExecutionContext, ScoreSummary
def _sanitize(value: str) -> str:
return re.sub(r"[^A-Za-z0-9_.-]+", "-", value.strip()).strip("-").lower() or "run"
def _provider_model_name(provider: str, model: str) -> str:
provider_name = provider.strip().lower()
model_name = model.strip()
if provider_name == "cerebras" and model_name.startswith("openai/"):
return model_name.split("/", 1)[1]
return model_name
def _find_latest_by_patterns(root: Path, patterns: list[str]) -> Path | None:
matches: list[Path] = []
for pattern in patterns:
matches.extend([p for p in root.glob(pattern) if p.is_file()])
if not matches:
return None
return max(matches, key=lambda p: p.stat().st_mtime)
def _find_latest_json(root: Path) -> Path | None:
return _find_latest_by_patterns(root, ["**/*.json"])
def _json_score(path: Path) -> ScoreSummary:
return generic_score_extractor(path)
IGNORED_BENCHMARK_DIRS = {
"__pycache__",
".git",
".pytest_cache",
"benchmark_results",
"claw-eval",
"claw_eval_matrix",
"clawbench_matrix",
"qwen_claw_bench_matrix",
"agentbench_matrix",
"swe_bench_pro_matrix",
# Legacy compatibility shim for benchmarks.mmau, not a separate benchmark.
"mmau",
"elizaos_mmau",
"eliza-adapter",
"app_eval",
# Legacy/partial shim with no source files in this checkout.
"eliza-format",
"hermes-adapter",
"openclaw-adapter",
"openclaw_benchmark",
"lib",
"nl2repo",
"orchestrator",
"qwen-claw-bench",
"qwen-web-bench",
# Python package shim for benchmarks.registry, not a benchmark adapter dir.
"registry",
"scripts",
"skillsbench",
"swe-bench-pro",
"swe-bench-multilingual",
"swe-bench-workspace",
"tests",
# Standalone dialogue runner; not wired into the normalized benchmark
# orchestrator contract yet.
"three-agent-dialogue",
"viewer",
# Standalone package; not yet wired as an orchestrator adapter.
"voice-emotion",
# Plugin validation tests/fixtures, not a normalized benchmark adapter.
"voice-speaker-validation",
}
# Harness compatibility lookup. The benchmark matrix is intentionally
# tri-harness by default so `--all-harnesses` remains a full Eliza/Hermes/
# OpenClaw comparison unless a future adapter adds a hard exclusion here.
ALL_HARNESSES: tuple[str, ...] = ("eliza", "openclaw", "hermes")
AGENT_COMPATIBILITY_OVERRIDES: dict[str, tuple[str, ...]] = {}
HYPERLIQUID_LIVE_UNAVAILABLE_REASON = (
"Hyperliquid live execution unavailable "
"(set HL_PRIVATE_KEY and run with --no-demo); harness not run"
)
TERMINAL_BENCH_DOCKER_UNAVAILABLE_REASON = (
"Terminal-Bench Docker execution unavailable "
"(start Docker Desktop/daemon so real Docker-backed tasks can run); "
"harness not run"
)
SWE_BENCH_DOCKER_UNAVAILABLE_REASON = (
"SWE-Bench Docker evaluation unavailable "
"(start Docker Desktop/daemon so official SWE-Bench tests can run); "
"harness not run"
)
OSWORLD_DOCKER_UNAVAILABLE_REASON = (
"OSWorld Docker desktop backend unavailable "
"(start Docker Desktop/daemon so the VM-backed tasks can run); "
"harness not run"
)
HERMES_SANDBOX_UNAVAILABLE_REASON = (
"Hermes sandbox execution unavailable "
"(set MODAL_TOKEN_ID/MODAL_TOKEN_SECRET or start a reachable Docker daemon); "
"harness not run"
)
VISION_LANGUAGE_REAL_INPUTS_UNAVAILABLE_REASON = (
"vision-language real multimodal runtime/input bundle unavailable or not "
"explicitly selected (set VISION_LANGUAGE_PROVIDER=local-eliza for the "
"local eliza-1 VLM); harness not run"
)
VISION_LANGUAGE_FIXED_RUNTIME_REASON = (
"vision-language currently runs the fixed eliza-1 VLM runtime only; "
"Hermes/OpenClaw harness adapters are not implemented"
)
VISION_LANGUAGE_HARNESS_RUNTIME_UNAVAILABLE_REASON = (
"vision-language Hermes/OpenClaw VLM runtime unavailable "
"(set VISION_LANGUAGE_MODEL plus provider credentials for a multimodal "
"OpenAI-compatible model); harness not run"
)
def _agent_compatibility_for(benchmark_id: str) -> tuple[str, ...]:
if benchmark_id == "hyperliquid_bench":
return ALL_HARNESSES if _has_hyperliquid_live_backend() else ()
if benchmark_id == "terminal_bench":
return ALL_HARNESSES if _has_terminal_bench_docker_backend() else ()
if benchmark_id in {"swe_bench", "swe_bench_orchestrated"}:
return ALL_HARNESSES if _has_swe_bench_docker_backend() else ()
if benchmark_id == "osworld":
return ALL_HARNESSES if _has_osworld_docker_backend() else ()
if benchmark_id == "gauntlet":
return ALL_HARNESSES if _has_gauntlet_real_surfpool_backend() else ()
if benchmark_id in {
"hermes_tblite",
"hermes_terminalbench_2",
"hermes_yc_bench",
"hermes_swe_env",
}:
return ALL_HARNESSES if _has_hermes_sandbox_backend() else ()
if benchmark_id == "voicebench":
return ALL_HARNESSES if _has_voicebench_real_audio_assets() else ()
if benchmark_id == "voicebench_quality":
return ALL_HARNESSES if _has_voicebench_quality_real_inputs() else ()
if benchmark_id == "voiceagentbench":
return ALL_HARNESSES if _has_voiceagentbench_real_audio_dataset() else ()
if benchmark_id == "vision_language":
return _vision_language_compatible_harnesses()
return AGENT_COMPATIBILITY_OVERRIDES.get(benchmark_id, ALL_HARNESSES)
_GAUNTLET_REAL_SURFPOOL_AVAILABLE: bool | None = None
def _has_hyperliquid_live_backend() -> bool:
"""Return true when Hyperliquid can run outside demo/smoke mode."""
# This is an environment-only probe. Do not cache it: tests and runbook
# scripts often validate the matrix, set HL_PRIVATE_KEY, then validate
# again in the same Python process.
return bool(os.environ.get("HL_PRIVATE_KEY"))
def _surfpool_start_help(binary: str) -> str:
try:
completed = subprocess.run(
[binary, "start", "--help"],
capture_output=True,
text=True,
timeout=3,
check=False,
)
except (OSError, subprocess.TimeoutExpired):
return ""
return f"{completed.stdout}\n{completed.stderr}"
def _has_gauntlet_real_surfpool_backend() -> bool:
"""Return true only when Surfpool can run Gauntlet's real mainnet-backed path."""
global _GAUNTLET_REAL_SURFPOOL_AVAILABLE
if _GAUNTLET_REAL_SURFPOOL_AVAILABLE is not None:
return _GAUNTLET_REAL_SURFPOOL_AVAILABLE
binary = shutil.which("surfpool")
if not binary:
_GAUNTLET_REAL_SURFPOOL_AVAILABLE = False
return False
help_text = _surfpool_start_help(binary)
has_remote_datasource = "--rpc-url" in help_text or "--network" in help_text
has_noninteractive_mode = "--no-tui" in help_text
_GAUNTLET_REAL_SURFPOOL_AVAILABLE = has_remote_datasource and has_noninteractive_mode
return _GAUNTLET_REAL_SURFPOOL_AVAILABLE
_HERMES_SANDBOX_BACKEND_AVAILABLE: bool | None = None
_TERMINAL_BENCH_DOCKER_AVAILABLE: bool | None = None
def _has_terminal_bench_docker_backend() -> bool:
"""Return true when Docker can answer quickly enough to run real tasks."""
global _TERMINAL_BENCH_DOCKER_AVAILABLE
if _TERMINAL_BENCH_DOCKER_AVAILABLE is not None:
return _TERMINAL_BENCH_DOCKER_AVAILABLE
_TERMINAL_BENCH_DOCKER_AVAILABLE = _docker_info_available()
return _TERMINAL_BENCH_DOCKER_AVAILABLE
def _docker_info_available(*, attempts: int = 3, timeout_s: float = 20.0) -> bool:
if not shutil.which("docker"):
return False
for attempt in range(max(attempts, 1)):
try:
completed = subprocess.run(
["docker", "info", "--format", "{{.ServerVersion}}"],
stdout=subprocess.DEVNULL,
stderr=subprocess.DEVNULL,
timeout=timeout_s,
check=False,
)
if completed.returncode == 0:
return True
except (OSError, subprocess.TimeoutExpired):
pass
if attempt < attempts - 1:
time.sleep(0.25)
return False
_SWE_BENCH_DOCKER_AVAILABLE: bool | None = None
def _has_swe_bench_docker_backend() -> bool:
"""Return true when Docker can run the official SWE-Bench evaluator."""
global _SWE_BENCH_DOCKER_AVAILABLE
if _SWE_BENCH_DOCKER_AVAILABLE is not None:
return _SWE_BENCH_DOCKER_AVAILABLE
_SWE_BENCH_DOCKER_AVAILABLE = _has_terminal_bench_docker_backend()
return _SWE_BENCH_DOCKER_AVAILABLE
_OSWORLD_DOCKER_AVAILABLE: bool | None = None
def _has_osworld_docker_backend() -> bool:
"""Return true when Docker can run OSWorld's VM orchestration backend."""
global _OSWORLD_DOCKER_AVAILABLE
if _OSWORLD_DOCKER_AVAILABLE is not None:
return _OSWORLD_DOCKER_AVAILABLE
_OSWORLD_DOCKER_AVAILABLE = _docker_info_available(attempts=1, timeout_s=5.0)
return _OSWORLD_DOCKER_AVAILABLE
def _has_hermes_sandbox_backend() -> bool:
global _HERMES_SANDBOX_BACKEND_AVAILABLE
if _HERMES_SANDBOX_BACKEND_AVAILABLE is not None:
return _HERMES_SANDBOX_BACKEND_AVAILABLE
if os.environ.get("MODAL_TOKEN_ID") and os.environ.get("MODAL_TOKEN_SECRET"):
_HERMES_SANDBOX_BACKEND_AVAILABLE = True
return True
_HERMES_SANDBOX_BACKEND_AVAILABLE = _docker_info_available()
return _HERMES_SANDBOX_BACKEND_AVAILABLE
_VOICEAGENTBENCH_REAL_AUDIO_AVAILABLE: bool | None = None
def _has_voiceagentbench_real_audio_dataset() -> bool:
"""Return true only when VoiceAgentBench can run as a real voice benchmark."""
global _VOICEAGENTBENCH_REAL_AUDIO_AVAILABLE
if _VOICEAGENTBENCH_REAL_AUDIO_AVAILABLE is not None:
return _VOICEAGENTBENCH_REAL_AUDIO_AVAILABLE
stt_provider = os.environ.get("VOICEAGENTBENCH_STT_PROVIDER", "").strip().lower()
if not stt_provider:
if os.environ.get("GROQ_API_KEY"):
stt_provider = "groq"
elif importlib.util.find_spec("faster_whisper") is not None:
stt_provider = "faster-whisper"
else:
stt_provider = "groq"
if stt_provider == "groq":
stt_ready = bool(os.environ.get("GROQ_API_KEY"))
elif stt_provider == "eliza-runtime":
stt_ready = bool(
(os.environ.get("ELIZA_API_BASE") or os.environ.get("ELIZA_BENCH_URL") or "").strip()
)
elif stt_provider in {"faster-whisper", "local-whisper"}:
stt_ready = importlib.util.find_spec("faster_whisper") is not None
else:
stt_ready = False
data_path_raw = (
os.environ.get("VOICEAGENTBENCH_DATA_PATH")
or os.environ.get("VOICEAGENTBENCH_REAL_DATA_PATH")
or ""
).strip()
if not stt_ready:
_VOICEAGENTBENCH_REAL_AUDIO_AVAILABLE = False
return False
if not data_path_raw:
_VOICEAGENTBENCH_REAL_AUDIO_AVAILABLE = importlib.util.find_spec("huggingface_hub") is not None
return _VOICEAGENTBENCH_REAL_AUDIO_AVAILABLE
path = Path(data_path_raw).expanduser()
if not path.is_file():
_VOICEAGENTBENCH_REAL_AUDIO_AVAILABLE = False
return False
try:
with path.open("r", encoding="utf-8") as fh:
for raw in fh:
if not raw.strip():
continue
row = json.loads(raw)
queries = row.get("queries") if isinstance(row, dict) else None
if not isinstance(queries, list):
continue
for query in queries:
if not isinstance(query, dict):
continue
audio_b64 = query.get("audio_b64")
if isinstance(audio_b64, str) and audio_b64.strip():
_VOICEAGENTBENCH_REAL_AUDIO_AVAILABLE = True
return True
except Exception:
_VOICEAGENTBENCH_REAL_AUDIO_AVAILABLE = False
return False
_VOICEAGENTBENCH_REAL_AUDIO_AVAILABLE = False
return False
_VOICEBENCH_REAL_AUDIO_AVAILABLE: bool | None = None
_VOICEBENCH_QUALITY_REAL_INPUTS_AVAILABLE: bool | None = None
def _voicebench_quality_stt_provider() -> str:
explicit = (
os.environ.get("VOICEBENCH_QUALITY_STT_PROVIDER")
or os.environ.get("VOICEBENCH_STT_PROVIDER")
or ""
).strip().lower()
if explicit:
return explicit
if os.environ.get("GROQ_API_KEY"):
return "groq"
if importlib.util.find_spec("faster_whisper") is not None:
return "faster-whisper"
return "groq"
def _has_voicebench_quality_real_inputs() -> bool:
"""Return true only when VoiceBench-quality can run real audio + STT."""
global _VOICEBENCH_QUALITY_REAL_INPUTS_AVAILABLE
if _VOICEBENCH_QUALITY_REAL_INPUTS_AVAILABLE is not None:
return _VOICEBENCH_QUALITY_REAL_INPUTS_AVAILABLE
if importlib.util.find_spec("datasets") is None:
_VOICEBENCH_QUALITY_REAL_INPUTS_AVAILABLE = False
return False
stt_provider = _voicebench_quality_stt_provider()
if stt_provider == "groq":
ready = bool(os.environ.get("GROQ_API_KEY"))
elif stt_provider == "eliza-runtime":
ready = bool(
(os.environ.get("ELIZA_API_BASE") or os.environ.get("ELIZA_BENCH_URL") or "").strip()
)
elif stt_provider in {"faster-whisper", "local-whisper"}:
ready = importlib.util.find_spec("faster_whisper") is not None
else:
ready = False
_VOICEBENCH_QUALITY_REAL_INPUTS_AVAILABLE = ready
return ready
def _voicebench_dir() -> Path:
return Path(__file__).resolve().parents[1] / "voicebench"
def _eliza_state_dir() -> Path:
explicit = os.environ.get("ELIZA_STATE_DIR") or os.environ.get("ELIZA_STATE_DIR")
if explicit:
return Path(explicit).expanduser()
namespace = os.environ.get("ELIZA_NAMESPACE") or "eliza"
return Path.home() / f".{namespace}"
def _has_vision_language_bundle(tier: str = "eliza-1-9b") -> bool:
bundle = _eliza_state_dir() / "local-inference" / "models" / f"{tier}.bundle"
manifest = bundle / "eliza-1.manifest.json"
if not manifest.is_file():
return False
try:
manifest_payload = json.loads(manifest.read_text(encoding="utf-8"))
except Exception:
return False
if not isinstance(manifest_payload, dict):
return False
runtime = manifest_payload.get("runtime")
kernels = manifest_payload.get("kernels")
files = manifest_payload.get("files")
has_dflash_runtime = isinstance(runtime, dict) and "dflash" in runtime
has_dflash_kernel = (
isinstance(kernels, dict)
and isinstance(kernels.get("required"), list)
and "dflash" in {str(item) for item in kernels["required"]}
)
has_dflash_file = (
isinstance(files, dict)
and isinstance(files.get("dflash"), list)
and any(isinstance(item, dict) and item.get("path") for item in files["dflash"])
)
if not (has_dflash_runtime or has_dflash_kernel or has_dflash_file):
return False
slug = tier.removeprefix("eliza-1-")
text_candidates = [
bundle / "text" / f"eliza-1-{slug}-64k.gguf",
bundle / "text" / f"eliza-1-{slug}-32k.gguf",
bundle / "text" / f"eliza-1-{slug}-128k.gguf",
bundle / "text" / f"eliza-1-{slug}-256k.gguf",
bundle / "text" / f"eliza-1-{slug}.gguf",
]
vision = bundle / "vision" / f"mmproj-{slug}.gguf"
return vision.is_file() and any(path.is_file() for path in text_candidates)
def _has_textvqa_real_inputs() -> bool:
data_dir = os.environ.get("TEXTVQA_DATA_DIR")
if not data_dir:
return True
root = Path(data_dir).expanduser()
return (root / "TextVQA_0.5.1_val.json").is_file() and (root / "train_images").is_dir()
def _has_vision_language_real_inputs() -> bool:
tier = os.environ.get("VISION_LANGUAGE_TIER") or "eliza-1-9b"
provider = (os.environ.get("VISION_LANGUAGE_PROVIDER") or "").strip().lower()
local_enabled = os.environ.get("VISION_LANGUAGE_USE_LOCAL_ELIZA") == "1" or provider in {
"local-eliza",
"local_eliza",
"eliza-local",
"eliza_local",
}
return local_enabled and _has_vision_language_bundle(tier) and _has_textvqa_real_inputs()
def _has_vision_language_harness_runtime() -> bool:
provider = (os.environ.get("VISION_LANGUAGE_PROVIDER") or "openai").strip().lower()
model = (os.environ.get("VISION_LANGUAGE_MODEL") or "").strip()
if not model:
return False
if provider in {"local-eliza", "local_eliza", "eliza-local", "eliza_local"}:
return _has_vision_language_real_inputs()
if not _is_vision_language_multimodal_model(provider=provider, model=model):
return False
key_envs = {
"cerebras": ("CEREBRAS_API_KEY", "OPENAI_API_KEY"),
"openai": ("OPENAI_API_KEY",),
"openrouter": ("OPENROUTER_API_KEY", "OPENAI_API_KEY"),
"groq": ("GROQ_API_KEY", "OPENAI_API_KEY"),
"vllm": ("OPENAI_API_KEY",),
}.get(provider, ("OPENAI_API_KEY",))
return any(os.environ.get(name) for name in key_envs)
def _is_vision_language_multimodal_model(*, provider: str, model: str) -> bool:
if os.environ.get("VISION_LANGUAGE_MULTIMODAL") == "1":
return True
provider_key = provider.strip().lower()
model_key = model.strip().lower()
if provider_key in {"local-eliza", "local_eliza", "eliza-local", "eliza_local"}:
return model_key.startswith("eliza-1-")
if not model_key:
return False
if provider_key == "cerebras":
return False
multimodal_markers = (
"gpt-4o",
"gpt-4.1",
"o4-mini",
"qwen-vl",
"qwen2-vl",
"qwen2.5-vl",
"qwen3-vl",
"llava",
"pixtral",
"gemini",
"claude-3",
"claude-4",
"vision",
"vlm",
)
return any(marker in model_key for marker in multimodal_markers)
def _vision_language_compatible_harnesses() -> tuple[str, ...]:
if not _has_textvqa_real_inputs():
return ()
harnesses: list[str] = []
if _has_vision_language_real_inputs():
harnesses.append("eliza")
if _has_vision_language_harness_runtime():
harnesses.extend(["hermes", "openclaw"])
return tuple(harnesses)
def _voicebench_resolve_audio_path(raw_path: str, manifest_path: Path) -> Path:
direct = Path(raw_path).expanduser()
if not direct.is_absolute():
direct = manifest_path.parent / direct
if direct.is_file():
return direct
marker = "benchmarks/voicebench/"
marker_index = raw_path.find(marker)
if marker_index >= 0:
remapped = _voicebench_dir() / raw_path[marker_index + len(marker) :]
if remapped.is_file():
return remapped
return direct
def _voicebench_manifest_has_audio(manifest_path: Path) -> bool:
try:
root = json.loads(manifest_path.read_text(encoding="utf-8"))
except Exception:
return False
samples = root.get("samples") if isinstance(root, dict) else None
if not isinstance(samples, list) or not samples:
return False
for sample in samples:
if not isinstance(sample, dict):
return False
raw_path = sample.get("audioPath") or sample.get("audio_path")
if not isinstance(raw_path, str) or not raw_path.strip():
return False
if not _voicebench_resolve_audio_path(raw_path, manifest_path).is_file():
return False
return True
def _has_voicebench_real_audio_assets() -> bool:
"""Return true only when VoiceBench can run a publishable real voice profile."""
global _VOICEBENCH_REAL_AUDIO_AVAILABLE
if _VOICEBENCH_REAL_AUDIO_AVAILABLE is not None:
return _VOICEBENCH_REAL_AUDIO_AVAILABLE
profile = os.environ.get("VOICEBENCH_PROFILE", "").strip().lower()
if not profile:
profile = "local-cerebras" if os.environ.get("CEREBRAS_API_KEY") else "groq"
if profile == "local-cerebras":
if not os.environ.get("CEREBRAS_API_KEY"):
_VOICEBENCH_REAL_AUDIO_AVAILABLE = False
return False
if importlib.util.find_spec("faster_whisper") is None:
_VOICEBENCH_REAL_AUDIO_AVAILABLE = False
return False
say_bin = os.environ.get("VOICEBENCH_SAY_BIN", "").strip()
if say_bin:
if not Path(say_bin).expanduser().is_file():
_VOICEBENCH_REAL_AUDIO_AVAILABLE = False
return False
elif shutil.which("say") is None and not Path("/usr/bin/say").is_file():
_VOICEBENCH_REAL_AUDIO_AVAILABLE = False
return False
elif profile in {"groq", "elevenlabs"}:
if not os.environ.get("GROQ_API_KEY"):
_VOICEBENCH_REAL_AUDIO_AVAILABLE = False
return False
if profile == "elevenlabs" and not os.environ.get("ELEVENLABS_API_KEY"):
_VOICEBENCH_REAL_AUDIO_AVAILABLE = False
return False
else:
_VOICEBENCH_REAL_AUDIO_AVAILABLE = False
return False
audio_path_raw = os.environ.get("VOICEBENCH_AUDIO_PATH", "").strip()
if audio_path_raw:
_VOICEBENCH_REAL_AUDIO_AVAILABLE = Path(audio_path_raw).expanduser().is_file()
return _VOICEBENCH_REAL_AUDIO_AVAILABLE
dataset_raw = (
os.environ.get("VOICEBENCH_DATASET")
or os.environ.get("VOICEBENCH_DATASET_PATH")
or ""
).strip()
if dataset_raw:
manifest_path = Path(dataset_raw).expanduser()
elif profile == "local-cerebras":
_VOICEBENCH_REAL_AUDIO_AVAILABLE = importlib.util.find_spec("huggingface_hub") is not None
return _VOICEBENCH_REAL_AUDIO_AVAILABLE
else:
manifest_name = "manifest-elevenlabs.json" if profile == "elevenlabs" else "manifest-groq.json"
manifest_path = _voicebench_dir() / "fixtures" / manifest_name
_VOICEBENCH_REAL_AUDIO_AVAILABLE = (
manifest_path.is_file() and _voicebench_manifest_has_audio(manifest_path)
)
return _VOICEBENCH_REAL_AUDIO_AVAILABLE
def _is_benchmark_directory(path: Path) -> bool:
if not path.is_dir():
return False
name = path.name
if name.startswith("."):
return False
return name not in IGNORED_BENCHMARK_DIRS
def _make_registry_adapter(
workspace_root: Path,
benchmarks_root: Path,
score_extractor_factory: RegistryScoreExtractor,
benchmark_id: str,
display_name: str,
description: str,
benchmark_dir: str,
cwd_rel: str,
build_command,
locate_result,
requirements_env: tuple[str, ...],
default_extra_config: dict[str, Any] | None,
) -> BenchmarkAdapter:
def command_builder(ctx: ExecutionContext, adapter: BenchmarkAdapter) -> list[str]:
model = type("ModelSpecShim", (), {"provider": ctx.request.provider, "model": ctx.request.model, "temperature": None})()
extra_config = dict(ctx.request.extra_config)
extra_config.setdefault("agent", ctx.request.agent)
extra_config.setdefault("harness", ctx.request.agent)
return list(build_command(ctx.output_root, model, extra_config))
def result_locator(ctx: ExecutionContext, adapter: BenchmarkAdapter, benchmark_output_root: Path) -> Path | None:
try:
path = locate_result(benchmark_output_root)
if path.exists():
return path
except Exception:
pass
return _find_latest_json(benchmark_output_root)
cwd_candidates = [
(workspace_root / cwd_rel).resolve(),
(benchmarks_root / cwd_rel).resolve(),
(benchmarks_root / benchmark_dir).resolve(),
workspace_root.resolve(),
]
cwd_value = str(next((candidate for candidate in cwd_candidates if candidate.exists()), workspace_root.resolve()))
adapter_python_paths = [
str((benchmarks_root / "eliza-adapter").resolve()),
str((benchmarks_root / "hermes-adapter").resolve()),
str((benchmarks_root / "openclaw-adapter").resolve()),
]
lifeops_bench_path = benchmarks_root / "lifeops-bench"
if lifeops_bench_path.exists():
adapter_python_paths.append(str(lifeops_bench_path.resolve()))
if benchmark_id == "gauntlet":
adapter_python_paths.append(str((benchmarks_root / "gauntlet" / "src").resolve()))
if benchmark_id == "mmau":
adapter_python_paths.append(str((benchmarks_root / "mmau-audio").resolve()))
def env_builder(ctx: ExecutionContext, adapter: BenchmarkAdapter) -> dict[str, str]:
existing = ctx.env.get("PYTHONPATH", "")
pythonpath = (
os.pathsep.join([*adapter_python_paths, existing])
if existing
else os.pathsep.join(adapter_python_paths)
)
harness = str(
ctx.request.extra_config.get("agent")
or ctx.request.extra_config.get("harness")
or ctx.request.agent
).strip().lower()
model_name = _provider_model_name(ctx.request.provider, ctx.request.model)
env = {
"PYTHONPATH": pythonpath,
"BENCHMARK_HARNESS": harness,
"ELIZA_BENCH_HARNESS": harness,
"BENCHMARK_MODEL_PROVIDER": ctx.request.provider.strip(),
"BENCHMARK_MODEL_NAME": model_name,
"MODEL_NAME": model_name,
}
for extra_key, env_key in (
("openclaw_timeout_s", "OPENCLAW_TIMEOUT_S"),
("hermes_timeout_s", "HERMES_TIMEOUT_S"),
("eliza_bench_http_timeout_s", "ELIZA_BENCH_HTTP_TIMEOUT"),
("hl_bench_command_timeout_s", "HL_BENCH_COMMAND_TIMEOUT_S"),
):
value = ctx.request.extra_config.get(extra_key)
if isinstance(value, (int, float)) and value > 0:
env[env_key] = str(float(value))
if benchmark_id in {"bfcl", "clawbench", "terminal_bench", "tau_bench", "lifeops_bench"} and harness == "openclaw":
env["OPENCLAW_DIRECT_OPENAI_COMPAT"] = "1"
env["OPENCLAW_USE_CLI"] = "0"
if benchmark_id in {
"terminal_bench",
"swe_bench",
"swe_bench_orchestrated",
"osworld",
"hermes_tblite",
"hermes_terminalbench_2",
"hermes_yc_bench",
"hermes_swe_env",
}:
desktop_socket = Path.home() / ".docker" / "run" / "docker.sock"
if desktop_socket.exists():
env.setdefault("DOCKER_HOST", f"unix://{desktop_socket}")
if benchmark_id == "hyperliquid_bench":
# Hyperliquid asks for strict JSON text plans. The generic
# benchmark action tool surface makes malformed-plan retries more
# likely and can stall the smoke when the model keeps tool-calling.
env["ELIZA_BENCH_FORCE_TOOL_CALL"] = "0"
return env
return BenchmarkAdapter(
id=benchmark_id,
directory=benchmark_dir,
description=f"{display_name}: {description}",
cwd=cwd_value,
command_builder=command_builder,
result_locator=result_locator,
score_extractor=score_extractor_factory.for_benchmark(benchmark_id),
required_env=tuple(requirements_env),
default_extra_config=dict(default_extra_config or {}),
env_builder=env_builder,
agent_compatibility=_agent_compatibility_for(benchmark_id),
result_patterns=("registry locate_result(output_dir)", "**/*.json fallback"),
)
def _make_extra_adapter(
*,
adapter_id: str,
directory: str,
description: str,
cwd: str,
command_builder,
result_patterns: list[str],
required_env: tuple[str, ...] = (),
default_extra_config: dict[str, Any] | None = None,
env_builder=None,
score_extractor=_json_score,
capability_notes: str = "",
default_timeout_seconds: int = 3600,
) -> BenchmarkAdapter:
def result_locator(ctx: ExecutionContext, adapter: BenchmarkAdapter, benchmark_output_root: Path) -> Path | None:
path = _find_latest_by_patterns(benchmark_output_root, result_patterns)
if path is not None:
return path
cwd_root = Path(adapter.cwd)
if cwd_root.exists():
path = _find_latest_by_patterns(cwd_root, result_patterns)
if path is not None:
return path
return _find_latest_json(benchmark_output_root)
return BenchmarkAdapter(
id=adapter_id,
directory=directory,
description=description,
cwd=cwd,
command_builder=command_builder,
result_locator=result_locator,
score_extractor=score_extractor,
required_env=required_env,
default_extra_config=dict(default_extra_config or {}),
env_builder=env_builder,
capability_notes=capability_notes,
default_timeout_seconds=default_timeout_seconds,
agent_compatibility=_agent_compatibility_for(adapter_id),
result_patterns=tuple(result_patterns),
)
def _command_hyperliquid(ctx: ExecutionContext, adapter: BenchmarkAdapter) -> list[str]:
args = [
sys.executable,
"-m",
"benchmarks.HyperliquidBench",
"--coverage",
"--output",
str(ctx.output_root),
]
if ctx.request.model:
args.extend(["--model", ctx.request.model])
if "max_steps" in ctx.request.extra_config:
args.extend(["--max-steps", str(int(ctx.request.extra_config["max_steps"]))])
if "max_iterations" in ctx.request.extra_config:
args.extend(["--max-iterations", str(int(ctx.request.extra_config["max_iterations"]))])
return args
def _command_adhdbench(ctx: ExecutionContext, adapter: BenchmarkAdapter) -> list[str]:
provider = ctx.request.provider.strip().lower()
# Route LLM-backed providers through the eliza TS bridge by default so
# the registered eliza agent + plugins are exercised. Callers can
# opt out via extra_config "use_direct_provider": True.
bridge_providers = {"cerebras", "openai", "groq", "openrouter", "vllm", "eliza"}
use_direct = bool(ctx.request.extra_config.get("use_direct_provider"))
if ctx.request.extra_config.get("mock") is True or provider == "mock":
effective_provider = "mock-passthrough"
else:
effective_provider = (
"eliza" if (provider in bridge_providers and not use_direct) else ctx.request.provider
)
args = [
sys.executable,
"scripts/run_benchmark.py",
"run",
"--provider",
effective_provider,
"--model",
ctx.request.model,
"--output",
str(ctx.output_root),
]
mode = str(ctx.request.extra_config.get("mode", "")).strip().lower()
if mode in {"quick", "full"}:
args.append(f"--{mode}")
if "levels" in ctx.request.extra_config and isinstance(ctx.request.extra_config["levels"], list):
levels = [str(int(x)) for x in ctx.request.extra_config["levels"]]
if levels:
args.extend(["--levels", *levels])
if "ids" in ctx.request.extra_config and isinstance(ctx.request.extra_config["ids"], list):
ids = [str(x) for x in ctx.request.extra_config["ids"] if str(x)]
if ids:
args.extend(["--ids", *ids])
if "tags" in ctx.request.extra_config and isinstance(ctx.request.extra_config["tags"], list):
tags = [str(x) for x in ctx.request.extra_config["tags"] if str(x)]
if tags:
args.extend(["--tags", *tags])
if ctx.request.extra_config.get("basic_only"):
args.append("--basic-only")
if ctx.request.extra_config.get("full_only"):
args.append("--full-only")
return args
def _command_configbench(ctx: ExecutionContext, adapter: BenchmarkAdapter) -> list[str]:
args = ["bun", "run", "src/index.ts", "--output", str(ctx.output_root)]
agent = ctx.request.extra_config.get("agent")
provider_name = ctx.request.provider.strip().lower()
harness = ctx.request.agent.strip().lower()
if harness in {"eliza", "hermes", "openclaw"}:
args.extend(["--harness", harness])
elif (
agent == "eliza"
or ctx.request.extra_config.get("eliza") is True
or provider_name == "eliza"
):
args.append("--eliza")
limit = ctx.request.extra_config.get("limit")
if isinstance(limit, int) and limit > 0:
args.extend(["--limit", str(limit)])
if ctx.request.extra_config.get("verbose") is True:
args.append("--verbose")
return args
def _env_configbench(ctx: ExecutionContext, adapter: BenchmarkAdapter) -> dict[str, str]:
provider_name = ctx.request.provider.strip().lower()
model_name = _provider_model_name(ctx.request.provider, ctx.request.model)
env: dict[str, str] = {}
if provider_name in {"groq", "openai", "anthropic"}:
env["CONFIGBENCH_AGENT_PROVIDER"] = provider_name
elif provider_name in {"cerebras", "openrouter", "vllm"}:
env["CONFIGBENCH_AGENT_PROVIDER"] = "openai"
if provider_name == "groq" and model_name:
env["GROQ_SMALL_MODEL"] = model_name
env["GROQ_LARGE_MODEL"] = model_name
elif provider_name in {"openai", "cerebras", "openrouter", "vllm"} and model_name:
env["OPENAI_SMALL_MODEL"] = model_name
env["OPENAI_LARGE_MODEL"] = model_name
return env
def _command_experience(ctx: ExecutionContext, adapter: BenchmarkAdapter) -> list[str]:
provider = ctx.request.provider.strip().lower()
if ctx.request.extra_config.get("mock") is True or provider == "mock":
mode = "direct"
else:
mode = str(ctx.request.extra_config.get("mode", "eliza-agent"))
args = [
sys.executable,
"run_benchmark.py",
"--mode",
mode,
]
if mode != "direct":
args.extend(["--provider", ctx.request.provider, "--model", ctx.request.model])
if "output_file" in ctx.request.extra_config:
args.extend(["--output", str(ctx.request.extra_config["output_file"])])
else:
args.extend(["--output", str(ctx.output_root / "experience-results.json")])
experiences = ctx.request.extra_config.get("experiences")
if isinstance(experiences, int) and experiences > 0:
args.extend(["--experiences", str(experiences)])
queries = ctx.request.extra_config.get("queries", ctx.request.extra_config.get("max_tasks"))
if isinstance(queries, int) and queries > 0:
args.extend(["--queries", str(queries)])
learning_cycles = ctx.request.extra_config.get(
"learning_cycles",
ctx.request.extra_config.get("max_tasks"),
)
if isinstance(learning_cycles, int) and learning_cycles > 0:
args.extend(["--learning-cycles", str(learning_cycles)])
if "seed" in ctx.request.extra_config:
args.extend(["--seed", str(int(ctx.request.extra_config["seed"]))])
return args
def _command_app_eval(ctx: ExecutionContext, adapter: BenchmarkAdapter) -> list[str]:
mode = str(ctx.request.extra_config.get("mode", "bridge")).strip().lower()
if mode in {"app-cli", "legacy"}:
args = [
"bun",
"run",
"run-benchmarks.ts",
"--root",
str(ctx.workspace_root.parent.resolve()),
]
task_type = ctx.request.extra_config.get("type")
if isinstance(task_type, str) and task_type.strip():
args.extend(["--type", task_type.strip()])
task_id = ctx.request.extra_config.get("task")
if isinstance(task_id, str) and task_id.strip():
args.extend(["--task", task_id.strip()])
timeout = ctx.request.extra_config.get("timeout_ms")
if isinstance(timeout, int) and timeout > 0:
args.extend(["--timeout", str(timeout)])
if ctx.request.extra_config.get("server") is True:
args.append("--server")
if ctx.request.extra_config.get("verbose") is True:
args.append("--verbose")
return args
args = [
sys.executable,
"-m",
"eliza_adapter.app_eval",
"--tasks-dir",
str((ctx.benchmarks_root / "app-eval" / "tasks").resolve()),
"--output",
str(ctx.output_root / "summary.json"),
]
if ctx.request.extra_config.get("mock") is True or ctx.request.provider.strip().lower() == "mock":
args.append("--mock")
task_type = ctx.request.extra_config.get("type")
if isinstance(task_type, str) and task_type.strip():
args.extend(["--type", task_type.strip()])
task_id = ctx.request.extra_config.get("task")
if isinstance(task_id, str) and task_id.strip():
args.extend(["--task", task_id.strip()])
timeout = ctx.request.extra_config.get("timeout_ms")
if isinstance(timeout, int) and timeout > 0:
args.extend(["--timeout-ms", str(timeout)])
return args
def _env_app_eval(ctx: ExecutionContext, adapter: BenchmarkAdapter) -> dict[str, str]:
existing = ctx.env.get("PYTHONPATH", "")
adapter_path = str((ctx.benchmarks_root / "eliza-adapter").resolve())
env = {
"PYTHONPATH": os.pathsep.join([adapter_path, existing]).rstrip(os.pathsep),
"ELIZA_APP_ROOT": str(ctx.workspace_root.parent.resolve()),
"ELIZA_HEADLESS": "1",
"LOG_LEVEL": "error",
}
model = _provider_model_name(ctx.request.provider, ctx.request.model)
provider = ctx.request.provider.strip().upper()
if model:
env.update({
"BENCHMARK_MODEL_NAME": model,
"MODEL_NAME": model,
"SMALL_MODEL": model,
"LARGE_MODEL": model,
})
if provider and provider != "MOCK":
env[f"{provider}_SMALL_MODEL"] = model
env[f"{provider}_LARGE_MODEL"] = model
return env