A plugin that records real agent turns and replays them with every tool call answered from the recording.
Most teams ship an agent, then change one line (a model id, a system prompt, a temperature) and find out in production that it stopped doing the thing it used to do. There is no red build, because there is no build. The behaviour changed, and nothing was watching it.
hermes-regress is a Hermes Agent plugin that watches. It records the turns your agent actually runs, tool calls and tool outputs included, and later replays those same turns against a different model or config with every tool call served from the recording. Nothing on your machine gets executed twice. You get a verdict per case: pass, drift, regressed, error.
The gap this fills
There are three common ways to test an agent, and all three miss the specific failure that hurts:
- Unit tests cover your tools, not the model's decision to call them.
- Benchmarks (SWE-bench style) measure a model on someone else's tasks, not on your prompts, your tools, your failure modes.
- Hand-written evals are the right idea, but they are expensive to author, and they drift away from what production traffic looks like.
Meanwhile the cheapest possible test input already exists: the transcripts of what your agent did yesterday. Those turns contain the prompts, the exact tool arguments, and the exact outputs the model was reasoning over. If you can replay one of those turns and compare the new behaviour to the old one, you have a regression test that cost you nothing to write.
That is the whole idea. Capture passively, replay hermetically, compare honestly.
What a case is
A case is one finished turn, stored as plain JSON:
{
"schema": "hermes-regress/v1",
"case_id": "042ef5945fbce0c6",
"session_id": "20261110_190814_f48726ed",
"model": "deepseek-v41-flash-1017",
"prompt": "…the turn's user message…",
"tool_calls": [
{"tool": "terminal", "args": {"command": "npm run build"}, "result": "…"}
],
"answer": "…the assistant's final answer…",
"redactions": 47,
"tool_count": 68,
"expect": []
}
That example is a real capture from building this plugin: one Slack turn, 68 tool calls, 47 secrets scrubbed. Cases live under the active Hermes home in plugin-data/hermes-regress/cases/, one file per turn, mode 0600.
Architecture
The important line in that diagram is the one going from pre_tool_call back into the model loop. Replay does not stub your tools. It runs the real agent loop, real prompting, real tool schemas, and intercepts at the hook that fires immediately before a tool executes. The model sees the same world it saw during capture, and the process sees nothing.
Flat version, for terminals and plain Markdown:
capture: turn -> tool call -> real tool -> post_tool_call -> case.json (0600)
replay: case -> arm -> agent loop -> pre_llm_call (claim) -> pre_tool_call (block, serve recorded output) -> score
Capture
The plugin registers four capture hooks and two replay hooks:
def register(ctx) -> None:
ctx.register_hook("pre_llm_call", rg_replay.claim_session)
ctx.register_hook("pre_tool_call", rg_replay.serve)
ctx.register_hook("post_tool_call", rg_capture.on_post_tool_call)
ctx.register_hook("post_llm_call", rg_capture.on_post_llm_call)
ctx.register_hook("on_session_end", rg_capture.on_session_end)
ctx.register_command("regress", handler=rg_cli.handle, description="…")
Capture never changes a tool call or an answer. It only observes. The one place it does intervene is on the way to disk: everything written into a case is redacted first.
SECRET_PATTERNS = [
(re.compile(r"(?i)\b(password|passwd|pwd|secret|token|api[_-]?key|access[_-]?key)\b\s*[=:]\s*\S+"),
r"\1=[REDACTED]"),
(re.compile(r"\beyJ[A-Za-z0-9_-]{8,}\.[A-Za-z0-9_-]{8,}\.[A-Za-z0-9_-]{4,}\b"), "[REDACTED_JWT]"),
re.compile(r"\b(?:sk|pk|rk)-[A-Za-z0-9_\-]{16,}\b"),
re.compile(r"\bgh[pousr]_[A-Za-z0-9]{20,}\b"),
re.compile(r"\bxox[abprs]-[A-Za-z0-9\-]{10,}\b"),
re.compile(r"\bAKIA[0-9A-Z]{16}\b"),
re.compile(r"\b[A-Fa-f0-9]{40,}\b"),
]
def redact(text: str) -> tuple[str, int]:
hits = 0
for pattern in SECRET_PATTERNS:
if isinstance(pattern, tuple):
regex, replacement = pattern
text, n = regex.subn(replacement, text)
else:
text, n = pattern.subn("[REDACTED]", text)
hits += n
return text, hits
A case file is a security artifact, because it contains real prompts and real tool output. So writes go through one function that chmods the temp file before the atomic rename:
def write_private(path: Path, text: str) -> Path:
path.parent.mkdir(parents=True, exist_ok=True)
tmp = path.with_name(f"{path.name}.{os.getpid()}.tmp")
tmp.write_text(text, encoding="utf-8")
os.chmod(tmp, 0o600)
os.replace(tmp, path)
return path
And there is no home-directory guessing. regress_home() asks the same resolver the rest of Hermes uses, so a gateway running three profiles writes each profile's cases into that profile's home instead of one shared pile.
Replay
serve() is the whole safety story in about fifteen lines:
def serve(*, tool_name="", args=None, session_id="", task_id="", **_):
case = _load_fixtures()
if case is None or not _in_scope(case, session_id, task_id):
return {}
try:
return _serve(case, tool_name, args)
except Exception as exc: # fail closed: a bug here must not run the real tool
return {
"action": "block",
"message": f"[hermes-regress replay] fixture lookup failed; this tool call was not run.",
}
Three properties matter here.
Out of scope means silence, not a veto. If the session does not belong to this replay, the hook returns {} and the agent behaves normally. A plugin that blocked every tool call whenever any case was armed would freeze every other session on the machine, which is what my first version did.
Failing closed is mandatory. If fixture matching throws, the exception must not escape into a path where Hermes ignores the veto and runs the shell command. block with an apologetic message is the only safe return.
Matching is by tool name and arguments, in order. Each recorded call can be consumed once, and an exact argument match wins over a loose one:
def _score(recorded, tool_name, args) -> int:
if recorded.get("tool") != tool_name:
return 0
a, b = recorded.get("args") or {}, args or {}
if a == b:
return 3 # exact
if set(a) == set(b) and all(str(a[k])[:120] == str(b[k])[:120] for k in a):
return 2
if a.get("command") and a.get("command") == b.get("command"):
return 1
return 0
If the model calls a tool that never appeared in the capture, replay answers with a note saying exactly that and continues. You want to see the divergence in the transcript, not have the run crash on it.
The hard part: scoping
Replay has to run inside a real Hermes process, which means the plugin cannot hold the armed state in memory. The CLI that arms a case and the gateway that serves the hooks are different processes, and a subprocess environment variable does not reach a hook running inside a long-lived gateway. My first attempt used an env token and appeared to work in tests while never firing in the runtime that mattered.
The state is a file:
{"case_id": "042ef5945fbce0c6", "prompt": "…", "tool_calls": [...],
"claimed_session_id": "", "armed_until": 1762345678.0}
/regress run arms it with a TTL and spawns hermes chat -Q --oneshot --query-file prompt.txt. The next pre_llm_call sees a fresh session, compares the turn's message to the armed prompt, and if they match, claims the case for that session_id and task_id:
def claim_session(*, session_id="", user_message="", task_id="", is_first_turn=False, **_):
if not is_first_turn or not session_id:
return
with _armed_lock():
case = _read_armed()
if case is None or case.get("claimed_session_id"):
return
if not prompt_matches(case.get("prompt", ""), user_message):
return
case["claimed_session_id"] = session_id
case["claimed_task_id"] = task_id or ""
case["claimed_at"] = time.time()
if _write_armed(case, require_present=True) is None:
return
Every design choice in that function came from a review comment.
-
is_first_turnis required, because a later turn in an existing conversation can repeat the same text, and only the top of a fresh session is the replay the runner started. - The prompt comparison is exact, not fuzzy. A wrapper that rewrites the prompt turns the run into a claimed-nothing error, and an error is the correct outcome. Fuzzy matching would let a different task inherit a case's fixtures.
- The claim write happens under
fcntland only succeeds while the armed file still exists, so two runners cannot both claim the same case, and a disarm during the race wins. -
task_idis recorded as a secondary scope key, so the hook can still tell replay apart from background tasks inside the same session.
Never replay against a runtime that cannot intercept
Plugins load at process start. Edit a plugin, and the running gateway is still executing the old code. Replay against that gateway and the veto hook never runs, which means the tool calls execute for real. That is the failure mode the plugin exists to prevent, so it happened to the plugin itself during development.
preflight() is a 30 line probe that proves interception before any case runs. It arms a synthetic case, asks the runtime to run echo regress-probe, and checks two things: the session got claimed, and the tool call hit the fixture path.
ok = bool(hits) and bool(claimed)
if ok:
detail = "runtime claimed the probe session and served the recorded output"
elif hits:
detail = "the probe's tool call was served, but its session was never claimed, so scoping would not hold for a real case"
else:
detail = ("runtime did not intercept a tool call, so replay would execute real tools. "
"Restart Hermes (plugins load at startup) and run /regress run again")
Both conditions, because either one alone is a false positive. Hooks firing without a claim means scoping is broken. A claim without a served call means the veto is not in the path.
Honesty about what replay can and cannot prevent
If scoping is wrong and a tool runs for real, the plugin cannot take it back. The shell command already happened. What it can do is refuse to report that run as clean:
def live_execution_error(*, claimed_session, recorded_total, served, replay_calls) -> str:
"""This is a post-mortem, not a guard."""
if not claimed_session:
return ("the replay's own turn never claimed the armed case, so scoping never applied and "
f"its {recorded_total} recorded tool call(s) ran for real. This is detected after "
"the case, not prevented: check replay/hook.log and whether the runtime serving "
"turns loads plugins.")
if served < recorded_total:
return (f"only {served} of {recorded_total} recorded tool calls were answered from the "
f"recording; the other {recorded_total - served} ran for real. …")
replay/hook.log gets a line for every call the hooks saw while a case was armed. An empty log during a run is the fingerprint of a runtime that never loaded the plugin. That log is the difference between "replay is safe" as a claim and as an observation.
Verdicts
Comparison is deliberately boring: normalised answer similarity, tool plan similarity, and optional expectation rules.
def verdict_for(result, case, cfg) -> str:
if result.get("error"):
return "error"
failed = [c for c in result.get("expectations") or [] if not c["ok"]]
if failed:
return "regressed"
sim = result.get("answer_similarity") or answer_similarity(case.get("answer", ""), result.get("answer", ""))
plan = result["plan_similarity"]
if result.get("expectations"):
return "pass" if plan >= float(cfg.get("plan_threshold", 0.5)) else "drift"
if sim >= float(cfg.get("threshold", 0.55)) and plan >= float(cfg.get("plan_threshold", 0.5)):
return "pass"
if sim >= 0.35:
return "drift"
return "regressed"
Four verdicts, because "the answer changed" and "the agent stopped doing the work" are different problems:
-
pass: same tools in roughly the same order, answer within threshold. -
drift: it still works, but wording or step order moved. Worth reading, not worth failing a build over. -
regressed: the plan collapsed or an expected string vanished. This is the one that fails CI. -
error: the run itself did not complete, including the preflight refusals above.
Expectations are plain substring rules, which sounds weak until you use them. expect: ["no action needed"] on a turn that should conclude cleanly is a better regression test than any similarity score.
Evidence you can attach to a PR
/regress report writes Markdown with a table per case and a "What broke" section showing recorded answer, replayed answer, recorded tools, replayed tools side by side. /regress export adds JUnit XML for CI plus a ZIP whose manifest is hash chained, so a reviewer can tell whether the bundle was edited after the run:
def hash_chain(items) -> tuple[str, list[str]]:
prev = "0" * 64
links = []
for item in items:
blob = json.dumps(item, sort_keys=True, separators=(",", ":")).encode("utf-8")
prev = hashlib.sha256(prev.encode("ascii") + blob).hexdigest()
links.append(prev)
return prev, links
Headless mode is one command, with an exit code a pipeline can read:
python3 rg_cli.py run --model anthropic/claude-sonnet-4 --fail-on-regressed
# exit 0 all clear, 2 if any case regressed or errored
The suite has 32 tests, and they exercise the parts that broke during review: claim exclusivity, late claim rejection, scoping by session and task, preflight routing through the claim path, fail-closed serving, redaction, and the honest live-execution report.
What this does not do
Being specific about limits, because a testing tool that oversells itself is worse than none:
- It tests behaviour, not correctness. If the original answer was wrong, replay will happily pass the wrongness along.
- It only knows what it captured. A path your agent has never taken has no case.
- It is not a sandbox for a hostile plugin. It assumes the tools themselves are the thing you want to keep from running twice, not an adversary you are containing.
- Similarity thresholds are heuristics.
expectrules are the part you should trust.
Try it
hermes plugins install harishkotra/hermes-regress
hermes plugins enable hermes-regress
# restart Hermes: plugins load at startup
/regress status
/regress on
# …use your agent normally for a day…
/regress off
/regress list
/regress run --model <other-model>
/regress report
/regress selftest proves interception in the runtime you are actually talking to. Run it first. Every hour you spend debugging "why did nothing replay" is an hour that command would have saved.
Code & more: https://www.dailybuild.xyz/project/323-hermes-regress
Find it in the marketplace: https://hermes-agent.nousresearch.com/marketplace/hermes-regress

Top comments (2)
The loose fixture match deserves its own regression case. If two calls have the same argument keys and share the first 120 characters but differ in a later argument value, replay could return a plausible result for the wrong request. I'd mark that match as ambiguous and block it, while keeping an exact-match case to prove the normal path still works.
The limit is the part worth keeping. If the original answer was wrong, replay passes it anyway.