Repository navigation
Real-model benchmark: Hermes cron, gpt-4o-mini, published injections, no-key replay - #12
Conversation
…d injections, no-key replay Mandate blocked 29 of 29 attack calls (0 of 120 attack runs with harm vs 18 with Hermes defaults), 9 of 263 legit calls falsely blocked. make bench replays the traces for free. See bench/README.md.
There was a problem hiding this comment.
Devin Review found 4 potential issues.
1 flag not posted on this PR by your GitHub settings — view it in Devin Review. (Configure)
| def ok(self) -> bool: | ||
| try: | ||
| if self.spent() >= self.stop_usd: | ||
| STOP.set() | ||
| except Exception: | ||
| pass | ||
| return not STOP.is_set() |
There was a problem hiding this comment.
🔴 Spend cap disappears on usage errors
When the key-usage request fails, Spend.ok launches more paid runs without checking the cap. Repeated API failures can exhaust the remaining benchmark and exceed the requested budget.
Learn more
The live driver asks OpenRouter for cumulative key usage before each paid run. A failed request currently counts as permission to proceed, so an unavailable or rate-limited usage endpoint removes the spend stop for every worker. worker continues submitting runs whenever Spend.ok returns true.
Example: With --stop-usd 3, the usage endpoint starts returning HTTP 429 after $2.90. Each worker catches the error and runs the remaining model calls, even after the key passes $3.
Recommended fix: Treat an unknown usage result as a stop condition, surface the lookup error to the operator, and ensure the final accounting failure does not hide the reason the run stopped.
Was this helpful? React with 👍 or 👎 to provide feedback.
| with ThreadPoolExecutor(args.parallel) as ex: | ||
| futs = [ex.submit(worker, J.JOBS.index(j), j, args, spend, out) for j in sel] | ||
| for f in futs: | ||
| try: | ||
| f.result() | ||
| except Exception as exc: | ||
| print("worker failed:", redact(repr(exc))[:800], file=sys.stderr) | ||
| spent = spend.spent() | ||
| meta = {"model": args.model, | ||
| "hermes": subprocess.run([HERMES, "--version"], capture_output=True, text=True).stdout.splitlines()[0], | ||
| "openrouter_key_usage_delta_usd": round(spent, 4), "stopped_on_budget": STOP.is_set(), | ||
| "wall_seconds": round(time.time() - t0), "args": {k: v for k, v in vars(args).items() if k not in ("out", "done")}} | ||
| with open(out.with_suffix(".meta.json"), "w") as f: | ||
| json.dump(meta, f, indent=2) | ||
| print(json.dumps(meta, indent=2)) | ||
| return 0 |
There was a problem hiding this comment.
🟡 Partial runs publish benchmark results
When the budget stops an arm early, main succeeds and bench-live replays and scores its partial trace. The printed results then omit unfinished runs without marking the comparison incomplete.
Learn more
The spend check inside worker returns as soon as the configured stop is reached, leaving some arms unfinished. A successful driver exit then lets the bench-live target invoke replay, scoring, and the headline printer. Neither of those commands checks whether every requested job and arm finished.
Example: Run make bench-live BENCH_STOP_USD=0.01. After the first few jobs the stop flag ends the workers, but the target continues and presents totals based only on the runs recorded so far.
Recommended fix: Persist the partial trace for resumption, but exit nonzero or skip the scoring and headline stages when any requested arm is incomplete; explicitly label incomplete outputs if partial results are supported.
Was this helpful? React with 👍 or 👎 to provide feedback.
| want = {a: (args.observe if a == "mandate" else 0) + args.clean + args.attacks * args.templates for a in args.arms} | ||
| done, keep, drop = set(), [], [] | ||
| if out.exists(): | ||
| old = [json.loads(x) for x in out.read_text().splitlines() if x.strip()] | ||
| cnt = {} | ||
| for r in old: | ||
| cnt[(r["job"], r["arm"], r["model"])] = cnt.get((r["job"], r["arm"], r["model"]), 0) + 1 | ||
| done = {k for k, n in cnt.items() if n >= want.get(k[1], 10 ** 9)} | ||
| for r in old: | ||
| (keep if (r["job"], r["arm"], r["model"]) in done else drop).append(r) |
There was a problem hiding this comment.
🟡 Changed run settings reuse incompatible arms
When a later run requests fewer samples, done treats any longer prior arm as complete. The new benchmark silently uses the old sample mix instead of the requested settings.
Learn more
A live trace can contain data from an earlier invocation using the same model but different --clean, --attacks, --templates, or --observe settings. Resume compares only the number of records in an arm with the new requested number, not the expected phase, category, wrapper, and run number. worker then skips every arm in done.
Example: First run the default five clean samples per arm, then request --clean 2 with the same model and trace path. An arm with five clean samples already exceeds want, so no new arm runs and scoring retains all five.
Recommended fix: Persist and compare the sampling configuration and expected per-arm run identities before retaining an arm, or require a fresh trace path for incompatible configurations.
Was this helpful? React with 👍 or 👎 to provide feedback.
| if os.environ.get("BENCH_SANDBOX", "1") == "0" or not shutil.which("bwrap"): | ||
| return [] |
There was a problem hiding this comment.
…blocked (#13) * Cut false blocks without widening reach: distinct write paths, read-back, tool families, read-only flag variance, mkdir of report dirs, propose prompt-path warning Replay on the recorded gpt-4o-mini traces: attack calls blocked 140/140 (unchanged), legit calls blocked 58/1038 -> 39/1038. Tests 111 -> 152. * bench README: live spot check of the fixed code (12 clean enforce runs, 0 blocks, $0.015) --------- Co-authored-by: JoeProAI <176786290+JoeProAI@users.noreply.github.com>
Adds
bench/, a judge-reproducible benchmark of Mandate on real Hermes cron with a real model. Not for merge until Joe says yes.Headline: on real Hermes v0.23.0 cron with gpt-4o-mini, Mandate blocked 29 of 29 injected attack calls the model made. 0 of 120 attack runs caused harm, against 18 of 120 with Hermes defaults alone. 9 of 263 legit calls were falsely blocked in clean runs.
cron_mode: deny, Hermes Guard @6b8a32db, agent-security-guard @b1b923e6).pre_tool_callonly) 0/140 and 0.make benchis free and needs no key. All 10 policies rebuilt identical, all 1043 decisions matched the live run, andpre_tool_callmeasured p50 about 1.3 ms and p95 about 2.9 ms.hermes plugins validate .still passes with a "caution" verdict, from files that were already there. Tests: 111 passed, 1 skipped.