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.

fix(runner): cumulative relay repairs; reasoning_effort:'none' on gpt-5.6 complaint

richard-epsilla5518cc0043ec
diff --git a/runner/server.py b/runner/server.py
index 5b4f79e7..f2006c60 100644
--- a/runner/server.py
+++ b/runner/server.py
@@ -1982,6 +1982,24 @@ def _stringify_tool_content(body: bytes) -> bytes:
return body
+def _set_reasoning_effort_none(body: bytes) -> bytes:
+ """Set `reasoning_effort: "none"` in one chat-completions body.
+
+ OpenAI's gpt-5.6 family refuses function tools on /v1/chat/completions unless
+ reasoning_effort is 'none', and says so verbatim ("Function tools with reasoning_effort are
+ not supported ... set reasoning_effort to 'none'" — surfaced live through LLMTR 2026-08-27).
+ Applied only on that complaint, and remembered per (route, model) — never route-wide,
+ because other models on the same aggregator reject the parameter outright."""
+ try:
+ obj = json.loads(body)
+ if isinstance(obj, dict) and obj.get("reasoning_effort") != "none":
+ obj["reasoning_effort"] = "none"
+ return json.dumps(obj, separators=(",", ":")).encode()
+ except Exception: # noqa: BLE001 — a body we cannot parse is a body we must not alter
+ pass
+ return body
+
+
def _drop_stream_options(body: bytes) -> bytes:
"""Remove `stream_options` from one chat-completions body.
@@ -2125,6 +2143,10 @@ class _HermesRelayHandler(http.server.BaseHTTPRequestHandler):
and body is not None):
self._bedrock_anthropic(base, key, body)
return
+ try:
+ _body_model = json.loads(body or b"{}").get("model") or ""
+ except Exception: # noqa: BLE001
+ _body_model = ""
if body is not None and self.path.endswith("/chat/completions"):
body = _normalize_openai_chat_body(body)
if flags.get("rename_max_tokens"):
@@ -2133,22 +2155,24 @@ class _HermesRelayHandler(http.server.BaseHTTPRequestHandler):
body = _stringify_tool_content(body)
if flags.get("drop_stream_options"):
body = _drop_stream_options(body)
+ if flags.get(f"reasoning_effort_none:{_body_model}"):
+ body = _set_reasoning_effort_none(body)
headers["content-length"] = str(len(body))
resp = None
tried_slim = False
- for attempt in (0, 1):
+ for attempt in (0, 1, 2):
req = urllib.request.Request(base.rstrip("/") + tail, data=body,
method=self.command, headers=headers)
try:
resp = urllib.request.urlopen(req, timeout=600)
- if attempt == 1 and tried_slim:
- # the blind no-stream_options retry is what made this route work
+ if attempt > 0 and tried_slim:
+ # the blind no-stream_options retry is part of what made this route work
flags["drop_stream_options"] = True
break
except urllib.error.HTTPError as e:
data = e.read()
renamed = _rename_max_tokens(body) if body is not None else None
- if (attempt == 0 and e.code == 400 and b"max_completion_tokens" in data
+ if (attempt < 2 and e.code == 400 and b"max_completion_tokens" in data
and renamed is not None and renamed != body):
# The provider named the fix itself; apply it, remember it for this route.
flags["rename_max_tokens"] = True
@@ -2156,14 +2180,22 @@ class _HermesRelayHandler(http.server.BaseHTTPRequestHandler):
headers["content-length"] = str(len(body))
continue
stringified = _stringify_tool_content(body) if body is not None else None
- if (attempt == 0 and e.code == 400 and b"content must be a string" in data
+ if (attempt < 2 and e.code == 400 and b"content must be a string" in data
and stringified is not None and stringified != body):
flags["stringify_tool_content"] = True
body = stringified
headers["content-length"] = str(len(body))
continue
+ effort = _set_reasoning_effort_none(body) if body is not None else None
+ if (attempt < 2 and e.code == 400 and b"reasoning_effort" in data
+ and b"'none'" in data and effort is not None and effort != body):
+ # the provider named the fix itself; remember it for this model only
+ flags[f"reasoning_effort_none:{_body_model}"] = True
+ body = effort
+ headers["content-length"] = str(len(body))
+ continue
slim = _drop_stream_options(body) if body is not None else None
- if attempt == 0 and e.code == 400 and slim is not None and slim != body:
+ if attempt < 2 and e.code == 400 and slim is not None and slim != body:
tried_slim = True
# Generic 400 with stream_options aboard: blind single retry without it
# (LLMTR's gpt-5.x upstream names nothing better). Sticks only if it works.
diff --git a/runner/tests/test_hermes_relay.py b/runner/tests/test_hermes_relay.py
index ad64408c..f026b234 100644
--- a/runner/tests/test_hermes_relay.py
+++ b/runner/tests/test_hermes_relay.py
@@ -295,3 +295,58 @@ def test_relay_retries_a_stream_options_rejection_and_sticks():
assert len(calls) == 3 and "stream_options" not in calls[2] # sticky: no second 400
finally:
up.shutdown()
+
+# ── cumulative repairs in one request (qwen x LLMTR gpt-5.6, 2026-08-27) ────────────────────────
+# A single request can need TWO named fixes: the first 400 (generic) goes away with
+# stream_options dropped, and only then does the upstream surface "Function tools with
+# reasoning_effort are not supported ... set reasoning_effort to 'none'". Three attempts let
+# both land; the reasoning_effort fix sticks per (route, model), never route-wide.
+
+def test_relay_applies_two_repairs_cumulatively_and_scopes_effort_per_model():
+ calls = []
+
+ class Upstream(BaseHTTPRequestHandler):
+ protocol_version = "HTTP/1.1"
+
+ def do_POST(self): # noqa: N802
+ body = json.loads(self.rfile.read(int(self.headers["content-length"])))
+ calls.append(body)
+ if "stream_options" in body:
+ data = b'{"error": {"message": "The model provider rejected the request."}}'
+ self.send_response(400)
+ elif body["model"] == "gpt-5.6-luna" and body.get("reasoning_effort") != "none":
+ data = (b'{"error": {"message": "Function tools with reasoning_effort are not '
+ b'supported for gpt-5.6-luna in /v1/chat/completions. To use function '
+ b'tools, use /v1/responses or set reasoning_effort to \'none\'."}}')
+ self.send_response(400)
+ else:
+ data = b'{"ok": true}'
+ self.send_response(200)
+ self.send_header("content-type", "application/json")
+ self.send_header("content-length", str(len(data)))
+ self.end_headers()
+ self.wfile.write(data)
+
+ def log_message(self, *a):
+ pass
+
+ up = ThreadingHTTPServer(("127.0.0.1", 0), Upstream)
+ threading.Thread(target=up.serve_forever, daemon=True).start()
+ try:
+ base, tok = _hermes_relay_route(f"http://127.0.0.1:{up.server_address[1]}/v1", "sk-real")
+ mk = lambda model: json.dumps({"model": model, "stream": True,
+ "stream_options": {"include_usage": True},
+ "messages": [{"role": "user", "content": "hi"}]}).encode()
+ req = lambda b: urllib.request.Request(base + "/chat/completions", data=b, method="POST",
+ headers={"authorization": f"Bearer {tok}",
+ "content-type": "application/json"})
+ assert json.loads(urllib.request.urlopen(req(mk("gpt-5.6-luna")), timeout=10).read()) == {"ok": True}
+ # attempt 0: generic 400 -> drop stream_options; attempt 1: named 400 -> effort none; attempt 2: OK
+ assert len(calls) == 3
+ assert "stream_options" not in calls[1] and calls[2]["reasoning_effort"] == "none"
+ # a DIFFERENT model on the same route inherits the stream_options drop but NOT the effort
+ assert json.loads(urllib.request.urlopen(req(mk("other-model")), timeout=10).read()) == {"ok": True}
+ assert calls[-1]["model"] == "other-model" and "reasoning_effort" not in calls[-1]
+ assert "stream_options" not in calls[-1] and len(calls) == 4 # no extra 400 round-trip
+ finally:
+ up.shutdown()