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
runner: nanobot's shell gets the turn's own settings; base state stays out of the checkpoint repo (#460)
github-actions[bot]b8f2685fb892
diff --git a/runner/server.py b/runner/server.pyindex c86547c8..930c3717 100644--- a/runner/server.py+++ b/runner/server.py@@ -930,6 +930,9 @@ def _git(ws: str, *args: str, check: bool = False, env: dict | None = None) -> s# Config the runner rewrites every turn and that can carry MCP credentials (see CHECKPOINT_EXCLUDE)._PER_TURN_CONFIG = (".harness/opencode.json", ".harness/kilo.json", ".harness/mcp.json",".harness/mcp-bridge/")+# A base's own state directory outside the CLI home, which it rewrites on every turn (see+# _git_ensure). Not in the checkpoint repo; in the tar like .harness/home.+_STATE_DIRS = (".harness/nanobot/", ".harness/opensquilla/", ".harness/goose/")def _git_ensure(ws: str) -> None:@@ -968,6 +971,13 @@ def _git_ensure(ws: str) -> None:# prompt (ctx_window) on every save, so committing it would put a new copy of the system# prompt into .git/objects each turn. It travels in the tar like the CLI home does.".harness/agentzero/",+ # The same for every base whose own store changes on each turn: committed, each turn put+ # a new copy of the whole store into .git/objects. MEASURED on 0.33.0 (2026-10-14): a+ # 15-turn opensquilla session had an 8.3 MB .git for 4 MB of state (its SQLite stores,+ # transcript and logs in every commit); goose committed its sessions.db WAL and its raw+ # request logs, nanobot its whole conversation file, on every turn. They travel in the+ # tar instead, which carries the session's whole tree.+ *_STATE_DIRS,"",]))if not (p / ".git").exists():@@ -982,6 +992,7 @@ def _git_ensure(ws: str) -> None:# The same for the per-turn config files: a session checkpointed before they were ignored# tracks them, and an ignore rule alone would keep committing each turn's credentials._git(ws, "rm", "-r", "-q", "--cached", "--ignore-unmatch", "--", *_PER_TURN_CONFIG)+ _git(ws, "rm", "-r", "-q", "--cached", "--ignore-unmatch", "--", *_STATE_DIRS)tracked = bool(_git(ws, "ls-files", "--", ".harness/home").stdout.strip())if tracked:_git(ws, "rm", "-r", "-q", "--cached", "--ignore-unmatch", "--", ".harness/home")@@ -10336,6 +10347,20 @@ ALL_NANOBOT_TOOLS = (# an allow-list and a PATH prepend, so the layer is handed to it by name._ENV_LAYER_KEYS = ("PROJECT_ROOT", "HR_ENVIRONMENT", "PYTHONPATH", "VIRTUAL_ENV", "NODE_PATH","LD_LIBRARY_PATH")+# The names the runner itself puts on a turn for the agent's shell to use: the image skill's+# per-turn broker credential (HR_IMAGE_*, see run_turn) and, on a harness that drives another, the+# platform API and its calibration credential. Every base whose shell inherits the turn's+# environment has them; one that builds its own (nanobot) must be told. MEASURED on 0.33.0+# (2026-10-14): nanobot found the imagegen script and it answered "image generation is not+# configured for this Harness", with the integration in place and pi making the same image.+# And the image's own setting for its Office tool: OFFICECLI_RESIDENT_FLUSH=each makes every officecli+# command write through to disk (the Dockerfile sets it, the officecli skill relies on it). Without+# it officecli keeps the document open in a background process and writes it only once that process+# goes idle; MEASURED on zeroclaw (2026-10-14), a ten-second deck turn ended first, and seven decks+# were handed back as the empty file `officecli create` had made. nanobot's shell lacked it too.+_TURN_SHELL_KEYS = ("HR_IMAGE_BASE_URL", "HR_IMAGE_KEY", "HR_IMAGE_MODEL",+ "HR_API_URL", "HR_INNER_HARNESS", "HR_CALIBRATION_TOKEN",+ "OFFICECLI_RESIDENT_FLUSH")def _nanobot_exec_env(env: dict, caller_keys: list[str] | tuple = ()) -> dict:@@ -10349,6 +10374,7 @@ def _nanobot_exec_env(env: dict, caller_keys: list[str] | tuple = ()) -> dict:link = str(env.get("HR_ENVIRONMENT") or "").strip()keys = [k for k in _ENV_LAYER_KEYS if link and env.get(k)]keys += [k for k in caller_keys if env.get(k) is not None and k not in keys]+ keys += [k for k in _TURN_SHELL_KEYS if env.get(k) and k not in keys]# the layer's own PATH entries, taken as the ones under its directory rather than by# reconstructing what apply_env decided to addprepend = [x for x in str(env.get("PATH") or "").split(":") if x.startswith(link + "/")] if link else []diff --git a/runner/tests/test_batch3_backends.py b/runner/tests/test_batch3_backends.pyindex cea73d6c..4c768fc9 100644--- a/runner/tests/test_batch3_backends.py+++ b/runner/tests/test_batch3_backends.py@@ -1370,3 +1370,17 @@ def test_nanobots_shell_gets_the_harnesss_own_variables_by_name():assert ex["allowedEnvKeys"] == ["STAMP_NONCE", "HR_API_URL"] # names only, none that is unsetassert "n-123" not in text # the value stays in the environmentassert "pathPrepend" not in ex # no environment layer, no PATH entry+++def test_nanobots_shell_gets_the_turns_image_credential_by_name():+ """The image skill reads HR_IMAGE_* from the shell; nanobot's shell had none of them and the+ skill answered "image generation is not configured for this Harness" (0.33.0, 2026-10-14)."""+ d = _ws()+ env = {"HR_IMAGE_BASE_URL": "http://127.0.0.1:8080/v1/llm", "HR_IMAGE_KEY": "hrtc-turn", "HR_IMAGE_MODEL": "gpt-image-2",+ "OFFICECLI_RESIDENT_FLUSH": "each"}+ _build_nanobot("openai-api", Auth(api_key="k", base_url=UP), "gpt-5.4", "hi", d, env)+ text = pathlib.Path(d, ".harness", "nanobot", "config.json").read_text()+ # and officecli's write-through: without it a short deck turn handed back an empty deck+ assert json.loads(text)["tools"]["exec"]["allowedEnvKeys"] == ["HR_IMAGE_BASE_URL", "HR_IMAGE_KEY", "HR_IMAGE_MODEL",+ "OFFICECLI_RESIDENT_FLUSH"]+ assert "hrtc-turn" not in text # names onlydiff --git a/runner/tests/test_workspace_cli_home_not_tracked.py b/runner/tests/test_workspace_cli_home_not_tracked.pyindex 0b5a558b..3fa3b311 100644--- a/runner/tests/test_workspace_cli_home_not_tracked.py+++ b/runner/tests/test_workspace_cli_home_not_tracked.py@@ -163,3 +163,31 @@ def test_an_index_released_but_a_tip_not_yet_rewritten_still_sheds_and_only_oncehead = _git(str(d), "rev-parse", "HEAD").stdout.strip()_git_ensure(str(d)) # and it does not run twiceassert _git(str(d), "rev-parse", "HEAD").stdout.strip() == head+++def test_a_bases_own_state_stays_out_of_the_repo_and_an_old_session_lets_go_of_it():+ """nanobot's conversation file, opensquilla's stores and logs, goose's session database: each+ rewritten on every turn, so a commit per turn put a new copy of each into .git/objects (a+ 15-turn opensquilla session: 8.3 MB of .git for 4 MB of state, 2026-10-14). They ride the tar."""+ d = pathlib.Path(tempfile.mkdtemp())+ _git_ensure(str(d))+ (d / "out.txt").write_text("deliverable")+ state = [d / ".harness" / "nanobot" / "sessions" / "w" / "k.jsonl",+ d / ".harness" / "opensquilla" / "sessions.sqlite",+ d / ".harness" / "goose" / "data" / "sessions" / "sessions.db"]+ for f in state:+ f.parent.mkdir(parents=True, exist_ok=True)+ f.write_bytes(b"\x01" * 256)+ _git(str(d), "add", "-A")+ _git(str(d), "commit", "-q", "-m", "checkpoint")+ tracked = _git(str(d), "ls-files").stdout.split()+ assert "out.txt" in tracked and not any(p.startswith((".harness/nanobot", ".harness/opensquilla", ".harness/goose")) for p in tracked)+ # a session checkpointed before the rule tracks them; the next _git_ensure releases them+ subprocess.run(["git", "-C", str(d), "add", "-f", "--", *[str(f.relative_to(d)) for f in state]], check=True)+ subprocess.run(["git", "-C", str(d), "commit", "-q", "-m", "old checkpoint"], check=True)+ _git_ensure(str(d))+ _git(str(d), "add", "-A")+ _git(str(d), "commit", "-q", "-m", "next checkpoint")+ tracked = _git(str(d), "ls-files").stdout.split()+ assert "out.txt" in tracked and not any(p.startswith(".harness/") for p in tracked), tracked+ assert all(f.exists() for f in state) # released from the index, not from disk