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 record names the connection that served it (#103)

github-actions[bot]9373f35addbe
diff --git a/gateway/app.py b/gateway/app.py
index b8ea4424..7d4c5111 100644
--- a/gateway/app.py
+++ b/gateway/app.py
@@ -4731,6 +4731,10 @@ class _RespTranslator:
self.requested_model = ""
self.model_fallback = False
self.fallback_reason = ""
+ # The connection that served this turn, stamped when the sandbox is dispatched. The session's
+ # last_connection carried it before, one value per session; the turns feed and the support
+ # matrix read it per turn (a report that said "every turn record" was reading the session).
+ self.connection = ""
self.seq = 0
self.out_index = -1
self.output: list[dict] = []
@@ -4764,6 +4768,7 @@ class _RespTranslator:
if status == "incomplete" and self.incomplete_reason else None),
"previous_response_id": self.prev, "model": self.model,
"output": self.output, "store": self.store, "usage": self.usage,
+ "connection": self.connection,
"metadata": meta}
def start(self) -> list[dict]:
@@ -6127,6 +6132,10 @@ async def _resp_execute(translator: _RespTranslator, *, org: str, member: str, s
await control_store.resp_put_running(org, translator.resp_id, sid, rt or "", int(_GW_MAX_TURN_S))
except Exception: # noqa: BLE001
pass
+ # The turn names its connection, not only the session: on the executor's record (the trace
+ # manifest reads it) and on the translator (the stored response and the turns feed read it).
+ rec["connection"] = name
+ translator.connection = name
if sid in _cancel_req:
try:
await _sandbox_json(f"/turn/{rt}/cancel", sid, "POST", attempts=2)
diff --git a/gateway/tests/test_turn_record_connection.py b/gateway/tests/test_turn_record_connection.py
new file mode 100644
index 00000000..9be67cff
--- /dev/null
+++ b/gateway/tests/test_turn_record_connection.py
@@ -0,0 +1,15 @@
+"""The turn record names the connection that served it (2026-09-06): the session's last_connection
+carried it once per session, and the turns feed exposed a key the record did not have."""
+import sys
+from pathlib import Path
+
+sys.path.insert(0, str(Path(__file__).resolve().parents[1]))
+import app as gw # noqa: E402
+
+
+def test_the_record_carries_the_connection_stamped_at_dispatch():
+ tr = gw._RespTranslator("resp_1", "gemini-3.5-flash", None, True, 0.0)
+ assert tr.connection == ""
+ tr.connection = "integration:Google AI Studio"
+ rec = tr._response_obj("completed")
+ assert rec["connection"] == "integration:Google AI Studio"