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 substitution is judged per turn against what that turn asked for (#105)

github-actions[bot]a538962ef941
diff --git a/gateway/app.py b/gateway/app.py
index d5f36234..9d927e09 100644
--- a/gateway/app.py
+++ b/gateway/app.py
@@ -7297,6 +7297,9 @@ async def _session_turns_data(sid: str, limit: int = 0) -> dict:
"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"),
+ # the model the turn asked for (a served model other than it on the SAME turn is a
+ # substitution; a switch turn asks for another model on purpose)
+ "model": rec.get("model") or None,
# 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_turns_feed_model.py b/gateway/tests/test_turns_feed_model.py
new file mode 100644
index 00000000..87581992
--- /dev/null
+++ b/gateway/tests/test_turns_feed_model.py
@@ -0,0 +1,14 @@
+"""The turns feed names, per turn, the model the turn asked for (2026-09-06): the support matrix judges a
+served-model substitution on the same turn, since a switch turn asks for another model on purpose."""
+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_feed_carries_the_requested_model_per_turn():
+ src = Path(gw.__file__).read_text()
+ body = src[src.index("async def _session_turns_data"):][:8000]
+ assert '"model": rec.get("model") or None' in body
+ assert '"connection": rec.get("connection")' in body
diff --git a/scripts/support-matrix/run.mjs b/scripts/support-matrix/run.mjs
index e10aef97..785de673 100644
--- a/scripts/support-matrix/run.mjs
+++ b/scripts/support-matrix/run.mjs
@@ -155,7 +155,13 @@ try {
// the model each turn record says the CLI actually ran (gemini-cli reports it; it rewrites some
// requested ids): a served model other than the pair's id is a substitution, a finding of its own
rec.served = [...new Set(turnsList.map((t) => t && t.served_model).filter(Boolean).map(String))];
- rec.substituted = rec.served.filter((sm) => sm.split(',').some((x) => x && x !== m));
+ // judged per turn against what THAT turn asked for: the switch scenario runs a partner model on
+ // purpose, and its served name is not a substitution of this pair's id. A feed without the
+ // per-turn model (older gateways) falls back to the pair's id never being served at all.
+ const withModel = turnsList.filter((t) => t && t.served_model && t.model);
+ rec.substituted = withModel.length
+ ? [...new Set(withModel.filter((t) => t.model === m && String(t.served_model).split(',').some((x) => x && x !== m)).map((t) => String(t.served_model)))]
+ : (rec.served.length && !rec.served.some((sm) => sm.split(',').includes(m)) ? rec.served : []);
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);
}