HarnessRouter Community Edition: the self-hosted, Apache-2.0 edition of the unified interface for agent harnesses. Run Codex, Claude Code, Hermes, PI, DSH, and more through one API, with sessions, streaming, files, cancellation, and failure handling. Implements the Unified Harness Protocol (UHP), an open standard. Your keys, your infrastructure.
Python agent-apiagent-frameworkagent-harnessai-agentsai-infrastructurecoding-agentconformance-testingdeepseek-harnessharness-engineeringhermesllmopen-protocolopen-sourceopen-standardpi-coding-agentself-hosteduhpunified-apiunified-harness-protocolunified-interface
runner: a Gemini signature's maker is also known by the signature itself, for a call replayed under an id of the harness's own (#606)
github-actions[bot]70ac31e21946
diff --git a/runner/server.py b/runner/server.pyindex c5a4ec05..d1f4cc27 100644--- a/runner/server.py+++ b/runner/server.py@@ -4969,28 +4969,42 @@ _GOOGLE_HOST = "generativelanguage.googleapis.com"# turn, so this is kept beside the routes. A signature whose maker this process never saw (a runner# restarted since) is kept as the harness sent it, and if Google calls it corrupted the call goes once more# with the sentinel in its place. The hosted broker keeps the same record per session.+# The maker is also kept under a digest of the signature itself (never the signature), so a harness that replays a+# call under an id of its own while keeping Google's signature on it is still known by what it carries: by id+# alone no maker would be found and another model's signature would go on. None measured does this today (vibe+# 3.0.2 keeps the provider's ids and carries no signature, 2026-10-27); the hosted broker keeps the same record._SIG_MAKERS: dict[str, str] = {}_SIG_MAKERS_MAX = 50_000_SIG_MAKERS_LOCK = threading.Lock()_GOOGLE_SIG_CORRUPT_RE = re.compile(rb"Corrupted thought signature", re.I)-def _sig_makers_keep(ids, model: str) -> None:- """Note `model` as the maker of each tool call id (the oldest notes go past _SIG_MAKERS_MAX)."""+def _sig_key(sig: str) -> str:+ """The record's key for a signature's own maker: a digest, never the signature."""+ return "sig:" + hashlib.sha256(str(sig).encode()).hexdigest()[:32]+++def _sig_makers_keep(ids, model: str, sigs=()) -> None:+ """Note `model` as the maker of each tool call id and of each signature (the oldest notes go past+ _SIG_MAKERS_MAX)."""if not model:returnwith _SIG_MAKERS_LOCK:- for cid in ids:- if cid:- _SIG_MAKERS.pop(str(cid), None)- _SIG_MAKERS[str(cid)] = model+ for key in [str(c) for c in ids if c] + [_sig_key(s) for s in sigs if s]:+ _SIG_MAKERS.pop(key, None)+ _SIG_MAKERS[key] = modelwhile len(_SIG_MAKERS) > _SIG_MAKERS_MAX:del _SIG_MAKERS[next(iter(_SIG_MAKERS))]-def _sig_by_another(cid: str, want: str) -> bool:+def _sig_maker(cid: str, carried: str = "") -> str:+ """Who made the call `cid` (or, under an id this process never saw, the signature it carries), or ""."""+ return (_SIG_MAKERS.get(cid, "") if cid else "") or (_SIG_MAKERS.get(_sig_key(carried), "") if carried else "")+++def _sig_by_another(cid: str, want: str, carried: str = "") -> bool:"""Whether the call `cid` was made by a model other than `want`, as far as this process saw."""- maker = _SIG_MAKERS.get(cid, "") if cid else ""+ maker = _sig_maker(cid, carried)return bool(maker and want) and not _same_model(want, maker)@@ -5292,9 +5306,11 @@ def _google_with_signatures(body: bytes, sigs: dict, distrust: bool = False, filif not isinstance(tc, dict):continuecid = str(tc.get("id") or "")- own = not _sig_by_another(cid, want) and not (distrust and cid not in _SIG_MAKERS)ec = tc.get("extra_content")carried = isinstance(ec, dict) and isinstance(ec.get("google"), dict) and ec["google"].get("thought_signature")+ known = bool(_sig_maker(cid, carried if isinstance(carried, str) else ""))+ own = (not _sig_by_another(cid, want, carried if isinstance(carried, str) else "")+ and not (distrust and not known))if (carried and own) or (not carried and not fill):continuesig = (sigs.get(cid) if own else "") or _GOOGLE_SIG_SKIP@@ -6491,7 +6507,7 @@ class _HermesRelayHandler(http.server.BaseHTTPRequestHandler):for cid, sig in _google_signatures_in_line(line):sigs[cid] = sigflags["thought_signature"] = True- _sig_makers_keep([cid], str(_body_model))+ _sig_makers_keep([cid], str(_body_model), [sig])if out_lines is not None:chunk = b"".join(out_lines)_stream_fold(flags, call_usage, call_thinking, folded) # on the route before the client has it@@ -6575,7 +6591,7 @@ class _HermesRelayHandler(http.server.BaseHTTPRequestHandler):sigs.update(found)if found:flags["thought_signature"] = True- _sig_makers_keep([cid for cid, _ in found], str(_body_model))+ _sig_makers_keep([cid for cid, _ in found], str(_body_model), [s for _, s in found])self.send_header("content-length", str(len(data)))self.end_headers()self.wfile.write(data)diff --git a/runner/tests/test_relay_signature_maker.py b/runner/tests/test_relay_signature_maker.pyindex aa1b62f6..05ac281b 100644--- a/runner/tests/test_relay_signature_maker.py+++ b/runner/tests/test_relay_signature_maker.py@@ -156,3 +156,22 @@ def test_a_runner_that_never_saw_the_call_learns_from_the_refusal(google_like, mmakers.clear() # a runner started sinceassert turn({"model": "gemini-3.6-flash", "messages": [ASK, ARGON_CALL, RESULT]}) == 200assert len(got) == 2 and _sigs_of(got[0]) == ["sigArgon"] and _sigs_of(got[1]) == [SKIP]+++def test_a_call_replayed_under_the_harness_own_id_is_known_by_its_signature():+ """A harness that replays Google's calls under ids of its own and keeps the signatures on them: by id alone+ no maker is found, so the signature itself (its digest) says who made it, and argon's goes to+ gemini-3.6-flash as the sentinel."""+ server._sig_makers_keep(["call_1"], "gemini-4-argon", ["sigArgon"])+ server._sig_makers_keep(["call_2"], "gemini-3.6-flash", ["sigFlash"])+ body = json.dumps({"model": "gemini-3.6-flash", "messages": [{"role": "assistant", "content": None, "tool_calls": [+ {"id": "effect-0b9e", "type": "function", "function": {"name": "f", "arguments": "{}"},+ "extra_content": {"google": {"thought_signature": "sigArgon"}}},+ {"id": "effect-77aa", "type": "function", "function": {"name": "f", "arguments": "{}"},+ "extra_content": {"google": {"thought_signature": "sigFlash"}}},+ {"id": "effect-c0de", "type": "function", "function": {"name": "f", "arguments": "{}"},+ "extra_content": {"google": {"thought_signature": "unseen"}}}]}]}).encode()+ out = json.loads(server._google_with_signatures(body, {}))+ got = [tc["extra_content"]["google"]["thought_signature"] for tc in out["messages"][0]["tool_calls"]]+ assert got == [SKIP, "sigFlash", "unseen"] # argon's goes as the sentinel; its own and an unseen one stay+ assert not any("sigArgon" in k or "sigFlash" in k for k in server._SIG_MAKERS) # kept as digests, never the signature