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
0.17.1: goose temp files in the workspace, a failed turn shows the CLI's last lines (#174)
github-actions[bot]f5b9d51a5545
diff --git a/gateway/app.py b/gateway/app.pyindex 62e6766c..01714735 100644--- a/gateway/app.py+++ b/gateway/app.py@@ -6874,7 +6874,9 @@ async def _resp_execute(translator: _RespTranslator, *, org: str, member: str, s# event's message); its `result` is the answer so far, which a failed turn# may still carry. Reason first: a Gemini CLI turn that failed as a# substitution showed its finished answer as the error (2026-09-07).- "error": (s.get("error") or s.get("result") or "")[:200]})+ # 2000, not 200: a CLI panic names its file after the first 200+ # characters and 200 cut goose's tmp-dir panic at its path (2026-09-13).+ "error": (s.get("error") or s.get("result") or "")[:2000]})break_last_err = str(rec["tried"][-1].get("error") or "") if rec["tried"] else ""if (not terminal and rec["tried"] and rec["tried"][-1].get("connection") == namediff --git a/gateway/tests/test_gemini_backend.py b/gateway/tests/test_gemini_backend.pyindex 5e710a02..453d91a3 100644--- a/gateway/tests/test_gemini_backend.py+++ b/gateway/tests/test_gemini_backend.py@@ -51,5 +51,5 @@ def test_tokenrouter_drives_the_gemini_backend_for_the_ids_it_serves():def test_the_failed_turn_reason_is_the_runners_error_before_its_result():src = Path(gw.__file__).read_text()- assert '"error": (s.get("error") or s.get("result") or "")[:200]' in src+ assert '"error": (s.get("error") or s.get("result") or "")[:2000]' in srcassert '"native_model": ((conn.get("model") if conn.get("_model_resolved") else _map_model(conn, model_req))' in srcdiff --git a/runner/server.py b/runner/server.pyindex 24117647..ce98c61c 100644--- a/runner/server.py+++ b/runner/server.py@@ -4365,6 +4365,12 @@ def _build_goose(provider: str, auth: Auth, model: str, prompt: str, cwd: str, eroot.mkdir(parents=True, exist_ok=True)host, base_path = _goose_split_base(auth.base_url or "")env["GOOSE_PATH_ROOT"] = str(root)+ # goose's platform-extension loader writes a temp file through std::env::temp_dir() at start+ # (crates/goose/src/agents/platform_extensions/mod.rs, v1.50.0) and panics when it cannot:+ # on a host whose sandbox refuses /tmp every turn exited 1 right after "goose is ready"+ # (hosted, 2026-09-13). The workspace's own tmp, the same thing codex gets.+ env["TMPDIR"] = str(pathlib.Path(cwd) / "tmp")+ pathlib.Path(env["TMPDIR"]).mkdir(parents=True, exist_ok=True)env["OPENAI_API_KEY"] = auth.api_key or ""env["OPENAI_HOST"] = hostenv["OPENAI_BASE_PATH"] = base_path@@ -4775,15 +4781,28 @@ def _run_turn_bg(turn_id: str, cmd: list[str], env: dict, cwd: str, normalize, mif rec["status"] in ("failed", "error", "timeout"):tail = "\n".join(errbuf[-30:]).strip()ev_err = (result_ev or {}).get("result") or (result_ev or {}).get("error") or ""- # The provider's refusal is the line that explains a failure; the CLI's last lines are- # usually its retries ("Reconnecting... 1/5"). Say the refusal when there is one.refusal = next((ln.strip() for ln in errbuf if _PROVIDER_REFUSAL.search(ln)), "")- rec["error"] = (refusal or str(ev_err).strip() or tail or f"exit_code={rc}, no diagnostic output")[:2000]+ rec["error"] = _failure_reason(refusal, str(ev_err), tail, rc)if result_ev is not None and not str(result_ev.get("result") or "").strip() and tail:result_ev["result"] = tail[:2000] # so the trace's result event isn't empty eitherrec["done"] = True+_NO_DIAGNOSTIC_RE = re.compile(r"\w[\w-]* exited -?\d+ without reporting an error")+++def _failure_reason(refusal: str, ev_err: str, tail: str, rc: int) -> str:+ """The one line that explains a failed turn, in order of how much it says: the provider's+ refusal, the result event's own message, the CLI's last lines, the exit code. A normaliser's+ "<cli> exited N without reporting an error" says nothing the CLI's last lines do not, so those+ lines win over it: goose's tokio panic ("Permission denied (os error 13) at path /tmp/...")+ sat in the stderr behind that sentence and the record never showed it (2026-09-13)."""+ ev_err = ev_err.strip()+ if tail and _NO_DIAGNOSTIC_RE.fullmatch(ev_err):+ ev_err = ""+ return (refusal or ev_err or tail or f"exit_code={rc}, no diagnostic output")[:2000]++# Codex app-server JSON-RPC driver — the ONLY codex mode that streams assistant text (via# item/agentMessage/delta). Flag-gated; the default codex path stays `codex exec` (batch). We run# one turn per app-server process (spawn -> initialize -> thread start/resume -> turn -> done), adiff --git a/runner/tests/test_failure_reason.py b/runner/tests/test_failure_reason.pynew file mode 100644index 00000000..5837f51f--- /dev/null+++ b/runner/tests/test_failure_reason.py@@ -0,0 +1,22 @@+import os+import sys++sys.path.insert(0, os.path.join(os.path.dirname(__file__), ".."))+from server import _failure_reason # noqa: E402++PANIC = "thread 'tokio-rt-worker' panicked at crates/goose/src/agents/platform_extensions/mod.rs:178:90:\ncalled `Result::unwrap()` on an `Err` value: Permission denied (os error 13) at path \"/tmp/.tmpAb12\"\nError: Extension loading task failed"+++def test_the_clis_last_lines_outrank_a_normalisers_no_diagnostic_sentence():+ assert _failure_reason("", "goose exited 1 without reporting an error", PANIC, 1) == PANIC+ assert _failure_reason("", "opencode exited 2 without reporting an error", "boom", 2) == "boom"+++def test_a_real_result_message_and_a_refusal_still_come_first():+ assert _failure_reason("", "the provider declined the request (finish_reason content_filter)", PANIC, 1).startswith("the provider declined")+ assert _failure_reason("HTTP 401: bad key", "goose exited 1 without reporting an error", PANIC, 1) == "HTTP 401: bad key"+++def test_without_any_lines_the_sentence_and_then_the_exit_code_remain():+ assert _failure_reason("", "goose exited 1 without reporting an error", "", 1) == "goose exited 1 without reporting an error"+ assert _failure_reason("", "", "", 3) == "exit_code=3, no diagnostic output"diff --git a/runner/tests/test_goose_build.py b/runner/tests/test_goose_build.pyindex 3dff2eb2..a5c95901 100644--- a/runner/tests/test_goose_build.py+++ b/runner/tests/test_goose_build.py@@ -131,6 +131,14 @@ def test_everything_lives_under_the_harness_dir():assert ".harness" in root.parts+def test_temp_files_go_to_the_workspace():+ """goose's extension loader writes a temp file through std::env::temp_dir() at start and panics+ when it cannot; a sandbox that refuses /tmp failed every turn (hosted, 2026-09-13)."""+ _, d, env = _argv()+ assert env["TMPDIR"] == str(pathlib.Path(d) / "tmp")+ assert pathlib.Path(env["TMPDIR"]).is_dir()++def test_config_names_the_provider_and_model():_, d, env = _argv()cfg = yaml.safe_load((pathlib.Path(env["GOOSE_PATH_ROOT"]) / "config" / "config.yaml").read_text())