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(dsh): the anthropic-messages route base must not carry /v1 — the client appends it

richard-epsilla935a84c74df3
diff --git a/runner/dsh_driver.py b/runner/dsh_driver.py
index 78862a34..79be2aeb 100644
--- a/runner/dsh_driver.py
+++ b/runner/dsh_driver.py
@@ -160,7 +160,11 @@ def _compose_cordis(home: pathlib.Path, servers: list[dict], llm: dict | None =
# relay; apiKeyEnv resolves a placeholder, and the relay injects the real credential
# upstream — same isolation as the deepseek path.
api = llm.get("api") or "openai-completions"
- base_url = f"http://127.0.0.1:{relay_port}/v1"
+ # The same /v1 lesson the pi backend already paid for: the anthropic-messages client
+ # appends /v1/messages to its base itself, the openai clients want /v1 present. Getting
+ # it wrong here produced /v1/v1/messages against the relay — measured, not guessed.
+ base_url = (f"http://127.0.0.1:{relay_port}" if api == "anthropic-messages"
+ else f"http://127.0.0.1:{relay_port}/v1")
blocks.append({"id": "hr-llm", "name": "@deepseek-ai/dsh-llm-pi-ai", "config": {
"providers": {"hr": {
"displayName": "HR Gateway",
diff --git a/runner/tests/test_dsh_normalize.py b/runner/tests/test_dsh_normalize.py
index d930ecec..c926dfec 100644
--- a/runner/tests/test_dsh_normalize.py
+++ b/runner/tests/test_dsh_normalize.py
@@ -184,3 +184,21 @@ def test_build_dsh_native_anthropic_default_base(tmp_path):
env = {"HOME": str(tmp_path)}
_build_dsh("anthropic", Auth(api_key="k"), "claude-sonnet-4-6", "x", str(tmp_path), env)
assert env["HR_DSH_BASE_URL"] == "https://api.anthropic.com/v1"
+
+
+def test_compose_cordis_v1_normalization_per_api(tmp_path, monkeypatch):
+ """anthropic-messages appends /v1/messages itself — its relay base must be bare; the openai
+ apis want /v1 present. The doubled /v1/v1/messages this guards against was measured live."""
+ import types, sys as _sys
+ fake = types.ModuleType("deepseek_harness_runtime")
+ cfg = tmp_path / "bundled.yml"
+ cfg.write_text("- id: sdk-jsonrpc-server\n name: '@deepseek-ai/dsh-sdk-jsonrpc-server'\n")
+ fake.bundled_default_config_path = lambda: str(cfg)
+ monkeypatch.setitem(_sys.modules, "deepseek_harness_runtime", fake)
+ home = tmp_path / "home"
+ out_a = pathlib.Path(dsh_driver._compose_cordis(home, [], llm={"api": "anthropic-messages"},
+ relay_port=9999, model="claude-haiku-4-5")).read_text()
+ assert "baseURL: http://127.0.0.1:9999\n" in out_a and "9999/v1" not in out_a
+ out_o = pathlib.Path(dsh_driver._compose_cordis(home, [], llm={"api": "openai-responses"},
+ relay_port=9999, model="gpt-5.4-mini")).read_text()
+ assert "baseURL: http://127.0.0.1:9999/v1" in out_o