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
fix: hermes on Azure names the Responses API; a lost claude or opencode resume says so (#139)
github-actions[bot]52ee3696d04a
diff --git a/gateway/app.py b/gateway/app.pyindex 596cea8e..d9eaaf33 100644--- a/gateway/app.py+++ b/gateway/app.py@@ -4810,12 +4810,12 @@ def _blocks_from_canonical(ev: dict) -> list[tuple[str, object]]:# keys its stats by served model, and rewrites some ids on the way)"model": str(ev.get("model") or "")}))elif t == "system" and ev.get("subtype") == "resume_lost":- # The runner asked to continue a prior session, but it wasn't found in this sandbox — it- # silently started fresh instead (see harness_runner _run_hermes_bg). A caller who believed- # this was a continuation has no other way to learn the context was actually dropped, so- # surface it as a short, honest note rather than let the reply look like a real continuation.- out.append(("text", "_Note: couldn't resume the prior session in this sandbox — "- "continuing as a new session, without earlier context._\n\n"))+ # The runner asked to continue a prior session, but it wasn't found in this sandbox and the+ # turn started fresh (hermes says so itself; claude and opencode through _resume_lost; codex+ # carries its own note). A caller who believed this was a continuation has no other way to+ # learn the context was dropped, so it is a short, honest note at the top of the reply.+ out.append(("text", "_Note: the earlier conversation could not be restored. This reply "+ "continues as a new session, without that context._\n\n"))return outdiff --git a/runner/server.py b/runner/server.pyindex 72630ae9..7ec39bbe 100644--- a/runner/server.py+++ b/runner/server.py@@ -241,6 +241,18 @@ def _own_tree(root: str, uid: int, from_uids: set[int]) -> None:continue+def _resume_lost(backend: str, cmd: list[str], resume_session_id: str | None) -> str | None:+ """The session id the caller asked to continue when the built command does not carry it: the+ builder looked for the session in the workspace, did not find it, and started fresh (claude's+ --resume, opencode's --session). hermes says so itself; codex carries its own note. Four+ hosted opencode sessions answered three recalls each with "there is no earlier message" as+ completed turns (2026-09-08): the history was lost to the 2026-09-06 restore burst, and nothing+ told the person. The gateway renders the event as a note at the top of the reply."""+ if backend not in ("opencode", "claude") or not resume_session_id:+ return None+ return None if resume_session_id in cmd else resume_session_id++def _isolate_session(ws: str) -> None:"""Make the session directory the one place its uid can write, and make everything in itthat uid's. Allocation happens once, under a lock, from the owners of the directories that@@ -2199,11 +2211,16 @@ _HERMES_RESPONSES_API_MODEL = re.compile(r"(?:^|/)(?:gpt-(?:[5-9]|\d{2,})|o[1-4]def _hermes_api_mode(provider: str, model: str) -> str | None:"""`model.api_mode` for config.yaml, or None to leave hermes' own detection alone.- Only for the generic OpenAI-compatible provider: that is the one whose transport hermes infers- from the URL. bedrock/anthropic/azure-foundry/openrouter each have their own resolution in the- CLI, and overriding those would replace working logic with a guess.+ The generic OpenAI-compatible provider is the one whose transport hermes infers from the URL,+ so the Responses family is named for it. Azure is named too: hermes 0.19.0 infers the+ Responses API there from the prefixes codex, gpt-5, o1, o3 and o4 (hermes_cli/models.py,+ azure_foundry_model_api_mode) and reads the config's api_mode first (runtime_provider.py), so+ gpt-6-astra, none of those prefixes, went to chat completions, which Azure refuses for+ function tools with reasoning (the astra column, 2026-09-08; every other Azure pair passed).+ The same family test as the generic provider, so the next line lands routed. bedrock,+ anthropic and openrouter keep the CLI's own resolution."""- if provider != "openai-api" or not model:+ if provider not in ("openai-api", "azure-foundry") or not model:return Nonereturn "codex_responses" if _HERMES_RESPONSES_API_MODEL.search(model) else None@@ -5137,6 +5154,7 @@ def turn(req: TurnReq, identifier: str = "") -> dict:resume_session_id=req.resume_session_id, mcp_config=mcp_config,disallowed_tools=req.tools_disabled, partial=bool(req.partial_messages),plugin_dirs=plugin_dirs)+ resume_lost = _resume_lost(backend, cmd, req.resume_session_id)_isolate_session(cwd) # everything the runner just wrote into the session is the session's nowturn_id = "turn" + uuid.uuid4().hex_evict_turns()@@ -5154,6 +5172,9 @@ def turn(req: TurnReq, identifier: str = "") -> dict:if codex_note: # the follow-up's Codex history was not here: the transcript says so first_turns[turn_id]["events"].append({"type": "assistant", "_ts": time.time(),"message": {"content": [{"type": "text", "text": codex_note}]}})+ if resume_lost: # the same for claude and opencode: the reply opens with the note, never a silent restart+ _turns[turn_id]["events"].append({"type": "system", "subtype": "resume_lost", "_ts": time.time(),+ "requested_session_id": resume_lost})if key:_turn_by_key[key] = turn_idif use_appserver:diff --git a/runner/tests/test_claude_error_filter.py b/runner/tests/test_claude_error_filter.pyindex 72456384..0007a517 100644--- a/runner/tests/test_claude_error_filter.py+++ b/runner/tests/test_claude_error_filter.py@@ -83,3 +83,14 @@ def test_a_real_answer_after_a_retried_error_keeps_the_answer():rn._claude_passthrough(delta, state)out = rn._claude_passthrough({"type": "result", "subtype": "success", "result": "", "is_error": False}, state)assert out == [{"type": "result", "subtype": "success", "result": "Hello", "is_error": False}]+++def test_a_resume_the_builder_could_not_honor_is_reported_not_silent():+ """claude and opencode start fresh when the session is not in the workspace; the turn then+ opens with the resume_lost note the gateway renders (hermes already sends it, codex its own)."""+ assert rn._resume_lost("opencode", ["opencode", "run", "hello"], "ses_abc") == "ses_abc"+ assert rn._resume_lost("opencode", ["opencode", "run", "--session", "ses_abc", "hello"], "ses_abc") is None+ assert rn._resume_lost("claude", ["claude", "-p", "hi"], "s1") == "s1"+ assert rn._resume_lost("claude", ["claude", "-p", "--resume", "s1", "hi"], "s1") is None+ assert rn._resume_lost("opencode", ["opencode"], None) is None+ assert rn._resume_lost("hermes", ["hermes"], "s1") is Nonediff --git a/runner/tests/test_hermes_hang.py b/runner/tests/test_hermes_hang.pyindex 9048ef26..c671d5f5 100644--- a/runner/tests/test_hermes_hang.py+++ b/runner/tests/test_hermes_hang.py@@ -147,3 +147,15 @@ def test_resume_lost_emits_visible_event_not_just_a_log_line(monkeypatch, tmp_paassert any(e.get("type") == "system" and e.get("subtype") == "resume_lost"and e.get("requested_session_id") == "prior-not-here" for e in events), ("resume-lost was not signaled in the turn's event stream")+++def test_hermes_names_the_responses_api_on_azure_for_the_family_the_cli_does_not_know():+ """hermes 0.19.0 infers the Responses API on Azure from the prefixes codex, gpt-5, o1, o3, o4+ and reads the config's api_mode first; gpt-6-astra went to chat completions there and Azure+ refused function tools with reasoning (the astra column, 2026-09-08)."""+ from server import _hermes_api_mode+ assert _hermes_api_mode("azure-foundry", "gpt-6-astra") == "codex_responses"+ assert _hermes_api_mode("azure-foundry", "gpt-5.4") == "codex_responses"+ assert _hermes_api_mode("azure-foundry", "gpt-4o") is None+ assert _hermes_api_mode("openai-api", "gpt-6-astra") == "codex_responses"+ assert _hermes_api_mode("bedrock", "gpt-6-astra") is None and _hermes_api_mode("openrouter", "openai/gpt-6-astra") is Nonediff --git a/scripts/support-matrix/run.mjs b/scripts/support-matrix/run.mjsindex 6a28cdf5..f4c63af9 100644--- a/scripts/support-matrix/run.mjs+++ b/scripts/support-matrix/run.mjs@@ -149,6 +149,8 @@ try {await sleep(2000);const r5 = await turn('What exact word did I ask you to reply with in my very first message of this task? Reply with just that word.');rec.recycle = expectWord(r5, `M1-${m}`); rec.recycle.recycled = rc;+ // a recall that reads the lost-history note as its answer is a failed resume, on every harness+ if (rec.recycle.ok && /no longer available to Codex|could not be restored/i.test(rec.recycle.tail || '')) rec.recycle = { ...rec.recycle, ok: false, why: 'resumed without its history: ' + rec.recycle.tail.slice(-160) };} else rec.recycle = { ok: false, s: 0, why: `recycle refused: HTTP ${rc.code} ${rc.body}`, recycled: rc };log(`RECYCLE ${k} ${rec.recycle.ok ? 'ok' : 'FAIL'} ${rec.recycle.s}s ${rec.recycle.why}`);} else { rec.followup = { ok: null, why: 'first turn failed' }; rec.switch = { ok: null, why: 'first turn failed' }; rec.artifact = { ok: null, why: 'first turn failed' }; rec.recycle = { ok: null, why: 'first turn failed' }; }