Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/omega-mv/blob/main/seed/agent/bench/equal_bench.py # omega-mv Omega: a language for verified programs, semantic identity and machine realization. Seed-born work and existing implementations have distinct provenance. Brought by drakestapleton Sign in to star 1 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `main` Branches Tags History `omega-mv / seed / agent / bench / equal_bench.py` 102 lines ยท 5477 bytes Raw Blame History 1 #!/usr/bin/env python3 2 """TEST-ONLY equal-work benchmark driver: omagent vs nanobot reduced to the same four tools. 3 4 Usage: equal_bench.py OMAGENT VENV_PYTHON N CPU DELAY_MS OUT.tsv 5 Both arms get the same prompt, endpoint, scripted mock (equal_mock.py), streaming, workspace 6 contents and tool script (read_file, write_file, one /bin/echo through each harness's shell tool, 7 final answer). Each run is a fresh process with a fresh session: nanobot's session store is 8 deleted between runs, omagent runs without --session. Client pinned with taskset to CPU, the 9 mock to CPU+1. Arms alternate order every repetition (paired, interleaved). 10 Row: arm cpu delay_ms rep wall_ns first_req_ns maxrss_kib rc posts verdict 11 first_req_ns = mock arrival of the first POST minus the driver's launch time (CLOCK_MONOTONIC). 12 verdict is ok only if the mock saw all four steps with correct tool results, out.txt holds 13 beta-456 and stdout holds delta-000.""" 14 import json, os, shutil, subprocess, sys, time, urllib.request 15 16 B, PY, N, CPU, DELAY, OUT = sys.argv[1], sys.argv[2], int(sys.argv[3]), int(sys.argv[4]), sys.argv[5], sys.argv[6] 17 D = os.path.dirname(os.path.abspath(__file__)) 18 H = "/tmp/OmegaBot-eq-%d-%s" % (CPU, DELAY) 19 PROMPT = "Read notes.txt, write beta-456 to out.txt, run /bin/echo gamma-789, then reply done." 20 shutil.rmtree(H, ignore_errors=True) 21 os.makedirs(H + "/nb/workspace") 22 os.makedirs(H + "/om") 23 pf = H + "/port" 24 mock = subprocess.Popen(["taskset", "-c", str(CPU + 1), sys.executable, D + "/equal_mock.py", pf, DELAY]) 25 for _ in range(100): 26 if os.path.exists(pf) and open(pf).read(): 27 break 28 time.sleep(0.05) 29 P = int(open(pf).read()) 30 assert P != 18091 31 URL = "http://127.0.0.1:%d/v1" % P 32 cfg = H + "/nb/config.json" 33 json.dump({ 34 "agents": {"defaults": {"workspace": H + "/nb/workspace", "model": "mock-1", "provider": "custom", 35 "timezone": "UTC", "maxToolIterations": 8, 36 "disabledSkills": ["clawhub", "cron", "github", "memory", "skill-creator", "summarize", 37 "tmux", "weather", "my", "image-generation", "update-setup"]}}, 38 "providers": {"custom": {"apiKey": "sk-test", "apiBase": URL}}, 39 "tools": {"restrictToWorkspace": True, "mcpServers": {}, 40 "exec": {"enable": True, "timeout": 10}, 41 "web": {"enable": True, "fetch": {"useJinaReader": False}}, 42 "file": {"enable": True}, 43 "cliApps": {"enable": False}, "my": {"enable": False}, "imageGeneration": {"enabled": False}}, 44 }, open(cfg, "w")) 45 ENV = dict(os.environ, HOME=H + "/nb", OMAGENT_KEY="sk-test") 46 # Peak RSS comes from GNU time, whose child is forked from a small C process; the driver's own 47 # rusage would charge the forked Python driver image to the child before exec. 48 TIME = ["/usr/bin/time", "-f", "%M", "-o", H + "/rss"] 49 CMD = { 50 "omagent": (TIME + ["taskset", "-c", str(CPU), B, "--url", URL + "/chat/completions", "--model", "mock-1", 51 "--key-env", "OMAGENT_KEY", "-p", PROMPT, "--workdir", H + "/om", "--allow-write", 52 "--allow-cmd", "/bin/echo", "--cmd-timeout", "10", "--max-rounds", "8"], H + "/om"), 53 "nanobot": (TIME + ["taskset", "-c", str(CPU), PY, D + "/nb_minimal.py", "agent", "-m", PROMPT, "--no-markdown", 54 "-c", cfg, "-w", H + "/nb/workspace"], H + "/nb/workspace"), 55 } 56 57 58 def state(): 59 return json.load(urllib.request.urlopen("http://127.0.0.1:%d/state" % P)) 60 61 62 def one(arm): 63 cmd, wd = CMD[arm] 64 for f in ("out.txt",): 65 if os.path.exists(os.path.join(wd, f)): 66 os.unlink(os.path.join(wd, f)) 67 open(os.path.join(wd, "notes.txt"), "w").write("alpha-123\n") 68 shutil.rmtree(H + "/nb/sessions", ignore_errors=True) 69 mem = H + "/nb/workspace/memory" 70 if os.path.isdir(H + "/memory.snap"): 71 shutil.rmtree(mem, ignore_errors=True) 72 shutil.copytree(H + "/memory.snap", mem) 73 state() 74 so = open(H + "/stdout", "w") 75 t0 = time.monotonic_ns() 76 p = subprocess.Popen(cmd, cwd=wd, env=ENV, stdout=so, stderr=subprocess.DEVNULL, stdin=subprocess.DEVNULL) 77 _, status, ru = os.wait4(p.pid, 0) 78 t1 = time.monotonic_ns() 79 p.returncode = os.waitstatus_to_exitcode(status) 80 so.close() 81 st = state() 82 out = open(H + "/stdout").read() 83 okf = os.path.exists(os.path.join(wd, "out.txt")) and open(os.path.join(wd, "out.txt")).read().strip() == "beta-456" 84 ok = p.returncode == 0 and st["posts"] == 4 and not st["bad"] and okf and "delta-000" in out 85 verdict = "ok" if ok else "BAD:" + json.dumps({"posts": st["posts"], "bad": st["bad"], "file": okf, "out": out[-200:]}) 86 rss = int(open(H + "/rss").read().split()[-1]) 87 return [t1 - t0, (st["first_ns"] - t0) if st["first_ns"] else -1, rss, p.returncode, st["posts"], verdict, st["tools"], st["req_bytes"]] 88 89 90 with open(OUT, "w") as fh: 91 for arm in ("omagent", "nanobot"): # warm-up, not recorded; also records the advertised tools 92 r = one(arm) 93 print("warmup", arm, r[3], r[5], "tools=" + ",".join(r[6]), "req_bytes=%d" % r[7], flush=True) 94 if arm == "nanobot": 95 shutil.copytree(H + "/nb/workspace/memory", H + "/memory.snap") 96 for rep in range(1, N + 1): 97 order = ("omagent", "nanobot") if rep % 2 else ("nanobot", "omagent") 98 for arm in order: 99 r = one(arm) 100 fh.write("\t".join(map(str, [arm, CPU, DELAY, rep] + r[:6] + [r[7]])) + "\n") 101 fh.flush() 102 mock.kill()