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
produced files: the turn's total counts what it produced, not the inputs the caller attached (#555)
Rudy Mizrahi Celekli0df1d3c86aca
diff --git a/gateway/app.py b/gateway/app.pyindex 042ca1ce..7a9935a7 100644--- a/gateway/app.py+++ b/gateway/app.py@@ -8527,7 +8527,13 @@ async def _collect_produced(sid: str, exclude: set[str] | None = None) -> list[ditems = (r.json() or {}).get("files") or []except Exception: # noqa: BLE001return []- _produced_total[sid] = len([it for it in items if (it or {}).get("path")+ # The same two filters the selection below applies, for the same reason: the total is a count of+ # what the turn PRODUCED, so an internal name and an input file the caller attached are both out+ # of it. Counting the attachments made a one-file turn carrying one input report a total of 2,+ # and the console's banner read "Showing 1 of 2" with nothing else to show.+ _produced_total[sid] = len([it for it in items+ if (it or {}).get("path")+ and _produced_rel(it["path"]) not in excludeand not _is_internal_output(_produced_rel(it["path"]))])out: list[dict] = []# The response carries at most RESP_MAX_FILES of them. Newest first when the runner says whendiff --git a/gateway/tests/test_produced_total.py b/gateway/tests/test_produced_total.pyindex 9ee1ec12..2d99dcf9 100644--- a/gateway/tests/test_produced_total.py+++ b/gateway/tests/test_produced_total.py@@ -85,3 +85,54 @@ def test_the_changed_listing_serves_the_turns_total_beside_the_captured_count(apjson.dumps({"at": 1.0, "files": files}).encode(), kb=gw.RESP_BLOB_KB))d = api.get(f"/v1/sessions/{sid}/files?changed=true").json()assert d["count"] == 2 and d["produced"] == 2+++def test_the_total_counts_what_the_turn_produced_and_not_the_inputs_it_carried(monkeypatch):+ """The caller's attached input files are in the runner's /produced listing (the agent's working+ directory holds them), and the selection below already sets them aside via `exclude` — but the+ total was counted before that filter, so it counted them as produced. A turn carrying one input+ and producing one file reported 2, and the console's banner read "Showing 1 of 2" with nothing+ else to show. The existing test above calls _collect_produced with NO exclude, which is why the+ gap survived. A case with no attached input is kept here so the filter cannot under-count an+ ordinary turn."""+ listed: list[dict] = []+ stored: dict[str, bytes] = {}++ async def _sandbox(path, s, method, body=None, params=None):+ if path == "/produced":+ return _Resp(200, json.dumps({"files": listed}).encode())+ return _Resp(200, b"{}")++ async def _file(s, path, cap):+ return 200, b"bytes", "text/plain", 5++ async def _blob_put(key, data, kb=0):+ stored[key] = data+ return True+ monkeypatch.setattr(gw, "_sandbox", _sandbox)+ monkeypatch.setattr(gw, "_blob_put", _blob_put)+ monkeypatch.setattr(gw, "_sandbox_file", _file)+ monkeypatch.setattr(gw, "RESP_MAX_FILES", 25)++ # N = 1 attached input, M = 1 produced file: the total is M, not M + N+ sid = "hsessprod" + os.urandom(4).hex()+ listed[:] = [{"path": "data.csv", "mtime": 1_700_000_000},+ {"path": "report.md", "mtime": 1_700_000_001}]+ out = asyncio.run(gw._collect_produced(sid, {"data.csv"}))+ assert [o["filename"] for o in out] == ["report.md"]+ assert gw._produced_total[sid] == 1++ # N = 2, M = 3, with an internal name beside them that was already excluded+ sid = "hsessprod" + os.urandom(4).hex()+ listed[:] = [{"path": "in/a.csv", "mtime": 1}, {"path": "in/b.csv", "mtime": 2},+ {"path": "AGENTS.md", "mtime": 3},+ {"path": "r1.txt", "mtime": 4}, {"path": "r2.txt", "mtime": 5},+ {"path": "r3.txt", "mtime": 6}]+ asyncio.run(gw._collect_produced(sid, {"in/a.csv", "in/b.csv"}))+ assert gw._produced_total[sid] == 3++ # no attached inputs: the count is every produced file, capped response or not+ sid = "hsessprod" + os.urandom(4).hex()+ listed[:] = [{"path": f"f{i:03d}.txt", "mtime": 1_700_000_000 + i} for i in range(30)]+ out = asyncio.run(gw._collect_produced(sid, set()))+ assert len(out) == 25 and gw._produced_total[sid] == 30