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
codex: an aggregator's connection rides the relay, so the free-form repair reaches it (#398)
github-actions[bot]7ae2aa467f54
diff --git a/docs/support-matrix-notes.md b/docs/support-matrix-notes.mdindex 5fcf26f0..492afab4 100644--- a/docs/support-matrix-notes.md+++ b/docs/support-matrix-notes.md@@ -2486,3 +2486,102 @@ minimax x llama-3.3-70b's first artifact turn (it passed on the retest); a displwith a kept session. The withheld-tool claim of custom-harness is still judged on a tool the fixturenever asks for (review of #362), so it cannot fail; the env-stamp oracle described under the minimaxand kilo sections is the judge to move it to.++## A list of free-form objects reached the tool empty (2026-10-05, 0.29.3 and 0.29.4)++Reported from the hosted service: an agent asked a tool to insert rows and the tool received+`[{}, {}]` or `[]`. The rows were in the model's plan and gone from its tool call.++**The mechanism.** One tool whose argument is a list of objects, the model asked to pass two+specific rows, one call per cell, the item's schema written four ways:++| `items` | what the tool received |+|---|---|+| `{"type":"object"}` | the rows, in every cell |+| `{"type":"object","properties":{}}` | `[{}, {}]` from OpenAI models through Vercel and through OpenRouter; `[]` from kimi-k3 through Vercel and through TokenRouter |+| `{"type":"object","properties":{},"additionalProperties":true}` | `[{}, {}]` from OpenAI models through OpenRouter; the rows elsewhere |+| `{"type":"object","additionalProperties":true}` | the rows, in every cell |++The cells were eleven model families on Vercel and on TokenRouter, OpenAI models on OpenRouter, and+OpenAI, Azure and Google AI Studio directly. A tool's author writes the first row. hermes, opencode,+kilo and goose add the empty `properties` to every object node themselves, and Codex does for an MCP+tool. With the key present a route may hand the model an object it can put nothing in; without it+none did.++**The repair (0.29.3, #394).** The relay drops an empty `properties` from every nested object node of+a function tool's schema, for every model, and leaves the root `parameters` node as it is. A function+tool sits in four places, and the repair walks all of them: `tools[].function.parameters` (Chat+Completions), `tools[].parameters` (the Responses API), the `tools` of a `{"type":"namespace"}` entry+(Codex groups a server's MCP tools that way), and the `tools` of an item in `input` (a tool search's+answer). The first candidate covered the first place alone and left gpt-5.4 on Vercel at 14 of 17:+with an OpenAI model on an aggregator, hermes (`codex_responses`), opencode and kilo+(`@ai-sdk/openai`) speak the Responses API. hermes on an OpenRouter connection also called+OpenRouter directly, with the connection's key in its environment; it takes a relay route now, like+hermes's other connections.++**The judge.** The plugin matrix has a `rows` column (`plugins/run-matrix.py --mode rows`): the+fixture's second tool answers `PLUGIN_ROWS_OK` only when both rows arrive with their fields and says+what it received otherwise. The tool is the judge; an agent's own record of its call is not (one base+writes arguments through a file, and an answer can be cut short).++**Measured**, every base that lists the model, through hr-test's side container:++| model, connection | 0.29.2 | candidates of 0.29.3 |+|---|---|---|+| gpt-5.4, Vercel | 14 of 17: hermes, opencode, kilo | 17 of 17 |+| gpt-5.4, OpenRouter | 16 of 17: hermes | 17 of 17 |+| kimi-k3, TokenRouter | 14 of 16: hermes, goose | 15 of 16 |++The remaining miss is aider with kimi-k3 answering with the model's reasoning and calling nothing,+about one turn in three, before and after (#395). On the last candidate: the plugin matrix's five+columns on six bases at their default models, 30 of 30, and hermes on OpenRouter through the console,+four models by five scenarios, 20 of 20.++**Codex (0.29.4).** 0.29.3 did not reach Codex: it was handed the connection's base and key and never+passed through the relay. Codex 0.154.0 with gpt-6-luna, two runs per connection: the rows on+TokenRouter, OpenRouter, OpenAI and Azure; `[{}]` and `[{}, {}]` on Vercel, and the same there with+gpt-6.1-sol. gpt-5.4, gpt-5.4-mini, gpt-5.5, gpt-5.6-sol and gpt-6-astra passed on Vercel. For+gpt-5.4 the hosted service captured why: Codex sends `{"type":"tool_search"}` and no MCP schema in+the first request, so there is no empty `properties` to act on. That the other four pass for the+same reason is inferred, not captured. Now every Codex+connection that is not OpenAI's own or Azure's takes a relay route. The route keeps the connection's+base exactly as stored, since Codex called `<base>/responses` whatever the base looked like; the CLI+gets a loopback URL and a placeholder, so the connection's key is out of its environment; and the+account fingerprint that decides whether a resumed history is replayed as content is still taken from+the connection, because a route is new on every turn.++With the route, Codex on Vercel: gpt-6-luna three of three, gpt-6.1-sol two of two, gpt-6-sol one of+one, and on the built candidate gpt-6-luna twice and gpt-6.1-sol once.++**Codex's columns with the route** (the branch's runner in a side container, through the console, one+worker):++| connection | models | scenarios passed | what did not |+|---|---|---|---|+| Vercel | 12 | 58 of 59 | gpt-5.6-luna's recall after a recycle |+| TokenRouter | 12 | 57 of 59 | gpt-5.4's switch into gpt-6.1-sol; one artifact turn on gpt-5.4 |+| OpenRouter | 3 | 15 of 15 | |+| a custom Responses endpoint | 2 | 8 of 8 | |+| OpenAI direct (route unchanged) | 2 | 10 of 10 | |+| Azure (route unchanged) | 2 | 10 of 10 | |++gpt-5.3-codex has no switch partner on Vercel or TokenRouter, nor has either model on the custom+endpoint, so those rows count four scenarios. Each miss was run again with and without the route:++- gpt-5.4's switch into gpt-6.1-sol on TokenRouter is refused with "cannot continue this task's+ earlier reasoning through this provider" three of three with the route and two of two without it,+ in the same time (132 to 173 s against 135 and 151 s). It is the condition recorded on 2026-09-10+ for that route: its upstream accounts cannot open each other's encrypted reasoning. The relay+ logged the provider's 400 once per turn.+- The artifact turn on gpt-5.4 that produced no file passed two of two on the retest with the route,+ and two of two without it.+- gpt-5.6-luna's recall after a recycle answered the completion phrase three of three with the route+ and two of three without it: the luna tier's recall recorded under the gpt-6 line.++Also with the route: the family tour (one conversation, 1 of 1), the plugin matrix's five columns,+the custom harness and the browser column, all on codex. On the built candidate (0.29.4-rc.1): three+models on Vercel 15 of 15, two on TokenRouter 10 of 10, two on the custom endpoint 8 of 8, the plugin+columns 5 of 5.++**Not measured.** A Codex turn whose provider stays silent past the relay's wait: the relay ends such a+call with its reason, as for every other base, and Codex was not driven into that case here.diff --git a/runner/server.py b/runner/server.pyindex cd0b0b53..6ce591e7 100644--- a/runner/server.py+++ b/runner/server.py@@ -2233,6 +2233,18 @@ def _codex_prepare_env(provider: str, auth: Auth, model: str, cwd: str,marker.write_text(fp)except OSError:pass+ # A connection that is not OpenAI's own or Azure's rides the relay, as it does for every other+ # base. Codex groups a server's MCP tools in a namespace and adds an empty `properties` to each+ # object node of their schemas; through Vercel the tool then received empty objects with+ # gpt-6-luna and gpt-6.1-sol (two of two, 2026-10-05; not with gpt-5.4, whose tool definitions+ # Codex defers behind a tool search), and the repair lives in the relay+ # (_with_free_form_objects). The CLI is given a loopback URL and a placeholder, so the+ # connection's key is no longer in its environment either. OpenAI's own endpoint and Azure's+ # keep the direct route: both were intact as Codex sends it. The account fingerprint above is+ # taken from the connection itself, never from the route, which is new on every turn.+ cli_base, cli_key = base_url, auth.api_key+ if p == "tokenrouter" and auth.api_key:+ cli_base, cli_key = _hermes_relay_route(base_url, auth.api_key, exact_base=True)# codex only speaks the OpenAI Responses API now — current releases removed# `wire_api = "chat"` entirely, so a custom chat-completions endpoint cannot be driven by# codex at all (the gateway greys codex out for those integrations). Always the supported@@ -2240,7 +2252,7 @@ def _codex_prepare_env(provider: str, auth: Auth, model: str, cwd: str,# crash on config load.cfg = _CODEX_CONFIG_TMPL.format(model=model, provider=f"hr-{p}", effort=CODEX_REASONING_EFFORT, ctx=CODEX_CONTEXT_WINDOW,- name=spec["name"], base_url=base_url, env_key=spec["env_key"],+ name=spec["name"], base_url=cli_base, env_key=spec["env_key"],wire_api=auth.wire_api or "responses")if _codex_namespace_tools_off(auth):# Codex enables its multi-agent namespace by default. Most custom Responses endpoints@@ -2263,7 +2275,7 @@ def _codex_prepare_env(provider: str, auth: Auth, model: str, cwd: str,for alias in _codex_session_provider_ids(cfg_dir):if alias == f"hr-{p}" or alias == "openai": # the current one; a reserved built-incontinue- cfg += _CODEX_ALIAS_TMPL.format(alias=alias, name=spec["name"], base_url=base_url,+ cfg += _CODEX_ALIAS_TMPL.format(alias=alias, name=spec["name"], base_url=cli_base,env_key=spec["env_key"], wire_api=auth.wire_api or "responses")if mcp_toml: # owner-attached MCP servers via Codex's experimental rmcp HTTP clientcfg += mcp_toml@@ -2271,8 +2283,8 @@ def _codex_prepare_env(provider: str, auth: Auth, model: str, cwd: str,env["CODEX_HOME"] = str(cfg_dir)env["TMPDIR"] = str(pathlib.Path(cwd) / "tmp")pathlib.Path(env["TMPDIR"]).mkdir(parents=True, exist_ok=True)- if auth.api_key:- env[spec["env_key"]] = auth.api_key+ if cli_key:+ env[spec["env_key"]] = cli_keyreturn cfg_dir@@ -4796,7 +4808,7 @@ def _gemini_relay_route(host_root: str, api_key: str, model: str = "", native_modef _hermes_relay_route(base_url: str, api_key: str, drop_fields: tuple[str, ...] = (),stream_usage: bool = False, gemini_schemas: bool = False,- usage_no_nulls: bool = False) -> tuple[str, str]:+ usage_no_nulls: bool = False, exact_base: bool = False) -> tuple[str, str]:"""Register one turn's upstream; → (relay base_url, placeholder bearer for the CLI).`drop_fields` names top-level request fields this route's client sends on its own initiative and@@ -4805,7 +4817,9 @@ def _hermes_relay_route(base_url: str, api_key: str, drop_fields: tuple[str, ...for a streamed call's usage when the client does not (_request_stream_usage). `gemini_schemas`normalises a gemini model's tool declarations on this route whatever the channel (see_build_grok for the one client that needs it). `usage_no_nulls` rewrites a null token count in an- answer's usage to 0 for a client whose parser takes only a number there (_usage_without_nulls)."""+ answer's usage to 0 for a client whose parser takes only a number there (_usage_without_nulls).+ `exact_base` joins the client's resource onto the connection's base as stored, for a client that+ was calling that base directly before it had a route (Codex): the same URL, with the relay between."""with _HERMES_RELAY["lock"]:if _HERMES_RELAY["server"] is None:srv = http.server.ThreadingHTTPServer(("127.0.0.1", 0), _HermesRelayHandler)@@ -4818,7 +4832,8 @@ def _hermes_relay_route(base_url: str, api_key: str, drop_fields: tuple[str, ...# https://api.anthropic.com/chat/completions, a 404 with no body (2026-09-06 support# matrix; Anthropic's OpenAI-compatible surface lives under /v1). Bedrock keeps its host# (its own path is built in _bedrock_anthropic).- _HERMES_RELAY["routes"][tok] = (_relay_base_with_version(base_url), api_key,+ upstream = (base_url or "").rstrip("/") if exact_base else _relay_base_with_version(base_url)+ _HERMES_RELAY["routes"][tok] = (upstream, api_key,{"rename_max_tokens": False, "drop_fields": tuple(drop_fields),"stream_usage": bool(stream_usage),"gemini_schemas": bool(gemini_schemas),diff --git a/runner/tests/test_codex_aggregator_relay.py b/runner/tests/test_codex_aggregator_relay.pynew file mode 100644index 00000000..e66dc47b--- /dev/null+++ b/runner/tests/test_codex_aggregator_relay.py@@ -0,0 +1,134 @@+"""Codex on an aggregator's connection rides the relay.++Codex groups a server's MCP tools in a namespace and adds an empty `properties` to each object node+of their schemas. Measured 2026-10-05 through a self-hosted instance, an MCP tool that reports what+it received, Codex with gpt-6-luna, two runs per connection:++ TokenRouter OpenAI Azure OpenRouter Vercel+ intact intact intact intact [{}], [{}, {}]++and the same on Vercel with gpt-6.1-sol. (gpt-5.4, gpt-5.4-mini, gpt-5.5, gpt-5.6-sol and gpt-6-astra+passed there; for gpt-5.4 Codex was seen to defer its tool definitions behind a tool search, and the+other four are assumed alike.) The repair lives in the relay, and Codex was the one base that never+passed through it: it was handed the connection's base and key.+"""+import http.client+import http.server+import json+import sys+import threading+from pathlib import Path++sys.path.insert(0, str(Path(__file__).resolve().parents[1]))+import server as rs # noqa: E402+++def _prepare(tmp_path, provider, auth, **kw):+ home = tmp_path / "home"+ home.mkdir(exist_ok=True)+ env = {"HOME": str(home)}+ cfg_dir = rs._codex_prepare_env(provider, auth, "gpt-6-luna", str(tmp_path), env, **kw)+ return env, (cfg_dir / "config.toml").read_text()+++def test_an_aggregator_connection_gets_a_route_and_the_key_stays_out_of_the_cli(tmp_path):+ env, cfg = _prepare(tmp_path, "tokenrouter",+ rs.Auth(api_key="sk-agg-real", base_url="https://ai-gateway.example/v1"))+ tok = env["ROUTER_API_KEY"]+ try:+ assert tok.startswith("hr-relay-")+ assert "sk-agg-real" not in json.dumps(env) and "sk-agg-real" not in cfg+ assert "ai-gateway.example" not in cfg and 'base_url = "http://127.0.0.1:' in cfg+ upstream, key, _flags = rs._HERMES_RELAY["routes"][tok]+ assert upstream == "https://ai-gateway.example/v1" and key == "sk-agg-real"+ finally:+ rs._HERMES_RELAY["routes"].pop(tok, None)+++def test_the_route_keeps_the_connection_base_exactly(tmp_path):+ """Codex called `<base>/responses` whatever the base looked like. A route that added a version+ segment, as other bases' routes do, would move a custom endpoint that has none."""+ env, _cfg = _prepare(tmp_path, "tokenrouter",+ rs.Auth(api_key="k", base_url="https://llm.example/api/openai/", api_format="responses"))+ tok = env["ROUTER_API_KEY"]+ try:+ assert rs._HERMES_RELAY["routes"][tok][0] == "https://llm.example/api/openai"+ finally:+ rs._HERMES_RELAY["routes"].pop(tok, None)+++def test_openai_and_azure_keep_their_direct_route(tmp_path):+ for provider, var, base in (("openai", "OPENAI_API_KEY", "https://api.openai.com/v1"),+ ("azure", "AZURE_OPENAI_API_KEY", "https://res.openai.azure.com/openai/v1")):+ env, cfg = _prepare(tmp_path, provider, rs.Auth(api_key="sk-direct", base_url=base))+ assert env[var] == "sk-direct"+ assert f'base_url = "{base}"' in cfg and "127.0.0.1" not in cfg+++def test_the_account_fingerprint_follows_the_connection_not_the_route(tmp_path):+ """A route is new on every turn. Were it part of the fingerprint, every resume would look like a+ change of account and the session's history would be replayed as content each time."""+ auth = rs.Auth(api_key="sk-agg-real", base_url="https://ai-gateway.example/v1")+ first, _ = _prepare(tmp_path, "tokenrouter", auth)+ second, _ = _prepare(tmp_path, "tokenrouter", auth)+ other, _ = _prepare(tmp_path, "tokenrouter", rs.Auth(api_key="sk-another", base_url="https://ai-gateway.example/v1"))+ try:+ assert first["ROUTER_API_KEY"] != second["ROUTER_API_KEY"]+ assert second["HR_CODEX_ACCOUNT_CHANGED"] == "0"+ assert other["HR_CODEX_ACCOUNT_CHANGED"] == "1"+ finally:+ for env in (first, second, other):+ rs._HERMES_RELAY["routes"].pop(env["ROUTER_API_KEY"], None)+++def test_a_resumed_session_declares_its_earlier_provider_ids_at_the_route(tmp_path, monkeypatch):+ monkeypatch.setattr(rs, "_codex_session_provider_ids", lambda cfg_dir: ["hr-azure", "hr-tokenrouter"])+ env, cfg = _prepare(tmp_path, "tokenrouter",+ rs.Auth(api_key="sk-agg-real", base_url="https://ai-gateway.example/v1"), resume=True)+ try:+ assert "[model_providers.hr-azure]" in cfg+ assert cfg.count('base_url = "http://127.0.0.1:') == 2 and "ai-gateway.example" not in cfg+ finally:+ rs._HERMES_RELAY["routes"].pop(env["ROUTER_API_KEY"], None)+++def test_what_codex_sends_reaches_the_provider_at_the_same_url_with_the_objects_free_form(tmp_path):+ seen = {}++ class Up(http.server.BaseHTTPRequestHandler):+ def do_POST(self):+ seen["path"] = self.path+ seen["auth"] = self.headers.get("authorization")+ seen["body"] = json.loads(self.rfile.read(int(self.headers["content-length"])))+ out = b'{"id":"resp_1","object":"response","model":"m","status":"completed","output":[]}'+ self.send_response(200); self.send_header("content-type", "application/json")+ self.send_header("content-length", str(len(out))); self.end_headers(); self.wfile.write(out)++ def log_message(self, *a):+ pass++ up = http.server.HTTPServer(("127.0.0.1", 0), Up)+ threading.Thread(target=up.serve_forever, daemon=True).start()+ # a base with no version segment: the route must not add one+ env, cfg = _prepare(tmp_path, "tokenrouter",+ rs.Auth(api_key="sk-agg-real", base_url=f"http://127.0.0.1:{up.server_port}/api/llm"))+ tok = env["ROUTER_API_KEY"]+ relay = cfg.split('base_url = "', 1)[1].split('"', 1)[0]+ conn = http.client.HTTPConnection(relay.removeprefix("http://").split("/", 1)[0], timeout=10)+ try:+ # the request as Codex 0.154.0 builds it for a model it does not defer tools for+ conn.request("POST", "/" + relay.split("/", 3)[3] + "/responses", # /v1/responses, as Codex joins it+ body=json.dumps({"model": "openai/gpt-6-luna", "input": [], "stream": False, "tools": [+ {"type": "namespace", "name": "mcp__probe", "description": "probe", "tools": [+ {"type": "function", "name": "probe_rows", "strict": False, "parameters": {+ "type": "object", "properties": {"rows": {"type": "array", "items": {+ "type": "object", "properties": {}}}}, "required": ["rows"]}}]}]}),+ headers={"authorization": f"Bearer {tok}", "content-type": "application/json"})+ resp = conn.getresponse(); resp.read()+ assert resp.status == 200+ assert seen["path"] == "/api/llm/responses" and seen["auth"] == "Bearer sk-agg-real"+ fn = seen["body"]["tools"][0]["tools"][0]+ assert fn["parameters"]["properties"]["rows"]["items"] == {"type": "object"}+ assert fn["parameters"]["required"] == ["rows"] and fn["strict"] is False+ finally:+ conn.close(); up.shutdown(); rs._HERMES_RELAY["routes"].pop(tok, None)diff --git a/scripts/support-matrix/README.md b/scripts/support-matrix/README.mdindex b1aad148..05cf40ba 100644--- a/scripts/support-matrix/README.md+++ b/scripts/support-matrix/README.md@@ -52,8 +52,11 @@ instance does not serve is skipped and recorded as not offered. Exit 0 when ever`plugins/run-matrix.py` proves the plugin path on every base, one base at a time: a harness iscreated with ONE Agent Plugins package (`plugins/fixture/`: a manifest, a skill whose token themodel must repeat, a stdio MCP server that speaks the protocol by hand) and nothing on its-direct lists, one real task runs per column (skill, stdio MCP, SSE MCP, streamable-HTTP MCP, the-remote two against a public probe), and the answer is judged on the probe token alone.+direct lists, one real task runs per column (skill, stdio MCP, a stdio tool that takes a list of+free-form objects, SSE MCP, streamable-HTTP MCP, the remote two against a public probe), and the+answer is judged on the probe token alone. The `rows` column's token comes from the tool itself:+it answers only when the rows it was handed carry their fields, and names what it received+otherwise, so an agent's own account of its call is never the judge.python3 plugins/run-matrix.py --base-url https://your-instance/api/harness --api-key "$KEY" \--bases aider --out plugin-results.jsondiff --git a/scripts/support-matrix/plugins/run-matrix.py b/scripts/support-matrix/plugins/run-matrix.pyindex 0359034d..92fb953e 100755--- a/scripts/support-matrix/plugins/run-matrix.py+++ b/scripts/support-matrix/plugins/run-matrix.py@@ -2,11 +2,15 @@"""Prove the plugin path on every harness base, directly. No workflow, no fan out.For each base it creates a harness carrying the fixture package, runs one real task, checks the-answer for the probe token, and deletes the harness. Two modes:+answer for the probe token, and deletes the harness. Five modes:skills the package carries only its Skill; every base must load itmcp the package also declares a stdio MCP server; every base must call its tool (since#180/#182 every base takes a stdio server; pi's adapter and dsh's client spawn it)+ rows the same stdio server's second tool takes a list of free-form objects and answers its+ token only when both rows arrive with their fields; otherwise it says what it received+ (#394: some bases add an empty `properties` to the item's schema and some routes then+ hand the tool [{}, {}]). Run it with --model on each connection that serves the modelsse the package declares an SSE server (a public probe); codex, dsh and goose reach itthrough the runner's bridge (#185), every other base nativelyhttp the package declares a streamable-HTTP server (the same probe's /mcp end)