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.

feat(dsh): multi-family — the wider families ride pi's LLM library, as a dsh plugin

richard-epsillafde5067758e6
diff --git a/gateway/app.py b/gateway/app.py
index 503e9131..10b13af0 100644
--- a/gateway/app.py
+++ b/gateway/app.py
@@ -930,12 +930,16 @@ _INTEGRATION_WIRING: dict[tuple[str, str], str] = {
("openrouter", "pi"): "openai-api",
("tokenrouter", "pi"): "tokenrouter", ("vercel", "pi"): "tokenrouter",
("llmtr", "pi"): "tokenrouter",
- # dsh (DeepSeek Harness) runs the deepseek family over any OpenAI-compatible endpoint —
- # 'deepseek' on the runner means exactly that (base_url + key; the driver's relay
- # normalizes aggregator stream quirks). A first-party DeepSeek Platform integration is
- # NOT listed yet: nobody here holds a platform.deepseek.com key, and unprobed is unlisted.
- ("tokenrouter", "dsh"): "deepseek", ("openrouter", "dsh"): "deepseek",
- ("vercel", "dsh"): "deepseek", ("llmtr", "dsh"): "deepseek",
+ # dsh (DeepSeek Harness) is multi-family via dsh-llm-pi-ai — pi's unified LLM library as
+ # a Cordis plugin — so its wiring mirrors pi's: 'deepseek' on the runner is the launch
+ # adapter for the deepseek family, 'tokenrouter' again means "OpenAI/Anthropic-compatible,
+ # api picked by model family" at the driver's relay. A first-party DeepSeek Platform
+ # integration is still NOT listed: nobody here holds a platform key; unprobed is unlisted.
+ ("anthropic", "dsh"): "anthropic", ("openai", "dsh"): "openai",
+ ("azure-foundry", "dsh"): "azure",
+ ("openrouter", "dsh"): "openai-api",
+ ("tokenrouter", "dsh"): "tokenrouter", ("vercel", "dsh"): "tokenrouter",
+ ("llmtr", "dsh"): "tokenrouter",
}
@@ -4315,7 +4319,7 @@ def _map_model(conn: dict, friendly: str) -> str | None:
table = _vendor_models(provider)
if friendly and friendly in table:
return table[friendly]
- if backend == "claude" or (backend in ("hermes", "pi") and provider in ("anthropic", "bedrock")):
+ if backend == "claude" or (backend in ("hermes", "pi", "dsh") and provider in ("anthropic", "bedrock")):
# Older claude ids the catalog no longer lists still map, and a caller may pass a
# provider-native id directly; _LEGACY_CLAUDE_IDS carries both, keyed bare (opus-4.5).
legacy = _BEDROCK_CLAUDE if provider == "bedrock" else _ANTHROPIC_CLAUDE
@@ -4409,13 +4413,21 @@ _MODEL_CATALOG: dict[str, dict] = {
# nemotron-3-ultra and qwen3.7-flash are NOT here: TokenRouter lists no channel for them,
# hermes serves them via OpenRouter, and no OpenRouter credential was available to probe
# pi with — unprobed is unlisted, per the bar at the top of this table.
- # dsh (DeepSeek Harness) is single-family BY DESIGN in this first phase: the audit that
- # scoped this backend (2026-08-13, harnessrouter-management) defers multi-provider
- # composition until one provider path has proven model/usage/tool/error consistency.
- # Both models probe-verified through the full product path on the TokenRouter connection
- # (2026-08-20), substitution-checked.
+ # dsh (DeepSeek Harness) went multi-family once the single-provider phase the audit
+ # required had proven itself (deepseek family, full product path, 2026-08-20). The wider
+ # families ride dsh-llm-pi-ai — pi's LLM library as a dsh plugin — through the driver's
+ # relay, so the serving paths are the ones pi's rows already earned; each family below was
+ # re-verified through a real dsh turn on the TokenRouter connection, substitution-checked,
+ # and the frontier set was probed per-model through the dsh driver (2026-08-20).
"dsh": {"default": "deepseek-v4-pro",
- "models": ["deepseek-v4-pro", "deepseek-v4-flash"]},
+ "models": ["deepseek-v4-pro", "deepseek-v4-flash",
+ "gpt-5.6-sol", "gpt-5.6-terra", "gpt-5.6-luna", "gpt-5.5",
+ "gpt-5.4", "gpt-5.4-mini", "gpt-5.2", "gpt-5.3-codex",
+ "claude-opus-5", "claude-fable-5", "claude-opus-4.8", "claude-sonnet-5",
+ "claude-opus-4.7", "claude-sonnet-4.6", "claude-haiku-4.5",
+ "gemini-3.6-flash", "kimi-k3", "kimi-k2.7-code",
+ "qwen3.7-max", "qwen3.8-max",
+ "mistral-medium-3.5", "step-3.7-flash"]},
"pi": {"default": "gpt-5.4",
"models": ["gpt-5.6-sol", "gpt-5.6-terra", "gpt-5.6-luna", "gpt-5.5",
"gpt-5.4", "gpt-5.4-mini", "gpt-5.2", "gpt-5.3-codex",
@@ -4483,9 +4495,9 @@ def _model_authorized(requested: str, backend: str) -> bool:
return False
if r in {m.lower() for m in _MODEL_CATALOG.get(backend, {}).get("models", [])}:
return True
- if backend in ("claude", "hermes", "pi") and r in _PROVIDER_CLAUDE_IDS:
+ if backend in ("claude", "hermes", "pi", "dsh") and r in _PROVIDER_CLAUDE_IDS:
return True # power users may pass a provider-native claude id (claude-opus-4-8 / us.anthropic...)
- if backend in ("codex", "hermes", "pi") and r.startswith("gpt-"):
+ if backend in ("codex", "hermes", "pi", "dsh") and r.startswith("gpt-"):
return True # gpt-* family; Azure deployment names vary
if backend == "dsh" and r.startswith(("deepseek", "deepseek/")):
return True # deepseek family; aggregator slugs vary (deepseek/deepseek-v4-pro)
diff --git a/runner/dsh_driver.py b/runner/dsh_driver.py
index 0bb42662..78862a34 100644
--- a/runner/dsh_driver.py
+++ b/runner/dsh_driver.py
@@ -54,15 +54,19 @@ class _Relay(http.server.BaseHTTPRequestHandler):
def do_POST(self): # noqa: N802
body = self.rfile.read(int(self.headers.get("content-length") or 0))
- # DEEPSEEK_BASE_URL carries /v1 and the adapter appends /chat/completions, so the
- # incoming path is /v1/...; the upstream base also ends in /v1 — join without doubling.
+ # The adapters' base URLs point at this relay and they append their own API paths
+ # (/v1/chat/completions, /v1/responses, /v1/messages); the upstream base ends in /v1 —
+ # join without doubling.
tail = self.path.removeprefix("/v1") if self.path.startswith("/v1/") else self.path
- req = urllib.request.Request(
- UPSTREAM_BASE.rstrip("/") + tail,
- data=body, method="POST",
- headers={"content-type": self.headers.get("content-type") or "application/json",
- "authorization": f"Bearer {UPSTREAM_KEY}",
- "accept": self.headers.get("accept") or "*/*"})
+ # Forward protocol headers (anthropic-version et al) verbatim; strip hop/auth/length.
+ drop = {"host", "content-length", "authorization", "x-api-key", "connection",
+ "accept-encoding", "transfer-encoding"}
+ headers = {k: v for k, v in self.headers.items() if k.lower() not in drop}
+ headers["authorization"] = f"Bearer {UPSTREAM_KEY}"
+ headers["x-api-key"] = UPSTREAM_KEY # the anthropic-messages spelling; harmless elsewhere
+ headers.setdefault("accept", "*/*")
+ req = urllib.request.Request(UPSTREAM_BASE.rstrip("/") + tail,
+ data=body, method="POST", headers=headers)
try:
resp = urllib.request.urlopen(req, timeout=600)
except urllib.error.HTTPError as e: # pass provider errors through verbatim
@@ -74,6 +78,9 @@ class _Relay(http.server.BaseHTTPRequestHandler):
self.wfile.write(data)
return
ctype = resp.headers.get("content-type") or ""
+ # The empty-string id/name quirk is a chat-completions stream shape; other protocols
+ # (anthropic-messages, openai-responses) pass through byte-faithful.
+ rewrite = self.path.endswith("/chat/completions")
self.send_response(resp.status)
self.send_header("content-type", ctype)
if "text/event-stream" in ctype:
@@ -87,11 +94,11 @@ class _Relay(http.server.BaseHTTPRequestHandler):
buf += chunk
while b"\n" in buf:
line, buf = buf.split(b"\n", 1)
- out = _rewrite_sse_line(line.rstrip(b"\r")) + b"\n"
+ out = (_rewrite_sse_line(line.rstrip(b"\r")) if rewrite else line.rstrip(b"\r")) + b"\n"
self.wfile.write(f"{len(out):x}\r\n".encode() + out + b"\r\n")
self.wfile.flush()
if buf:
- out = _rewrite_sse_line(buf)
+ out = _rewrite_sse_line(buf) if rewrite else buf
self.wfile.write(f"{len(out):x}\r\n".encode() + out + b"\r\n")
self.wfile.write(b"0\r\n\r\n")
else:
@@ -117,7 +124,8 @@ def _emit(method: str, payload) -> None:
DSH_RUNTIME_HAS_MCP = False
-def _compose_cordis(home: pathlib.Path, servers: list[dict]) -> str:
+def _compose_cordis(home: pathlib.Path, servers: list[dict], llm: dict | None = None,
+ relay_port: int = 0, model: str = "") -> str:
"""Our runtime composition: the wheel's bundled default, with the SDK server entry swapped
for the resume-or-create subclass (see hr_dsh_server.cjs — packaged-bin loads
configuration-relative plugins), plus one dsh-mcp-client entry per enabled MCP server."""
@@ -145,6 +153,23 @@ def _compose_cordis(home: pathlib.Path, servers: list[dict]) -> str:
if hdrs:
entry["config"]["headers"] = hdrs
blocks.append(entry)
+ if llm:
+ # Non-deepseek families ride dsh's OWN multi-provider layer, dsh-llm-pi-ai — which is
+ # pi's unified LLM library wrapped as a Cordis plugin, so the api-by-family choices are
+ # literally the ones the pi backend already proved. The route points at the loopback
+ # 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"
+ blocks.append({"id": "hr-llm", "name": "@deepseek-ai/dsh-llm-pi-ai", "config": {
+ "providers": {"hr": {
+ "displayName": "HR Gateway",
+ "apiKeyEnv": "HR_RELAY_TOKEN",
+ "api": api,
+ "baseURL": base_url,
+ "models": [{"id": model, "contextWindow": 200000, "maxTokens": 32000,
+ "input": (["text", "image"] if llm.get("vision", True) else ["text"])}],
+ }}}})
path = home / ".dsh" / "cordis.yml"
path.parent.mkdir(parents=True, exist_ok=True)
import shutil
@@ -174,6 +199,7 @@ def main() -> int:
from deepseek_harness import DeepSeekHarness
+ os.environ["HR_RELAY_TOKEN"] = "hr-relay" # the placeholder the pi-ai route resolves
mcp = job.get("mcp_servers") or []
if mcp and not DSH_RUNTIME_HAS_MCP:
# The pi precedent: a capability the harness asked for but this build cannot provide is
@@ -182,9 +208,11 @@ def main() -> int:
"runtime (0.1.0rc7) does not bundle its MCP client yet — this turn runs without "
"them. The next runtime pin restores them.", flush=True)
mcp = []
- kwargs = dict(provider="deepseek-official", model=job["model"],
+ llm = job.get("llm") # None => the verified deepseek-official path
+ kwargs = dict(provider=("hr" if llm else "deepseek-official"), model=job["model"],
cwd=cwd, session_root=str(sessions),
- cordis=_compose_cordis(home, mcp),
+ cordis=_compose_cordis(home, mcp, llm=llm,
+ relay_port=srv.server_address[1], model=job["model"]),
# A runtime whose plugin tree failed stays alive with a mute stdout; without a
# bound the initialize request waits forever and the turn reads as a hang.
request_timeout_seconds=180.0)
diff --git a/runner/server.py b/runner/server.py
index 0edc6cd0..c6fd6f35 100644
--- a/runner/server.py
+++ b/runner/server.py
@@ -1094,28 +1094,50 @@ def _build_codex(provider: str, auth: Auth, model: str, prompt: str, cwd: str,
# launches the bundled runtime executable, and every session.event notification comes back as
# one NDJSON line {"m": method, "p": payload}. Cancel stays a process-group kill — the SDK's
# close ladder never runs on a killed driver, and the runtime dies with the group.
-DSH_PROVIDERS = {"deepseek"}
+# "deepseek" is the launch provider (dsh's own adapter, auto-mounted); everything else rides
+# dsh-llm-pi-ai — pi's unified LLM library as a Cordis plugin — through a hand-declared route
+# at the driver's relay, so the api-by-family rules are the ones the pi backend already proved.
+DSH_PROVIDERS = {"deepseek", "anthropic", "openai", "azure", "openai-api", "tokenrouter"}
+_DSH_DEFAULT_BASE = {"anthropic": "https://api.anthropic.com/v1",
+ "openai": "https://api.openai.com/v1",
+ "deepseek": "https://api.deepseek.com/v1"}
DSH_PYTHON = os.environ.get("HR_DSH_PYTHON", "/data/agent-tools/dsh-venv/bin/python")
+_DSH_DEEPSEEK_MODEL = re.compile(r"(?:^|/)deepseek", re.I)
DSH_DRIVER = os.path.join(os.path.dirname(os.path.abspath(__file__)), "dsh_driver.py")
def _build_dsh(provider: str, auth: Auth, model: str, prompt: str, cwd: str, env: dict,
resume_session_id: str | None = None,
- mcp_servers: list[dict] | None = None) -> list[str]:
+ mcp_servers: list[dict] | None = None, vision: bool = True) -> list[str]:
pr = provider or "deepseek"
if pr not in DSH_PROVIDERS:
raise HTTPException(400, f"unknown dsh provider '{pr}' (one of {sorted(DSH_PROVIDERS)})")
- if not auth.base_url and not auth.api_key:
- raise HTTPException(400, "dsh needs an OpenAI-compatible endpoint (base_url) and api_key")
+ base = auth.base_url or _DSH_DEFAULT_BASE.get(pr, "")
+ if not base:
+ raise HTTPException(400, f"dsh provider '{pr}' needs a base_url (none configured)")
+ if not base.rstrip("/").endswith("/v1"):
+ base = base.rstrip("/") + "/v1" # the relay joins upstream paths against a /v1 base
# HR_DSH_*: consumed and scrubbed by the driver before the runtime starts. The runtime gets
# a loopback relay URL and a placeholder key — the credential never enters its environment.
- env["HR_DSH_BASE_URL"] = (auth.base_url or "https://api.deepseek.com/v1")
+ env["HR_DSH_BASE_URL"] = base
env["HR_DSH_API_KEY"] = auth.api_key or ""
# No system_prompt in the job: harness instructions land in AGENTS.md (dsh reads it via
# its dsh-agent-instructions loader), same mechanism as codex/hermes/pi.
job = {"prompt": prompt, "model": model, "cwd": cwd,
"session_id": resume_session_id or "",
"mcp_servers": [s for s in (mcp_servers or []) if (s or {}).get("url")]}
+ if not _DSH_DEEPSEEK_MODEL.search(model or ""):
+ # Family decides the route, not the integration's name: deepseek models keep the
+ # verified dsh-llm-deepseek launch path whichever endpoint serves them; every other
+ # family rides the pi-ai route. api by family — the same routing the pi backend
+ # live-verified on these channels.
+ if pr == "anthropic" or _PI_CLAUDE_MODEL.search(model or ""):
+ api = "anthropic-messages"
+ elif pr == "azure" or _HERMES_RESPONSES_API_MODEL.search(model or ""):
+ api = "openai-responses"
+ else:
+ api = "openai-completions"
+ job["llm"] = {"api": api, "vision": vision}
return [DSH_PYTHON, DSH_DRIVER, json.dumps(job)]
@@ -2492,7 +2514,8 @@ def turn(req: TurnReq, identifier: str = "") -> dict:
elif backend == "dsh":
model = model or DSH_DEFAULT_MODEL
cmd = _build_dsh(req.provider, auth, model, req.prompt, cwd, env,
- resume_session_id=req.resume_session_id, mcp_servers=req.mcp_servers)
+ resume_session_id=req.resume_session_id, mcp_servers=req.mcp_servers,
+ vision=bool(req.vision))
elif backend == "pi":
model = model or PI_DEFAULT_MODEL
cmd = _build_pi(req.provider, auth, model, req.prompt, cwd, env,
diff --git a/runner/tests/test_dsh_normalize.py b/runner/tests/test_dsh_normalize.py
index e5fddd01..d930ecec 100644
--- a/runner/tests/test_dsh_normalize.py
+++ b/runner/tests/test_dsh_normalize.py
@@ -165,3 +165,22 @@ def test_build_dsh_stages_creds_out_of_argv(tmp_path):
assert job["session_id"] == "sid-9"
assert job["mcp_servers"][0]["url"] == "https://mcp.example/mcp"
assert "system_prompt" not in job
+
+
+def test_build_dsh_routes_by_family_not_provider(tmp_path):
+ """deepseek models keep the verified launch adapter whatever the integration is called;
+ claude/gpt/other families ride the pi-ai route with the api the pi backend proved."""
+ env = {"HOME": str(tmp_path)}
+ a = Auth(api_key="k", base_url="https://tr.example/v1")
+ j = lambda cmd: json.loads(cmd[2])
+ assert "llm" not in j(_build_dsh("tokenrouter", a, "deepseek/deepseek-v4-pro", "x", str(tmp_path), env))
+ assert j(_build_dsh("tokenrouter", a, "claude-haiku-4-5", "x", str(tmp_path), env))["llm"]["api"] == "anthropic-messages"
+ assert j(_build_dsh("tokenrouter", a, "gpt-5.4-mini", "x", str(tmp_path), env))["llm"]["api"] == "openai-responses"
+ assert j(_build_dsh("tokenrouter", a, "moonshotai/kimi-k3", "x", str(tmp_path), env))["llm"]["api"] == "openai-completions"
+ assert j(_build_dsh("tokenrouter", a, "qwen/qwen3.7-max", "x", str(tmp_path), env, vision=False))["llm"]["vision"] is False
+
+
+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"
diff --git a/ui/src/lib/harness.ts b/ui/src/lib/harness.ts
index b9e1eefd..2a46b8d6 100644
--- a/ui/src/lib/harness.ts
+++ b/ui/src/lib/harness.ts
@@ -72,8 +72,8 @@ export const OOB: OobHarness[] = [
systemPrompt: 'You are Pi, a minimal autonomous coding agent. You operate on a real git workspace, reading, writing and editing files and running bash to complete the task end to end.',
tools: [], skills: [] },
{ id: 'dsh', name: 'DeepSeek Harness', version: 'v0.1.0-rc.7', backend: 'dsh', status: 'ready',
- // Single-family by design in this phase (see gateway _MODEL_CATALOG).
- models: ['deepseek-v4-pro', 'deepseek-v4-flash'], defaultModel: 'deepseek-v4-pro', moreModels: 0,
+ // Multi-family via dsh-llm-pi-ai (pi's LLM library as a dsh plugin); placeholder until /v1/models lands.
+ models: ['deepseek-v4-pro', 'deepseek-v4-flash', 'gpt-5.4', 'gpt-5.4-mini', 'gpt-5.5', 'claude-opus-4.8', 'claude-sonnet-4.6', 'claude-haiku-4.5', 'gemini-3.6-flash', 'kimi-k3', 'qwen3.7-max'], defaultModel: 'deepseek-v4-pro', moreModels: 0,
systemPrompt: 'You are DeepSeek Harness, an autonomous coding agent. You work on a real git workspace, running shell commands and editing files to complete the task end to end.',
tools: [], skills: [] },
];