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.

The turn's browser closes before the trace is finalized (#307)

github-actions[bot]dbef09328936
diff --git a/gateway/app.py b/gateway/app.py
index 5096d37b..6b10a4ff 100644
--- a/gateway/app.py
+++ b/gateway/app.py
@@ -2617,6 +2617,12 @@ async def _adopt_orphan_turn(sid: str, org: str, v: dict) -> bool:
_emit(oev)
except Exception: # noqa: BLE001
pass
+ # The turn's browser closes BEFORE the trace is finalized: its stop row (the vendor's stop
+ # takes seconds) must be in the trace, and the first read of a finished trace caches the
+ # chunks present at that moment for every later read. Closed from persist() it landed after
+ # the manifest said terminal, so the row reached the audit and never the trace (hosted, every
+ # base of the browser column, 2026-09-27). persist() still closes a turn that never got here.
+ await _browser_close(sid, "turn_end")
await _checkpoint(sid, rec)
await _trace_finalize(sid, rec)
# Persist the response record with the FULL turn output — NOT translator.output, which only
diff --git a/scripts/support-matrix/plugs/browser.py b/scripts/support-matrix/plugs/browser.py
index d2bc21f8..09dfe4be 100644
--- a/scripts/support-matrix/plugs/browser.py
+++ b/scripts/support-matrix/plugs/browser.py
@@ -100,16 +100,22 @@ def run_base(call, base: str, model: str, keep: bool, log) -> dict:
text = "".join(p.get("text") or "" for it in (d.get("output") or []) for p in (it.get("content") or [])
if p.get("type") in ("output_text", "text")) if isinstance(d, dict) else ""
out["answer"] = text[-400:]
- time.sleep(6) # the stop row lands after the turn settles
- code, trace = call("GET", f"/v1/traces/{sid}/all?compact=0", timeout=120)
+ # The stop row is in the trace once the browser has been stopped, which the gateway does
+ # before it finalizes the trace; read until it is there, up to a bound.
rows = []
- for line in (trace if isinstance(trace, str) else "").splitlines():
- try:
- ev = json.loads(line)
- except ValueError:
- continue
- if ev.get("type") == "plug" and ev.get("plug") == "browser":
- rows.append({k: ev.get(k) for k in ("tool", "outcome", "ms", "unit", "usd", "error")})
+ for _ in range(18):
+ code, trace = call("GET", f"/v1/traces/{sid}/all?compact=0", timeout=120)
+ rows = []
+ for line in (trace if isinstance(trace, str) else "").splitlines():
+ try:
+ ev = json.loads(line)
+ except ValueError:
+ continue
+ if ev.get("type") == "plug" and ev.get("plug") == "browser":
+ rows.append({k: ev.get(k) for k in ("tool", "outcome", "ms", "unit", "usd", "error")})
+ if any(r["tool"] == "session" for r in rows):
+ break
+ time.sleep(5)
ok_tools = [r["tool"] for r in rows if r.get("outcome") == "ok"]
stop = next((r for r in rows if r["tool"] == "session"), None)
out["tools"] = sorted(set(t for t in ok_tools if t != "session"))