Skip to content

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.

A replayed Gemini 3 tool call carries its thought signature; Fable 5.1 and LLMTR's Gemini family (#96)

github-actions[bot]33de4a4518e3
diff --git a/gateway/app.py b/gateway/app.py
index 24ef958d..a13875c8 100644
--- a/gateway/app.py
+++ b/gateway/app.py
@@ -3012,6 +3012,126 @@ def _google_unknown_field(refused: bytes) -> str:
return m.group(1) if m else ""
+# ── Gemini 3 thought signatures ────────────────────────────────────────────────────────
+# Google's OpenAI-compatible endpoint streams a `thought_signature` on every function call it
+# makes (tool_calls[].extra_content.google.thought_signature) and, on Gemini 3, refuses the next
+# request unless the replayed assistant tool_calls carry it back: 400 "Function call is missing
+# a thought_signature in functionCall parts" (measured 2026-09-06 on the artifact turn of pi, dsh,
+# qwen and opencode, every Gemini 3.x id; hermes keeps the field, Gemini 2.5 does not require it,
+# and the aggregators carry it themselves). OpenAI-shaped clients drop extra_content when they
+# rebuild the assistant message, so the broker remembers each signature under its tool call id as
+# the answer streams past and puts it back on the replay. A call it never saw (a trace that began
+# elsewhere) gets Google's own sentinel, which skips the check instead of failing the turn. One
+# process serves this deployment, so the table is in-process; owner-trust traffic never comes
+# here, and the loopback relays in the runner keep their own.
+_GOOGLE_SIG_SKIP = "skip_thought_signature_validator"
+_GOOGLE_SIGS: dict[str, str] = {} # "<sid>:<tool call id>" -> signature
+_GOOGLE_SIGS_MAX = 20000
+
+
+def _google_signatures_in(doc: dict) -> list[tuple[str, str]]:
+ """The (tool call id, thought signature) pairs one answer (a chunk or a whole message) carries."""
+ found: list[tuple[str, str]] = []
+ for ch in doc.get("choices") or []:
+ if not isinstance(ch, dict):
+ continue
+ holder = ch.get("delta") if isinstance(ch.get("delta"), dict) else ch.get("message")
+ if not isinstance(holder, dict):
+ continue
+ for tc in holder.get("tool_calls") or []:
+ if not isinstance(tc, dict):
+ continue
+ ec = tc.get("extra_content")
+ sig = ((ec or {}).get("google") or {}).get("thought_signature") if isinstance(ec, dict) else None
+ cid = tc.get("id")
+ if isinstance(sig, str) and sig and isinstance(cid, str) and cid:
+ found.append((cid, sig))
+ return found
+
+
+def _google_remember(sid: str, pairs: list[tuple[str, str]]) -> None:
+ """Keep the signatures for the replay, under the session so one never serves another."""
+ for cid, sig in pairs:
+ if len(_GOOGLE_SIGS) >= _GOOGLE_SIGS_MAX:
+ _GOOGLE_SIGS.clear()
+ _GOOGLE_SIGS[f"{sid}:{cid}"] = sig
+
+
+def _google_with_signatures(body: bytes, sid: str) -> bytes:
+ """The request with every replayed assistant tool call carrying a thought signature: the one
+ the broker saw on the answer, else Google's sentinel. A body without tool calls is untouched."""
+ if b"tool_calls" not in body:
+ return body
+ try:
+ doc = json.loads(body)
+ except (ValueError, UnicodeDecodeError):
+ return body
+ if not isinstance(doc, dict) or not isinstance(doc.get("messages"), list):
+ return body
+ changed = False
+ for msg in doc["messages"]:
+ if not isinstance(msg, dict) or msg.get("role") != "assistant":
+ continue
+ for tc in msg.get("tool_calls") or []:
+ if not isinstance(tc, dict):
+ continue
+ ec = tc.get("extra_content")
+ if isinstance(ec, dict) and isinstance(ec.get("google"), dict) and ec["google"].get("thought_signature"):
+ continue
+ cid = str(tc.get("id") or "")
+ sig = _GOOGLE_SIGS.get(f"{sid}:{cid}", "") if cid else ""
+ tc["extra_content"] = {"google": {"thought_signature": sig or _GOOGLE_SIG_SKIP}}
+ changed = True
+ return json.dumps(doc).encode() if changed else body
+
+
+class _GoogleSigTap:
+ """Reads the thought signatures off a Google answer as it streams past: an SSE answer line by
+ line, a whole JSON answer once it has ended. The bytes go through untouched."""
+ LINE_MAX = 1 << 20 # a signature-bearing line is small; a longer one is content, skipped
+ BODY_MAX = 8 << 20
+
+ def __init__(self, content_type: str):
+ self.sse = "text/event-stream" in (content_type or "")
+ self.buf = b""
+ self.body = bytearray()
+ self.sigs: list[tuple[str, str]] = [] # seen and not yet remembered (drained by the pump)
+
+ def feed(self, chunk: bytes) -> None:
+ if self.sse:
+ self.buf += chunk
+ while b"\n" in self.buf:
+ line, self.buf = self.buf.split(b"\n", 1)
+ self._line(line.strip())
+ if len(self.buf) > self.LINE_MAX:
+ self.buf = b""
+ elif len(self.body) < self.BODY_MAX:
+ self.body += chunk
+
+ def _line(self, line: bytes) -> None:
+ if not line.startswith(b"data:") or b"thought_signature" not in line:
+ return
+ try:
+ doc = json.loads(line[5:].strip())
+ except ValueError:
+ return
+ if isinstance(doc, dict):
+ self.sigs += _google_signatures_in(doc)
+
+ def finish(self) -> None:
+ if self.sse:
+ if self.buf:
+ self._line(self.buf.strip())
+ self.buf = b""
+ elif b"thought_signature" in self.body:
+ try:
+ doc = json.loads(bytes(self.body))
+ except ValueError:
+ doc = None
+ if isinstance(doc, dict):
+ self.sigs += _google_signatures_in(doc)
+
+
def _without_field(body: bytes, field: str) -> bytes:
"""The JSON request without one top-level field; a body that is not a JSON object is returned as is."""
try:
@@ -3140,6 +3260,8 @@ async def llm_broker(path: str, request: Request):
headers["authorization"] = f"Bearer {key}"
body = _strip_unsupported(await request.body(), provider=provider, byok=True, path=suffix)
+ if provider == "google":
+ body = _google_with_signatures(body, sid)
rc = _relay_client()
req = rc.build_request(request.method, url, headers=headers, content=body or None)
up = await rc.send(req, stream=True)
@@ -3162,15 +3284,34 @@ async def llm_broker(path: str, request: Request):
break
refused = await up.aread()
if up.status_code == 400:
+ # The refusal reaches the harness, which shows it as "400 (no body)"; the cause is here.
+ print(f"[broker] google refused sid={sid} path={suffix!r}: "
+ f"{refused[:300].decode('utf-8', 'replace')!r}", flush=True)
+ # aread() hands back the DECODED body; passing Google's content-encoding header along with
+ # it made the harness fail on the error itself ("Response decompression failed", "Failed
+ # to process error response") instead of reading the refusal, 2026-09-06.
return Response(content=refused, status_code=400, media_type=up.headers.get("content-type"),
headers={k: val for k, val in up.headers.items()
- if k.lower() not in ("content-length", "transfer-encoding", "connection")})
+ if k.lower() not in ("content-length", "transfer-encoding", "connection",
+ "content-encoding")})
+ # A Google answer's tool calls carry the signatures the next request must replay.
+ tap = _GoogleSigTap(up.headers.get("content-type", "")) if (provider == "google" and up.status_code < 400) else None
async def pump():
try:
async for chunk in up.aiter_raw():
+ if tap is not None:
+ tap.feed(chunk)
+ if tap.sigs:
+ pairs, tap.sigs = tap.sigs, []
+ _google_remember(sid, pairs)
yield chunk
finally:
+ if tap is not None:
+ tap.finish() # a whole JSON answer is read at the end
+ if tap.sigs:
+ _google_remember(sid, tap.sigs)
+ tap.sigs = []
await up.aclose()
out = {k: val for k, val in up.headers.items()
@@ -4731,12 +4872,14 @@ _BEDROCK_CLAUDE = {
"sonnet-4.6": "us.anthropic.claude-sonnet-4-6", "sonnet-4.5": "us.anthropic.claude-sonnet-4-5",
"opus-5": "us.anthropic.claude-opus-5", "sonnet-5": "us.anthropic.claude-sonnet-5",
"haiku-4.5": "us.anthropic.claude-haiku-4-5-20251001-v1:0", "fable-5": "us.anthropic.claude-fable-5",
+ "fable-5.1": "us.anthropic.claude-fable-5-1",
}
_ANTHROPIC_CLAUDE = {
"opus-4.8": "claude-opus-4-8", "opus-4.7": "claude-opus-4-7", "opus-4.6": "claude-opus-4-6",
"opus-4.5": "claude-opus-4-5", "sonnet-4.6": "claude-sonnet-4-6", "sonnet-4.5": "claude-sonnet-4-5",
"opus-5": "claude-opus-5", "sonnet-5": "claude-sonnet-5",
"haiku-4.5": "claude-haiku-4-5-20251001", "fable-5": "claude-fable-5",
+ "fable-5.1": "claude-fable-5-1",
}
@@ -4757,6 +4900,7 @@ _VENDOR_MODELS: dict[str, dict[str, str]] = {
"anthropic": {
"claude-opus-5": "claude-opus-5",
"claude-fable-5": "claude-fable-5",
+ "claude-fable-5-1": "claude-fable-5-1",
"claude-opus-4.8": "claude-opus-4-8",
"claude-sonnet-5": "claude-sonnet-5",
"claude-opus-4.7": "claude-opus-4-7",
@@ -4766,6 +4910,7 @@ _VENDOR_MODELS: dict[str, dict[str, str]] = {
"bedrock": {
"claude-opus-5": "us.anthropic.claude-opus-5",
"claude-fable-5": "us.anthropic.claude-fable-5",
+ "claude-fable-5-1": "us.anthropic.claude-fable-5-1",
"claude-opus-4.8": "us.anthropic.claude-opus-4-8",
"claude-sonnet-5": "us.anthropic.claude-sonnet-5",
"claude-opus-4.7": "us.anthropic.claude-opus-4-7",
@@ -4803,6 +4948,7 @@ _VENDOR_MODELS: dict[str, dict[str, str]] = {
"gpt-5.3-codex": "openai/gpt-5.3-codex",
"claude-opus-5": "anthropic/claude-opus-5",
"claude-fable-5": "anthropic/claude-fable-5",
+ "claude-fable-5-1": "anthropic/claude-fable-5.1",
"claude-opus-4.8": "anthropic/claude-opus-4.8",
"claude-sonnet-5": "anthropic/claude-sonnet-5",
"claude-opus-4.7": "anthropic/claude-opus-4.7",
@@ -4907,12 +5053,23 @@ _VENDOR_MODELS: dict[str, dict[str, str]] = {
"gpt-5.3-codex": "openai/gpt-5.3-codex",
"claude-opus-5": "anthropic/claude-opus-5",
"claude-fable-5": "anthropic/claude-fable-5",
+ "claude-fable-5-1": "anthropic/claude-fable-5.1",
"claude-opus-4.8": "anthropic/claude-opus-4.8",
"claude-sonnet-5": "anthropic/claude-sonnet-5",
"claude-opus-4.7": "anthropic/claude-opus-4.7",
"claude-sonnet-4.6": "anthropic/claude-sonnet-4.6",
"claude-haiku-4.5": "anthropic/claude-haiku-4.5",
"gemini-3.6-flash": "google/gemini-3.6-flash",
+ "gemini-3.8-flash": "google/gemini-3.8-flash",
+ "gemini-3.7-flash": "google/gemini-3.7-flash",
+ "gemini-3.5-flash": "google/gemini-3.5-flash",
+ "gemini-3.5-flash-lite": "google/gemini-3.5-flash-lite",
+ "gemini-3.1-flash-lite": "google/gemini-3.1-flash-lite",
+ "gemini-3.1-pro-preview": "google/gemini-3.1-pro-preview",
+ "gemini-3-flash-preview": "google/gemini-3-flash-preview",
+ "gemini-2.5-pro": "google/gemini-2.5-pro",
+ "gemini-2.5-flash": "google/gemini-2.5-flash",
+ "gemini-2.5-flash-lite": "google/gemini-2.5-flash-lite",
"deepseek-v4-pro": "deepseek/deepseek-v4-pro",
"deepseek-v4-flash": "deepseek/deepseek-v4-flash",
"kimi-k3": "moonshot/kimi-k3",
@@ -5090,7 +5247,7 @@ _MODEL_CATALOG: dict[str, dict] = {
# Anthropic's models overview and AWS's own model card), so it routes directly instead of
# falling through to the unmapped default it used at launch.
"claude": {"default": "claude-sonnet-4.6",
- "models": ["claude-opus-5", "claude-fable-5", "claude-opus-4.8", "claude-sonnet-5",
+ "models": ["claude-opus-5", "claude-fable-5", "claude-fable-5-1", "claude-opus-4.8", "claude-sonnet-5",
"claude-opus-4.7", "claude-sonnet-4.6", "claude-haiku-4.5"]},
# hermes (NousResearch hermes-agent) is multi-family — it runs any frontier model through
# the matching provider connection (family-aware chain selection in _resp_execute). Friendly
@@ -5101,7 +5258,7 @@ _MODEL_CATALOG: dict[str, dict] = {
"models": ["gpt-5.6-sol", "gpt-5.6-terra", "gpt-5.6-luna", "gpt-5.5",
"gpt-5.4", "gpt-5.4-mini", "gpt-5.2",
"gpt-5.3-codex",
- "claude-opus-5", "claude-fable-5", "claude-opus-4.8", "claude-sonnet-5",
+ "claude-opus-5", "claude-fable-5", "claude-fable-5-1", "claude-opus-4.8", "claude-sonnet-5",
"claude-opus-4.7", "claude-sonnet-4.6", "claude-haiku-4.5",
# frontier US+China set, served via the TokenRouter/OpenRouter
# integrations (2026-07-22: each probe-verified through the hermes
@@ -5133,7 +5290,7 @@ _MODEL_CATALOG: dict[str, dict] = {
"models": ["deepseek-v4-pro", "deepseek-v4-flash",
"gpt-5.6-sol", "gpt-5.6-terra", "gpt-5.6-luna", "gpt-5.5",
"gpt-5.4", "gpt-5.4-mini", "gpt-5.2", "gpt-5.3-codex",
- "claude-opus-5", "claude-fable-5", "claude-opus-4.8", "claude-sonnet-5",
+ "claude-opus-5", "claude-fable-5", "claude-fable-5-1", "claude-opus-4.8", "claude-sonnet-5",
"claude-opus-4.7", "claude-sonnet-4.6", "claude-haiku-4.5",
"gemini-3.6-flash", "gemini-3.8-flash", "gemini-3.7-flash", "gemini-3.5-flash", "gemini-3.5-flash-lite", "gemini-3.1-flash-lite", "gemini-3.1-pro-preview", "gemini-3-flash-preview", "gemini-2.5-pro", "gemini-2.5-flash", "gemini-2.5-flash-lite", "kimi-k3", "glm-5.3", "glm-5.3-flash", "kimi-k2.7-code",
"qwen3.7-max", "qwen3.8-max",
@@ -5148,7 +5305,7 @@ _MODEL_CATALOG: dict[str, dict] = {
"opencode": {"default": "gpt-5.4",
"models": ["gpt-5.6-sol", "gpt-5.6-terra", "gpt-5.6-luna", "gpt-5.5",
"gpt-5.4", "gpt-5.4-mini", "gpt-5.2", "gpt-5.3-codex",
- "claude-opus-5", "claude-fable-5", "claude-opus-4.8", "claude-sonnet-5",
+ "claude-opus-5", "claude-fable-5", "claude-fable-5-1", "claude-opus-4.8", "claude-sonnet-5",
"claude-opus-4.7", "claude-sonnet-4.6", "claude-haiku-4.5",
"gemini-3.6-flash", "deepseek-v4-pro", "deepseek-v4-flash", "kimi-k3", "glm-5.3", "glm-5.3-flash",
"kimi-k2.7-code", "qwen3.7-max", "qwen3.8-max",
@@ -5166,7 +5323,7 @@ _MODEL_CATALOG: dict[str, dict] = {
"models": ["qwen3.7-max", "qwen3.8-max",
"gpt-5.6-sol", "gpt-5.6-terra", "gpt-5.6-luna", "gpt-5.5",
"gpt-5.4", "gpt-5.4-mini", "gpt-5.2",
- "claude-opus-5", "claude-fable-5", "claude-opus-4.8", "claude-sonnet-5",
+ "claude-opus-5", "claude-fable-5", "claude-fable-5-1", "claude-opus-4.8", "claude-sonnet-5",
"claude-opus-4.7", "claude-sonnet-4.6", "claude-haiku-4.5",
"gemini-3.6-flash", "gemini-3.8-flash", "gemini-3.7-flash", "gemini-3.5-flash", "gemini-3.5-flash-lite", "gemini-3.1-flash-lite", "gemini-3.1-pro-preview", "gemini-3-flash-preview", "gemini-2.5-pro", "gemini-2.5-flash", "gemini-2.5-flash-lite", "deepseek-v4-pro", "deepseek-v4-flash", "kimi-k3",
"kimi-k2.7-code", "mistral-medium-3.5", "step-3.7-flash", "glm-5.3", "glm-5.3-flash"]},
@@ -5187,7 +5344,7 @@ _MODEL_CATALOG: dict[str, dict] = {
"cline": {"default": "gpt-5.4",
"models": ["gpt-5.4", "gpt-5.6-sol", "gpt-5.6-terra", "gpt-5.6-luna",
"gpt-5.5", "gpt-5.4-mini", "gpt-5.2", "claude-opus-5",
- "claude-fable-5", "claude-opus-4.8", "claude-sonnet-5", "claude-opus-4.7",
+ "claude-fable-5", "claude-fable-5-1", "claude-opus-4.8", "claude-sonnet-5", "claude-opus-4.7",
"claude-sonnet-4.6", "claude-haiku-4.5", "deepseek-v4-pro", "deepseek-v4-flash",
"kimi-k3", "kimi-k2.7-code", "qwen3.7-max", "qwen3.8-max",
"mistral-medium-3.5", "step-3.7-flash", "glm-5.3", "glm-5.3-flash",
@@ -5196,7 +5353,7 @@ _MODEL_CATALOG: dict[str, dict] = {
"pi": {"default": "gpt-5.4",
"models": ["gpt-5.6-sol", "gpt-5.6-terra", "gpt-5.6-luna", "gpt-5.5",
"gpt-5.4", "gpt-5.4-mini", "gpt-5.2", "gpt-5.3-codex",
- "claude-opus-5", "claude-fable-5", "claude-opus-4.8", "claude-sonnet-5",
+ "claude-opus-5", "claude-fable-5", "claude-fable-5-1", "claude-opus-4.8", "claude-sonnet-5",
"claude-opus-4.7", "claude-sonnet-4.6", "claude-haiku-4.5",
"gemini-3.6-flash", "gemini-3.8-flash", "gemini-3.7-flash", "gemini-3.5-flash", "gemini-3.5-flash-lite", "gemini-3.1-flash-lite", "gemini-3.1-pro-preview", "gemini-3-flash-preview", "gemini-2.5-pro", "gemini-2.5-flash", "gemini-2.5-flash-lite", "deepseek-v4-pro", "deepseek-v4-flash", "kimi-k3",
"kimi-k2.7-code", "qwen3.7-max", "qwen3.8-max",
@@ -7012,6 +7169,8 @@ async def _session_turns_data(sid: str, limit: int = 0) -> dict:
asst, tools, files = _output_to_turn_fields(rec.get("output") or [])
turns.append({"id": rid, "status": rec.get("status"), "user": user_text,
"user_files": user_files, "assistant": asst, "tools": tools, "files": files,
+ # the connection that served the turn, as the record stamps it
+ "connection": rec.get("connection"),
# WHY an incomplete turn is incomplete ("max_steps" | "timeout" |
# "interrupted"), so the console can say what actually happened instead of
# one banner for every cause. Absent on records from before the field.
diff --git a/gateway/tests/test_google_provider.py b/gateway/tests/test_google_provider.py
index 21c33c15..4019446c 100644
--- a/gateway/tests/test_google_provider.py
+++ b/gateway/tests/test_google_provider.py
@@ -29,3 +29,82 @@ def test_google_is_listed_and_brokered_with_its_endpoint():
assert "google" in gw._BROKERABLE_PROVIDERS
conn = gw._with_provider_base({"provider": "google", "api_key": "k"})
assert conn["base_url"] == "https://generativelanguage.googleapis.com/v1beta/openai"
+
+
+# ── Gemini 3 thought signatures (2026-09-06) ──────────────────────────────────────────────
+import json
+
+
+def _delta(cid, sig=None):
+ tc = {"id": cid, "type": "function", "function": {"name": "write_file", "arguments": "{}"}}
+ if sig:
+ tc["extra_content"] = {"google": {"thought_signature": sig}}
+ return {"object": "chat.completion.chunk", "choices": [{"delta": {"tool_calls": [tc]}}]}
+
+
+def test_signatures_are_read_off_a_chunk_and_a_whole_message():
+ assert gw._google_signatures_in(_delta("call_1", "sigA")) == [("call_1", "sigA")]
+ assert gw._google_signatures_in(_delta("call_1")) == []
+ whole = {"object": "chat.completion", "choices": [{"message": {"tool_calls": [
+ {"id": "call_2", "type": "function", "function": {"name": "f", "arguments": "{}"},
+ "extra_content": {"google": {"thought_signature": "sigB"}}}]}}]}
+ assert gw._google_signatures_in(whole) == [("call_2", "sigB")]
+
+
+def test_the_tap_collects_signatures_as_the_stream_passes_and_off_a_whole_answer():
+ tap = gw._GoogleSigTap("text/event-stream")
+ line = b"data: " + json.dumps(_delta("call_9", "sigZ")).encode() + b"\n"
+ tap.feed(line[:20]); tap.feed(line[20:]) # a signature split across two chunks
+ assert tap.sigs == [("call_9", "sigZ")]
+ tap.feed(b"data: [DONE]\n"); tap.finish()
+ assert tap.sigs == [("call_9", "sigZ")]
+ whole = gw._GoogleSigTap("application/json")
+ body = json.dumps({"object": "chat.completion", "choices": [{"message": {"tool_calls": [
+ {"id": "call_3", "type": "function", "function": {"name": "f", "arguments": "{}"},
+ "extra_content": {"google": {"thought_signature": "sigC"}}}]}}]}).encode()
+ whole.feed(body[:15]); whole.feed(body[15:])
+ assert whole.sigs == [] # a JSON answer is read once it has ended
+ whole.finish()
+ assert whole.sigs == [("call_3", "sigC")]
+
+
+def test_the_replay_carries_the_seen_signature_or_the_sentinel():
+ gw._GOOGLE_SIGS.clear()
+ gw._google_remember("sidA", [("call_1", "sigA")])
+ body = json.dumps({"model": "gemini-3.6-flash", "messages": [
+ {"role": "user", "content": "hi"},
+ {"role": "assistant", "content": None, "tool_calls": [
+ {"id": "call_1", "type": "function", "function": {"name": "f", "arguments": "{}"}},
+ {"id": "call_x", "type": "function", "function": {"name": "f", "arguments": "{}"}},
+ {"id": "call_k", "type": "function", "function": {"name": "f", "arguments": "{}"},
+ "extra_content": {"google": {"thought_signature": "kept"}}}]},
+ {"role": "tool", "tool_call_id": "call_1", "content": "ok"}]}).encode()
+ out = json.loads(gw._google_with_signatures(body, "sidA"))
+ calls = out["messages"][1]["tool_calls"]
+ assert calls[0]["extra_content"] == {"google": {"thought_signature": "sigA"}}
+ assert calls[1]["extra_content"] == {"google": {"thought_signature": gw._GOOGLE_SIG_SKIP}}
+ assert calls[2]["extra_content"] == {"google": {"thought_signature": "kept"}}
+ assert out["messages"][2] == {"role": "tool", "tool_call_id": "call_1", "content": "ok"}
+ # a signature seen under one session never serves another
+ other = json.loads(gw._google_with_signatures(body, "sidB"))
+ assert other["messages"][1]["tool_calls"][0]["extra_content"]["google"]["thought_signature"] == gw._GOOGLE_SIG_SKIP
+ untouched = b'{"model": "gemini-3.6-flash", "messages": [{"role": "user", "content": "hi"}]}'
+ assert gw._google_with_signatures(untouched, "sidA") is untouched
+
+
+def test_the_table_is_bounded():
+ gw._GOOGLE_SIGS.clear()
+ gw._google_remember("s", [(f"c{i}", "x") for i in range(gw._GOOGLE_SIGS_MAX)])
+ gw._google_remember("s", [("one-more", "y")])
+ assert gw._GOOGLE_SIGS == {"s:one-more": "y"}
+
+
+def test_llmtr_and_the_aggregators_carry_fable_5_1_and_llmtr_the_gemini_family():
+ assert gw._VENDOR_MODELS["anthropic"]["claude-fable-5-1"] == "claude-fable-5-1"
+ assert gw._VENDOR_MODELS["bedrock"]["claude-fable-5-1"] == "us.anthropic.claude-fable-5-1"
+ for agg in ("tokenrouter", "openrouter", "vercel", "llmtr"):
+ assert gw._VENDOR_MODELS[agg]["claude-fable-5-1"] == "anthropic/claude-fable-5.1", agg
+ assert {m for m in gw._VENDOR_MODELS["llmtr"] if m.startswith("gemini")} == set(gw._VENDOR_MODELS["google"])
+ for h, c in gw._MODEL_CATALOG.items():
+ if "claude-fable-5" in c["models"]:
+ assert "claude-fable-5-1" in c["models"], h
diff --git a/runner/dsh_driver.py b/runner/dsh_driver.py
index 156173f9..b8cba72d 100644
--- a/runner/dsh_driver.py
+++ b/runner/dsh_driver.py
@@ -60,6 +60,13 @@ _strip_reasoning_effort = False
_GOOGLE_UNKNOWN_RE = re.compile(r'Unknown name \\?"([A-Za-z_][A-Za-z0-9_]*)\\?"(?! at \')')
_drop_fields: list = [] # the top-level fields this upstream refused as unknown, dropped from then on
+# Gemini 3 requires each replayed tool call's thought signature (400 "Function call is missing a
+# thought_signature in functionCall parts", measured 2026-09-06); the relay reads them off the answer
+# as it streams past and puts them back on the replay, Google's sentinel for a call it never saw.
+_GOOGLE_SIG_SKIP = "skip_thought_signature_validator"
+_GOOGLE_HOST = "generativelanguage.googleapis.com"
+_google_sigs: dict = {} # tool call id -> thought signature, this session's relay
+_google_required = False # a 400 naming thought_signature from an endpoint not recognised as Google
def _google_unknown_field(refused: bytes) -> str:
@@ -84,6 +91,64 @@ def _drop_top_level_fields(body: bytes, fields) -> bytes:
return json.dumps(obj).encode()
+def _google_signatures_in(doc: dict) -> list:
+ """The (tool call id, thought signature) pairs one answer (a chunk or a whole message) carries."""
+ found = []
+ for ch in doc.get("choices") or []:
+ if not isinstance(ch, dict):
+ continue
+ holder = ch.get("delta") if isinstance(ch.get("delta"), dict) else ch.get("message")
+ if not isinstance(holder, dict):
+ continue
+ for tc in holder.get("tool_calls") or []:
+ if not isinstance(tc, dict):
+ continue
+ ec = tc.get("extra_content")
+ sig = ((ec or {}).get("google") or {}).get("thought_signature") if isinstance(ec, dict) else None
+ cid = tc.get("id")
+ if isinstance(sig, str) and sig and isinstance(cid, str) and cid:
+ found.append((cid, sig))
+ return found
+
+
+def _google_signatures_in_line(line: bytes) -> list:
+ """The signatures one SSE line carries; a line without one costs a substring check."""
+ if not line.startswith(b"data:") or b"thought_signature" not in line:
+ return []
+ try:
+ doc = json.loads(line[5:].strip())
+ except ValueError:
+ return []
+ return _google_signatures_in(doc) if isinstance(doc, dict) else []
+
+
+def _google_with_signatures(body: bytes, sigs: dict) -> bytes:
+ """The request with every replayed assistant tool call carrying a thought signature: the one
+ this relay saw on the answer, else Google's sentinel. A body without tool calls is untouched."""
+ if b"tool_calls" not in body:
+ return body
+ try:
+ doc = json.loads(body)
+ except (ValueError, UnicodeDecodeError):
+ return body
+ if not isinstance(doc, dict) or not isinstance(doc.get("messages"), list):
+ return body
+ changed = False
+ for msg in doc["messages"]:
+ if not isinstance(msg, dict) or msg.get("role") != "assistant":
+ continue
+ for tc in msg.get("tool_calls") or []:
+ if not isinstance(tc, dict):
+ continue
+ ec = tc.get("extra_content")
+ if isinstance(ec, dict) and isinstance(ec.get("google"), dict) and ec["google"].get("thought_signature"):
+ continue
+ cid = str(tc.get("id") or "")
+ tc["extra_content"] = {"google": {"thought_signature": sigs.get(cid) or _GOOGLE_SIG_SKIP}}
+ changed = True
+ return json.dumps(doc).encode() if changed else body
+
+
def _drop_reasoning_effort(body: bytes) -> bytes:
try:
obj = json.loads(body)
@@ -99,7 +164,7 @@ class _Relay(http.server.BaseHTTPRequestHandler):
protocol_version = "HTTP/1.1"
def do_POST(self): # noqa: N802
- global _strip_reasoning_effort
+ global _strip_reasoning_effort, _google_required
body = self.rfile.read(int(self.headers.get("content-length") or 0))
# The adapters' base URLs point at this relay and they append their own API paths
# (/v1/chat/completions, /v1/responses, /v1/messages); the upstream base ends in /v1 —
@@ -116,6 +181,9 @@ class _Relay(http.server.BaseHTTPRequestHandler):
body = _drop_reasoning_effort(body)
if _drop_fields:
body = _drop_top_level_fields(body, _drop_fields)
+ google = _GOOGLE_HOST in UPSTREAM_BASE or _google_required
+ if google and tail.endswith("/chat/completions"):
+ body = _google_with_signatures(body, _google_sigs)
resp = None
for attempt in (0, 1, 2):
req = urllib.request.Request(UPSTREAM_BASE.rstrip("/") + tail,
@@ -130,6 +198,15 @@ class _Relay(http.server.BaseHTTPRequestHandler):
_strip_reasoning_effort = True
body = stripped
continue
+ if google and e.code == 400:
+ # the harness shows this as "400 (no body)"; the refusal is here
+ print(f"[dsh relay] google refused {tail}: {data[:300]!r}", flush=True)
+ if attempt < 2 and e.code == 400 and b"thought_signature" in data and not _google_required:
+ # a Gemini 3 endpoint this relay did not recognise as Google names the need itself
+ _google_required = True
+ google = True
+ body = _google_with_signatures(body, _google_sigs)
+ continue
unknown = _google_unknown_field(data) if e.code == 400 else ""
if attempt < 2 and unknown and unknown not in _drop_fields:
# Google's OpenAI-compatible endpoint refuses any field it does not know (dsh
@@ -162,6 +239,9 @@ class _Relay(http.server.BaseHTTPRequestHandler):
buf += chunk
while b"\n" in buf:
line, buf = buf.split(b"\n", 1)
+ if google:
+ for cid, sig in _google_signatures_in_line(line.strip()):
+ _google_sigs[cid] = sig
out = (_rewrite_sse_line(line.rstrip(b"\r")) if rewrite else line.rstrip(b"\r")) + b"\n"
self.wfile.write(f"{len(out):x}\r\n".encode() + out + b"\r\n")
self.wfile.flush()
@@ -171,6 +251,13 @@ class _Relay(http.server.BaseHTTPRequestHandler):
self.wfile.write(b"0\r\n\r\n")
else:
data = resp.read()
+ if google and b"thought_signature" in data:
+ try:
+ doc = json.loads(data)
+ except ValueError:
+ doc = None
+ if isinstance(doc, dict):
+ _google_sigs.update(_google_signatures_in(doc))
self.send_header("content-length", str(len(data)))
self.end_headers()
self.wfile.write(data)
diff --git a/runner/server.py b/runner/server.py
index 76123e54..4bb90aa5 100644
--- a/runner/server.py
+++ b/runner/server.py
@@ -2248,6 +2248,77 @@ def _google_unknown_field(refused: bytes) -> str:
return m.group(1) if m else ""
+# Gemini 3 requires each replayed tool call's thought signature: Google's OpenAI-compatible endpoint
+# streams it on every function call (tool_calls[].extra_content.google.thought_signature) and refuses
+# the next request without it, 400 "Function call is missing a thought_signature in functionCall
+# parts" (measured 2026-09-06 on the artifact turn of pi, dsh, qwen and opencode). OpenAI-shaped
+# clients drop extra_content when they rebuild the assistant message; in owner trust this relay is
+# the only thing between the harness and the provider, so it remembers each signature under its
+# tool call id as the answer streams past and puts it back on the replay. A call it never saw gets
+# Google's sentinel, which skips the check instead of failing the turn. The broker does the same
+# for brokered traffic.
+_GOOGLE_SIG_SKIP = "skip_thought_signature_validator"
+_GOOGLE_HOST = "generativelanguage.googleapis.com"
+
+
+def _google_signatures_in(doc: dict) -> list[tuple[str, str]]:
+ """The (tool call id, thought signature) pairs one answer (a chunk or a whole message) carries."""
+ found: list[tuple[str, str]] = []
+ for ch in doc.get("choices") or []:
+ if not isinstance(ch, dict):
+ continue
+ holder = ch.get("delta") if isinstance(ch.get("delta"), dict) else ch.get("message")
+ if not isinstance(holder, dict):
+ continue
+ for tc in holder.get("tool_calls") or []:
+ if not isinstance(tc, dict):
+ continue
+ ec = tc.get("extra_content")
+ sig = ((ec or {}).get("google") or {}).get("thought_signature") if isinstance(ec, dict) else None
+ cid = tc.get("id")
+ if isinstance(sig, str) and sig and isinstance(cid, str) and cid:
+ found.append((cid, sig))
+ return found
+
+
+def _google_signatures_in_line(line: bytes) -> list[tuple[str, str]]:
+ """The signatures one SSE line carries; a line without one costs a substring check."""
+ if not line.startswith(b"data:") or b"thought_signature" not in line:
+ return []
+ try:
+ doc = json.loads(line[5:].strip())
+ except ValueError:
+ return []
+ return _google_signatures_in(doc) if isinstance(doc, dict) else []
+
+
+def _google_with_signatures(body: bytes, sigs: dict) -> bytes:
+ """The request with every replayed assistant tool call carrying a thought signature: the one
+ this relay saw on the answer, else Google's sentinel. A body without tool calls is untouched."""
+ if b"tool_calls" not in body:
+ return body
+ try:
+ doc = json.loads(body)
+ except (ValueError, UnicodeDecodeError):
+ return body
+ if not isinstance(doc, dict) or not isinstance(doc.get("messages"), list):
+ return body
+ changed = False
+ for msg in doc["messages"]:
+ if not isinstance(msg, dict) or msg.get("role") != "assistant":
+ continue
+ for tc in msg.get("tool_calls") or []:
+ if not isinstance(tc, dict):
+ continue
+ ec = tc.get("extra_content")
+ if isinstance(ec, dict) and isinstance(ec.get("google"), dict) and ec["google"].get("thought_signature"):
+ continue
+ cid = str(tc.get("id") or "")
+ tc["extra_content"] = {"google": {"thought_signature": sigs.get(cid) or _GOOGLE_SIG_SKIP}}
+ changed = True
+ return json.dumps(doc).encode() if changed else body
+
+
def _drop_top_level_field(body: bytes, field: str) -> bytes:
"""The JSON request without one top-level field; anything else is returned as it came."""
try:
@@ -2308,6 +2379,10 @@ class _HermesRelayHandler(http.server.BaseHTTPRequestHandler):
for field in flags.get("drop_fields", ()):
body = _drop_top_level_field(body, field)
headers["content-length"] = str(len(body))
+ google = _GOOGLE_HOST in base or bool(flags.get("thought_signature"))
+ if google and body is not None and self.path.endswith("/chat/completions"):
+ body = _google_with_signatures(body, flags.setdefault("google_sigs", {}))
+ headers["content-length"] = str(len(body))
resp = None
tried_slim = False
for attempt in (0, 1, 2):
@@ -2344,6 +2419,17 @@ class _HermesRelayHandler(http.server.BaseHTTPRequestHandler):
body = effort
headers["content-length"] = str(len(body))
continue
+ if google and e.code == 400:
+ # the harness shows this as "400 (no body)"; the refusal is here
+ print(f"[relay] google refused {tail} model={_body_model}: {data[:300]!r}", flush=True)
+ if (attempt < 2 and e.code == 400 and b"thought_signature" in data
+ and not flags.get("thought_signature") and body is not None):
+ # a Gemini 3 endpoint this relay did not recognise as Google names the need itself
+ flags["thought_signature"] = True
+ google = True
+ body = _google_with_signatures(body, flags.setdefault("google_sigs", {}))
+ headers["content-length"] = str(len(body))
+ continue
unknown = _google_unknown_field(data) if e.code == 400 else ""
dropped = _drop_top_level_field(body, unknown) if (unknown and body is not None) else None
if attempt < 2 and dropped is not None and dropped != body:
@@ -2374,18 +2460,34 @@ class _HermesRelayHandler(http.server.BaseHTTPRequestHandler):
ctype = resp.headers.get("content-type") or ""
self.send_response(resp.status)
self.send_header("content-type", ctype)
- if "text/event-stream" in ctype: # responses stream through untouched — the fix is request-side
+ # the bytes go through untouched; a Google answer's tool-call signatures are read as they pass
+ sigs = flags.setdefault("google_sigs", {}) if google else None
+ if "text/event-stream" in ctype:
self.send_header("transfer-encoding", "chunked")
self.end_headers()
+ pending = b""
while True:
chunk = resp.read(4096)
if not chunk:
break
+ if sigs is not None:
+ pending += chunk
+ while b"\n" in pending:
+ line, pending = pending.split(b"\n", 1)
+ for cid, sig in _google_signatures_in_line(line.strip()):
+ sigs[cid] = sig
self.wfile.write(f"{len(chunk):x}\r\n".encode() + chunk + b"\r\n")
self.wfile.flush()
self.wfile.write(b"0\r\n\r\n")
else:
data = resp.read()
+ if sigs is not None and b"thought_signature" in data:
+ try:
+ doc = json.loads(data)
+ except ValueError:
+ doc = None
+ if isinstance(doc, dict):
+ sigs.update(_google_signatures_in(doc))
self.send_header("content-length", str(len(data)))
self.end_headers()
self.wfile.write(data)
diff --git a/runner/tests/test_dsh_driver_thought_signature.py b/runner/tests/test_dsh_driver_thought_signature.py
new file mode 100644
index 00000000..168c1b23
--- /dev/null
+++ b/runner/tests/test_dsh_driver_thought_signature.py
@@ -0,0 +1,24 @@
+"""Gemini 3 thought signatures through the dsh relay (2026-09-06)."""
+import json
+import sys
+from pathlib import Path
+
+sys.path.insert(0, str(Path(__file__).resolve().parents[1]))
+import dsh_driver # noqa: E402
+
+
+def test_dsh_relay_reads_signatures_and_replays_them_or_the_sentinel():
+ tc = {"id": "call_7", "type": "function", "function": {"name": "f", "arguments": "{}"},
+ "extra_content": {"google": {"thought_signature": "sig7"}}}
+ line = b"data: " + json.dumps({"choices": [{"delta": {"tool_calls": [tc]}}]}).encode()
+ assert dsh_driver._google_signatures_in_line(line) == [("call_7", "sig7")]
+ assert dsh_driver._google_signatures_in_line(b"data: [DONE]") == []
+ body = json.dumps({"messages": [{"role": "assistant", "content": None, "tool_calls": [
+ {"id": "call_7", "type": "function", "function": {"name": "f", "arguments": "{}"}},
+ {"id": "call_new", "type": "function", "function": {"name": "f", "arguments": "{}"}}]}]}).encode()
+ out = json.loads(dsh_driver._google_with_signatures(body, {"call_7": "sig7"}))
+ calls = out["messages"][0]["tool_calls"]
+ assert calls[0]["extra_content"]["google"]["thought_signature"] == "sig7"
+ assert calls[1]["extra_content"]["google"]["thought_signature"] == dsh_driver._GOOGLE_SIG_SKIP
+ plain = b'{"messages": [{"role": "user", "content": "hi"}]}'
+ assert dsh_driver._google_with_signatures(plain, {}) is plain
diff --git a/runner/tests/test_relay_thought_signature.py b/runner/tests/test_relay_thought_signature.py
new file mode 100644
index 00000000..752434d6
--- /dev/null
+++ b/runner/tests/test_relay_thought_signature.py
@@ -0,0 +1,51 @@
+"""Gemini 3 thought signatures through the loopback relay (2026-09-06)."""
+import json
+import sys
+from pathlib import Path
+
+sys.path.insert(0, str(Path(__file__).resolve().parents[1]))
+import server # noqa: E402
+
+
+def _delta(cid, sig=None):
+ tc = {"id": cid, "type": "function", "function": {"name": "write_file", "arguments": "{}"}}
+ if sig:
+ tc["extra_content"] = {"google": {"thought_signature": sig}}
+ return {"object": "chat.completion.chunk", "choices": [{"delta": {"tool_calls": [tc]}}]}
+
+
+def _replay():
+ return json.dumps({"model": "gemini-3.6-flash", "messages": [
+ {"role": "user", "content": "hi"},
+ {"role": "assistant", "content": None, "tool_calls": [
+ {"id": "call_1", "type": "function", "function": {"name": "f", "arguments": "{}"}},
+ {"id": "call_x", "type": "function", "function": {"name": "f", "arguments": "{}"}},
+ {"id": "call_k", "type": "function", "function": {"name": "f", "arguments": "{}"},
+ "extra_content": {"google": {"thought_signature": "kept"}}}]},
+ {"role": "tool", "tool_call_id": "call_1", "content": "ok"}]}).encode()
+
+
+def test_signatures_are_read_off_a_chunk_a_whole_message_and_an_sse_line():
+ assert server._google_signatures_in(_delta("call_1", "sigA")) == [("call_1", "sigA")]
+ assert server._google_signatures_in(_delta("call_1")) == []
+ whole = {"object": "chat.completion", "choices": [{"message": {"tool_calls": [
+ {"id": "call_2", "type": "function", "function": {"name": "f", "arguments": "{}"},
+ "extra_content": {"google": {"thought_signature": "sigB"}}}]}}]}
+ assert server._google_signatures_in(whole) == [("call_2", "sigB")]
+ line = b"data: " + json.dumps(_delta("call_9", "sigZ")).encode()
+ assert server._google_signatures_in_line(line) == [("call_9", "sigZ")]
+ assert server._google_signatures_in_line(b"data: [DONE]") == []
+ assert server._google_signatures_in_line(b'data: {"choices": [{"delta": {"content": "thought_signature"}}]}') == []
+
+
+def test_the_replay_carries_the_seen_signature_or_the_sentinel():
+ sigs = {"call_1": "sigA"}
+ out = json.loads(server._google_with_signatures(_replay(), sigs))
+ calls = out["messages"][1]["tool_calls"]
+ assert calls[0]["extra_content"] == {"google": {"thought_signature": "sigA"}}
+ assert calls[1]["extra_content"] == {"google": {"thought_signature": server._GOOGLE_SIG_SKIP}}
+ assert calls[2]["extra_content"] == {"google": {"thought_signature": "kept"}}
+ assert out["messages"][2] == {"role": "tool", "tool_call_id": "call_1", "content": "ok"}
+ untouched = b'{"model": "gemini-3.6-flash", "messages": [{"role": "user", "content": "hi"}]}'
+ assert server._google_with_signatures(untouched, sigs) is untouched
+ assert server._google_with_signatures(b"not json tool_calls", sigs) == b"not json tool_calls"
diff --git a/scripts/support-matrix/render.py b/scripts/support-matrix/render.py
index c63f252a..7e388eec 100644
--- a/scripts/support-matrix/render.py
+++ b/scripts/support-matrix/render.py
@@ -6,7 +6,8 @@ by = collections.defaultdict(list)
for k, r in res.items(): by[r['provider']].append(r)
out = ["# Harness support matrix", "", "The run's notes, per column, are in [support-matrix-notes.md](support-matrix-notes.md).", "", "Scenarios: first turn, follow-up in the same session, switch model mid-session, artifact (a file the task must produce), recycle (the sandbox is let go on purpose, then a follow-up must recall the first message). pass = ran and answered as asked, FAIL = failed (reason in the notes), n/a = not run.", ""]
for prov, rows in sorted(by.items()):
- out += [f"## Provider: {prov}", "", "| Harness | Model | First | Follow-up | Switch | Artifact | Recycle | Notes |", "|---|---|---|---|---|---|---|---|"]
+ out += [f"## Provider: {prov}", "", "| Harness | Model | First | Follow-up | Switch | Artifact | Recycle | Served by | Notes |", "|---|---|---|---|---|---|---|---|---|"]
+ findings = []
for r in sorted(rows, key=lambda r: (r['harness'], r['model'])):
notes = []
for sc in ('first', 'followup', 'switch', 'artifact', 'recycle'):
@@ -17,8 +18,16 @@ for prov, rows in sorted(by.items()):
ft = r.get('first_try') or {}
if ft: notes.append('retested once; first try: ' + '; '.join(f"{sc} {(ft.get(sc) or {}).get('why', '')[:80]}" for sc in ('first', 'followup', 'switch', 'artifact', 'recycle') if (ft.get(sc) or {}).get('ok') is False))
sw = r.get('switch') or {}
- out.append(f"| {r['harness']} | {r['model']} | {mark(r.get('first'))} | {mark(r.get('followup'))} | {mark(sw)}{(' ('+sw['to']+')') if sw.get('to') else ''} | {mark(r.get('artifact'))} | {mark(r.get('recycle'))} | {' ; '.join(notes).replace('|', '/')} |")
- ok = sum(1 for r in rows for sc in ('first','followup','switch','artifact','recycle') if (r.get(sc) or {}).get('ok') is True)
- tot = sum(1 for r in rows for sc in ('first','followup','switch','artifact','recycle') if (r.get(sc) or {}).get('ok') is not None)
- out += ["", f"{len(rows)} pairs, {ok} of {tot} scenario runs passed.", ""]
+ served = ', '.join(c.replace('integration:', '') for c in (r.get('connections') or ([r['connection']] if r.get('connection') else []))) or '?'
+ if r.get('foreign'):
+ # a turn served by a connection other than the one under test is a finding, never a pass
+ findings.append(f"{r['harness']} x {r['model']}: served by {', '.join(r['foreign'])} (turn records: {', '.join(r.get('connections') or [])})")
+ notes.insert(0, "served by another connection (finding below)")
+ out.append(f"| {r['harness']} | {r['model']} | {mark(r.get('first'))} | {mark(r.get('followup'))} | {mark(sw)}{(' ('+sw['to']+')') if sw.get('to') else ''} | {mark(r.get('artifact'))} | {mark(r.get('recycle'))} | {served} | {' ; '.join(notes).replace('|', '/')} |")
+ clean = [r for r in rows if not r.get('foreign')]
+ ok = sum(1 for r in clean for sc in ('first','followup','switch','artifact','recycle') if (r.get(sc) or {}).get('ok') is True)
+ tot = sum(1 for r in clean for sc in ('first','followup','switch','artifact','recycle') if (r.get(sc) or {}).get('ok') is not None)
+ out += ["", f"{len(rows)} pairs, {ok} of {tot} scenario runs passed" + (f"; {len(rows) - len(clean)} pairs served by another connection are findings, not counted." if len(clean) < len(rows) else "."), ""]
+ if findings:
+ out += ["Findings, pairs served by a connection other than the one under test:", ""] + [f"- {f}" for f in findings] + [""]
print("\n".join(out))
diff --git a/scripts/support-matrix/run.mjs b/scripts/support-matrix/run.mjs
index 7e9131a3..7e74acdd 100644
--- a/scripts/support-matrix/run.mjs
+++ b/scripts/support-matrix/run.mjs
@@ -115,8 +115,10 @@ try {
log(`FOLLOWUP ${k} ${rec.followup.ok ? 'ok' : 'FAIL'} ${rec.followup.s}s ${rec.followup.why}`);
// the partner must be one Codex can carry on with: gpt-5.3-codex and the gpt-5.6 line refuse each
// other's threads by design (#73), and that rule is not what the switch row measures
- const conflicts = (a, c) => (a === 'gpt-5.3-codex' && c.startsWith('gpt-5.6')) || (c === 'gpt-5.3-codex' && a.startsWith('gpt-5.6'));
- const other = runnableAll.find((x) => x !== m && !conflicts(m, x)) || runnableAll.find((x) => x !== m) || null;
+ // Codex refuses gpt-5.3-codex after any other model (measured after gpt-5.5 and after the gpt-5.6
+ // line), so a switch away and back can only fail by design: that row is n/a, not a measurement
+ const conflicts = (a, c) => a === 'gpt-5.3-codex' || c === 'gpt-5.3-codex';
+ const other = runnableAll.find((x) => x !== m && !conflicts(m, x)) || null;
if (other) { await page.click('.ar2-chip'); await sleep(500); await page.locator('.wbx-model-opt', { hasText: other }).first().click(); await sleep(300); rec.switch = { to: other, ...expectWord(await turn(`Reply with exactly: M3-${other}`), `M3-${other}`) }; }
else rec.switch = { to: null, ok: null, why: 'only one model' };
log(`SWITCH ${k} -> ${other} ${rec.switch.ok ? 'ok' : rec.switch.ok === null ? 'n/a' : 'FAIL'} ${rec.switch.s || ''}s ${rec.switch.why || ''}`);
@@ -145,9 +147,15 @@ try {
if (rec.sid) {
const d = await page.evaluate(async (sid) => { const r = await fetch(`/api/harness/v1/sessions/${sid}`); return r.ok ? await r.json() : null; }, rec.sid).catch(() => null);
if (d && d.last_connection) rec.connection = String(d.last_connection);
+ // every turn record's own stamp, so a pair served by more than one connection is visible: when
+ // EXPECT_CONNECTION names the connection under test, any other one is a finding of its own
+ const ts = await page.evaluate(async (sid) => { const r = await fetch(`/api/harness/v1/sessions/${sid}/turns`); return r.ok ? await r.json() : null; }, rec.sid).catch(() => null);
+ const turnsList = Array.isArray(ts) ? ts : (ts && Array.isArray(ts.turns) ? ts.turns : []);
+ rec.connections = [...new Set(turnsList.map((t) => t && t.connection).filter(Boolean).map(String))];
+ if (process.env.EXPECT_CONNECTION) rec.foreign = rec.connections.filter((c) => c !== process.env.EXPECT_CONNECTION);
rec.deleted = await page.evaluate(async (sid) => { const r = await fetch(`/api/harness/v1/sessions/${sid}`, { method: 'DELETE' }); return r.status; }, rec.sid).catch(() => 0);
}
- const all = load(); all[k] = rec; save(all); log(`PAIR_DONE ${k} connection=${rec.connection || '?'} deleted=${rec.deleted || '?'}`);
+ const all = load(); all[k] = rec; save(all); log(`PAIR_DONE ${k} connection=${rec.connection || '?'} turns=${(rec.connections || []).join('+') || '?'}${(rec.foreign || []).length ? ' FOREIGN=' + rec.foreign.join('+') : ''} deleted=${rec.deleted || '?'}`);
}
}
} catch (e) { log(`FATAL ${String(e).slice(0, 300)}`); }