agentbench-ai 0.1.0__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.
- agentbench/__init__.py +2 -0
- agentbench/__main__.py +3 -0
- agentbench/cli.py +173 -0
- agentbench/config.py +88 -0
- agentbench/data_meta.json +28 -0
- agentbench/fixtures/__init__.py +1 -0
- agentbench/fixtures/base.py +1179 -0
- agentbench/fixtures/tier4.py +645 -0
- agentbench/fixtures/tier5.py +407 -0
- agentbench/fixtures/tier5b.py +424 -0
- agentbench/fixtures/tier6.py +528 -0
- agentbench/grading.py +326 -0
- agentbench/reference/__init__.py +0 -0
- agentbench/reference/t10/solve.py +23 -0
- agentbench/reference/t11/csvkit/parse.py +116 -0
- agentbench/reference/t12/q.py +451 -0
- agentbench/reference/t17/queuekit/queue.py +53 -0
- agentbench/reference/t19/report.py +19 -0
- agentbench/reference/t2/ledger/core.py +23 -0
- agentbench/reference/t20/cli.py +79 -0
- agentbench/reference/t21/calc.py +7 -0
- agentbench/reference/t22/server.py +117 -0
- agentbench/reference/t23/migrate.py +105 -0
- agentbench/reference/t24/serve.py +67 -0
- agentbench/reference/t25/merge3.py +77 -0
- agentbench/reference/t26/agg.py +31 -0
- agentbench/reference/t3/bin/audit +58 -0
- agentbench/reference/t7/emailkit/normalize.py +43 -0
- agentbench/reference/t9/engine.py +94 -0
- agentbench/runner.py +94 -0
- agentbench/selftest.py +278 -0
- agentbench_ai-0.1.0.dist-info/METADATA +181 -0
- agentbench_ai-0.1.0.dist-info/RECORD +37 -0
- agentbench_ai-0.1.0.dist-info/WHEEL +5 -0
- agentbench_ai-0.1.0.dist-info/entry_points.txt +2 -0
- agentbench_ai-0.1.0.dist-info/licenses/LICENSE +21 -0
- agentbench_ai-0.1.0.dist-info/top_level.txt +1 -0
agentbench/__init__.py
ADDED
agentbench/__main__.py
ADDED
agentbench/cli.py
ADDED
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
"""agentbench command line interface."""
|
|
2
|
+
from __future__ import annotations
|
|
3
|
+
|
|
4
|
+
import argparse
|
|
5
|
+
import json
|
|
6
|
+
import os
|
|
7
|
+
import shutil
|
|
8
|
+
import subprocess
|
|
9
|
+
import sys
|
|
10
|
+
import urllib.request
|
|
11
|
+
from pathlib import Path
|
|
12
|
+
|
|
13
|
+
from . import __version__
|
|
14
|
+
from .config import (PKG, Settings, all_tasks, codex_binary, default_home,
|
|
15
|
+
task_catalog, write_harness_home)
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
def _settings(args) -> Settings:
|
|
19
|
+
s = Settings()
|
|
20
|
+
if getattr(args, "home", None):
|
|
21
|
+
s.home = Path(args.home).expanduser()
|
|
22
|
+
s.effort = getattr(args, "effort", None) or s.effort
|
|
23
|
+
s.timeout = getattr(args, "timeout", None) or s.timeout
|
|
24
|
+
s.workers = getattr(args, "workers", None) or s.workers
|
|
25
|
+
return s
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
def _split(values: list[str] | None) -> list[str] | None:
|
|
29
|
+
if not values:
|
|
30
|
+
return None
|
|
31
|
+
out: list[str] = []
|
|
32
|
+
for chunk in values:
|
|
33
|
+
out.extend(x for x in chunk.replace(",", " ").split() if x)
|
|
34
|
+
return out
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
def cmd_build(args) -> int:
|
|
38
|
+
from .fixtures import build
|
|
39
|
+
|
|
40
|
+
s = _settings(args)
|
|
41
|
+
only = _split(args.only)
|
|
42
|
+
s.home.mkdir(parents=True, exist_ok=True)
|
|
43
|
+
answers = build(only=only, root=s.home)
|
|
44
|
+
print(f"built {len(only) if only else len(task_catalog())} tasks into {s.home}")
|
|
45
|
+
print(f"answers: {len(answers)} keys")
|
|
46
|
+
return 0
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
def cmd_list(args) -> int:
|
|
50
|
+
s = _settings(args)
|
|
51
|
+
meta = task_catalog()
|
|
52
|
+
built = set(all_tasks(s))
|
|
53
|
+
rows = [{"task": k, "category": v, "built": k in built} for k, v in sorted(meta.items())]
|
|
54
|
+
if args.json:
|
|
55
|
+
print(json.dumps(rows, indent=1))
|
|
56
|
+
return 0
|
|
57
|
+
width = max(len(r["task"]) for r in rows)
|
|
58
|
+
for r in rows:
|
|
59
|
+
flag = "*" if r["built"] else " "
|
|
60
|
+
print(f"{flag} {r['task']:<{width}} {r['category']}")
|
|
61
|
+
print("\n* = built in " + str(s.tasks_dir))
|
|
62
|
+
return 0
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
def cmd_run(args) -> int:
|
|
66
|
+
from .runner import run
|
|
67
|
+
|
|
68
|
+
s = _settings(args)
|
|
69
|
+
models = _split(args.models) or []
|
|
70
|
+
if not models:
|
|
71
|
+
print("error: --models is required", file=sys.stderr)
|
|
72
|
+
return 2
|
|
73
|
+
tasks = _split(args.tasks)
|
|
74
|
+
if tasks:
|
|
75
|
+
known = set(task_catalog())
|
|
76
|
+
unknown = [t for t in tasks if t not in known]
|
|
77
|
+
if unknown:
|
|
78
|
+
print(f"error: unknown task(s): {', '.join(unknown)}", file=sys.stderr)
|
|
79
|
+
return 2
|
|
80
|
+
runs = run(s, models, tasks=tasks, run_id=args.run_id, resume=args.resume)
|
|
81
|
+
print(f"runs: {runs}")
|
|
82
|
+
return 0
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
def cmd_grade(args) -> int:
|
|
86
|
+
from . import grading
|
|
87
|
+
|
|
88
|
+
s = _settings(args)
|
|
89
|
+
grading.configure(s.home)
|
|
90
|
+
sys.argv = ["agentbench-grade", str(args.run_dir)]
|
|
91
|
+
grading.main()
|
|
92
|
+
return 0
|
|
93
|
+
|
|
94
|
+
|
|
95
|
+
def cmd_selftest(args) -> int:
|
|
96
|
+
s = _settings(args)
|
|
97
|
+
env = dict(os.environ, AGENTBENCH_ROOT=str(s.home))
|
|
98
|
+
return subprocess.call([sys.executable, "-m", "agentbench.selftest"], env=env,
|
|
99
|
+
cwd=str(PKG.parent.parent))
|
|
100
|
+
|
|
101
|
+
|
|
102
|
+
def cmd_doctor(args) -> int:
|
|
103
|
+
s = _settings(args)
|
|
104
|
+
checks = []
|
|
105
|
+
codex = Path(s.codex)
|
|
106
|
+
checks.append(("codex binary", codex.exists(), str(codex)))
|
|
107
|
+
checks.append(("git", shutil.which("git") is not None, shutil.which("git") or ""))
|
|
108
|
+
checks.append(("npx (browser MCP)", shutil.which("npx") is not None,
|
|
109
|
+
shutil.which("npx") or ""))
|
|
110
|
+
gateway = os.environ.get("AGENTBENCH_GATEWAY", "http://127.0.0.1:3425")
|
|
111
|
+
ok = False
|
|
112
|
+
try:
|
|
113
|
+
with urllib.request.urlopen(gateway.rstrip("/") + "/v1/models", timeout=3) as r:
|
|
114
|
+
ok = r.status == 200
|
|
115
|
+
except Exception:
|
|
116
|
+
ok = False
|
|
117
|
+
checks.append(("gateway", ok, gateway))
|
|
118
|
+
built = len(all_tasks(s))
|
|
119
|
+
checks.append(("tasks built", built > 0, f"{built} in {s.tasks_dir}"))
|
|
120
|
+
width = max(len(c[0]) for c in checks)
|
|
121
|
+
rc = 0
|
|
122
|
+
for name, ok, detail in checks:
|
|
123
|
+
print(f"{'ok ' if ok else 'FAIL'} {name:<{width}} {detail}")
|
|
124
|
+
rc |= 0 if ok else 1
|
|
125
|
+
return rc
|
|
126
|
+
|
|
127
|
+
|
|
128
|
+
def build_parser() -> argparse.ArgumentParser:
|
|
129
|
+
p = argparse.ArgumentParser(
|
|
130
|
+
prog="agentbench",
|
|
131
|
+
description="Agentic coding benchmark: build tasks, run models, grade runs.")
|
|
132
|
+
p.add_argument("--version", action="version", version=f"agentbench {__version__}")
|
|
133
|
+
p.add_argument("--home", help=f"workspace directory (default: {default_home()})")
|
|
134
|
+
sub = p.add_subparsers(dest="cmd", required=True)
|
|
135
|
+
|
|
136
|
+
b = sub.add_parser("build", help="generate task fixtures and hidden tests")
|
|
137
|
+
b.add_argument("--only", action="append", help="restrict to task ids (repeatable)")
|
|
138
|
+
b.set_defaults(func=cmd_build)
|
|
139
|
+
|
|
140
|
+
l = sub.add_parser("list", help="list tasks and categories")
|
|
141
|
+
l.add_argument("--json", action="store_true")
|
|
142
|
+
l.set_defaults(func=cmd_list)
|
|
143
|
+
|
|
144
|
+
r = sub.add_parser("run", help="run tasks against one or more models")
|
|
145
|
+
r.add_argument("--models", action="append", required=True,
|
|
146
|
+
help="model ids, comma or space separated (repeatable)")
|
|
147
|
+
r.add_argument("--tasks", action="append", help="task ids (default: all built)")
|
|
148
|
+
r.add_argument("--run-id")
|
|
149
|
+
r.add_argument("--timeout", type=int)
|
|
150
|
+
r.add_argument("--effort", choices=["minimal", "low", "medium", "high"])
|
|
151
|
+
r.add_argument("--workers", type=int)
|
|
152
|
+
r.add_argument("--resume", action="store_true")
|
|
153
|
+
r.set_defaults(func=cmd_run)
|
|
154
|
+
|
|
155
|
+
g = sub.add_parser("grade", help="grade a run directory")
|
|
156
|
+
g.add_argument("run_dir")
|
|
157
|
+
g.set_defaults(func=cmd_grade)
|
|
158
|
+
|
|
159
|
+
st = sub.add_parser("selftest", help="validate every grader against its reference")
|
|
160
|
+
st.set_defaults(func=cmd_selftest)
|
|
161
|
+
|
|
162
|
+
d = sub.add_parser("doctor", help="check local prerequisites")
|
|
163
|
+
d.set_defaults(func=cmd_doctor)
|
|
164
|
+
return p
|
|
165
|
+
|
|
166
|
+
|
|
167
|
+
def main(argv=None) -> int:
|
|
168
|
+
args = build_parser().parse_args(argv)
|
|
169
|
+
return args.func(args)
|
|
170
|
+
|
|
171
|
+
|
|
172
|
+
if __name__ == "__main__":
|
|
173
|
+
raise SystemExit(main())
|
agentbench/config.py
ADDED
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
"""Configuration: where the workspace lives and which models/tasks exist."""
|
|
2
|
+
from __future__ import annotations
|
|
3
|
+
|
|
4
|
+
import json
|
|
5
|
+
import os
|
|
6
|
+
from dataclasses import dataclass, field
|
|
7
|
+
from pathlib import Path
|
|
8
|
+
|
|
9
|
+
PKG = Path(__file__).resolve().parent
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
def default_home() -> Path:
|
|
13
|
+
env = os.environ.get("AGENTBENCH_HOME")
|
|
14
|
+
if env:
|
|
15
|
+
return Path(env).expanduser()
|
|
16
|
+
return Path.home() / ".cache" / "agentbench"
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
def codex_binary() -> str:
|
|
20
|
+
return os.environ.get("AGENTBENCH_CODEX",
|
|
21
|
+
"/Applications/ChatGPT.app/Contents/Resources/codex-cli/"
|
|
22
|
+
"CodexCLI.app/Contents/MacOS/codex")
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
@dataclass
|
|
26
|
+
class Settings:
|
|
27
|
+
home: Path = field(default_factory=default_home)
|
|
28
|
+
effort: str = "low"
|
|
29
|
+
timeout: int = 900
|
|
30
|
+
workers: int = 1
|
|
31
|
+
codex: str = field(default_factory=codex_binary)
|
|
32
|
+
codex_home: Path | None = None
|
|
33
|
+
|
|
34
|
+
@property
|
|
35
|
+
def tasks_dir(self) -> Path:
|
|
36
|
+
return self.home / "tasks"
|
|
37
|
+
|
|
38
|
+
@property
|
|
39
|
+
def hidden_dir(self) -> Path:
|
|
40
|
+
return self.home / "hidden"
|
|
41
|
+
|
|
42
|
+
@property
|
|
43
|
+
def runs_dir(self) -> Path:
|
|
44
|
+
return self.home / "runs"
|
|
45
|
+
|
|
46
|
+
@property
|
|
47
|
+
def harness_home(self) -> Path:
|
|
48
|
+
return self.codex_home or (self.home / "codex-home")
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
def task_catalog() -> dict:
|
|
52
|
+
meta = json.loads((PKG / "data_meta.json").read_text())
|
|
53
|
+
return meta
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
def all_tasks(settings: Settings) -> list[str]:
|
|
57
|
+
if not settings.tasks_dir.exists():
|
|
58
|
+
return []
|
|
59
|
+
return sorted(p.name for p in settings.tasks_dir.iterdir() if p.is_dir())
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
def write_harness_home(settings: Settings) -> Path:
|
|
63
|
+
"""Create a clean CODEX_HOME with the magpie provider and browser MCP."""
|
|
64
|
+
home = settings.harness_home
|
|
65
|
+
home.mkdir(parents=True, exist_ok=True)
|
|
66
|
+
base_url = os.environ.get("AGENTBENCH_GATEWAY", "http://127.0.0.1:3425/v1")
|
|
67
|
+
config = f'''model_provider = "magpie"
|
|
68
|
+
forced_login_method = "api"
|
|
69
|
+
approval_policy = "never"
|
|
70
|
+
sandbox_mode = "danger-full-access"
|
|
71
|
+
model_reasoning_effort = "{settings.effort}"
|
|
72
|
+
web_search = "disabled"
|
|
73
|
+
mcp_optional_startup_grace_ms = 0
|
|
74
|
+
|
|
75
|
+
[model_providers.magpie]
|
|
76
|
+
name = "magpie"
|
|
77
|
+
base_url = "{base_url}"
|
|
78
|
+
wire_api = "responses"
|
|
79
|
+
experimental_bearer_token = "magpie"
|
|
80
|
+
http_headers = {{ "x-openai-actor-authorization" = "magpie" }}
|
|
81
|
+
|
|
82
|
+
[mcp_servers.chrome-devtools]
|
|
83
|
+
command = "npx"
|
|
84
|
+
args = ["-y", "chrome-devtools-mcp@latest"]
|
|
85
|
+
startup_timeout_sec = 60.0
|
|
86
|
+
'''
|
|
87
|
+
(home / "config.toml").write_text(config)
|
|
88
|
+
return home
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
{
|
|
2
|
+
"t1-knapsack": "algorithms",
|
|
3
|
+
"t2-ledger": "debugging",
|
|
4
|
+
"t3-audit-cli": "spec-precision",
|
|
5
|
+
"t4-injection": "robustness",
|
|
6
|
+
"t5-logs": "forensics",
|
|
7
|
+
"t6-xirr": "numerics",
|
|
8
|
+
"t7-normalize": "spec-precision",
|
|
9
|
+
"t8-schedule": "algorithms",
|
|
10
|
+
"t9-engine": "systems",
|
|
11
|
+
"t10-perf": "performance",
|
|
12
|
+
"t11-csv": "spec-precision",
|
|
13
|
+
"t12-sql": "systems",
|
|
14
|
+
"t13-review": "judgment",
|
|
15
|
+
"t14-logic": "reasoning",
|
|
16
|
+
"t15-browser": "tooling",
|
|
17
|
+
"t16-dossier": "long-context",
|
|
18
|
+
"t17-concurrency": "concurrency",
|
|
19
|
+
"t18-security": "judgment",
|
|
20
|
+
"t19-perf": "performance",
|
|
21
|
+
"t20-feature": "refactor",
|
|
22
|
+
"t21-bisect": "tooling",
|
|
23
|
+
"t22-http": "spec-precision",
|
|
24
|
+
"t23-migration": "long-horizon",
|
|
25
|
+
"t24-gauntlet": "tooling",
|
|
26
|
+
"t25-merge": "precision",
|
|
27
|
+
"t26-stream": "performance"
|
|
28
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
from .base import build, set_root # noqa: F401
|