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: newest first when a turn made more than a response carries (#273)
github-actions[bot]311aefac13fd
diff --git a/gateway/app.py b/gateway/app.pyindex 74b4b85d..488e7356 100644--- a/gateway/app.py+++ b/gateway/app.py@@ -6898,6 +6898,11 @@ async def _collect_produced(sid: str, exclude: set[str] | None = None) -> list[dexcept Exception: # noqa: BLE001return []out: list[dict] = []+ # The response carries at most RESP_MAX_FILES of them. Newest first when the runner says when+ # each was written (the item's mtime), so a turn that produced a long series (a game's 1,400+ # archived frames, hosted 2026-09-25) shows its latest and not its first second; a runner+ # without the field keeps its own order. The console says how many there were in all.+ items = sorted(items, key=lambda it: float((it or {}).get("mtime") or 0), reverse=True)for it in items[:RESP_MAX_FILES]:path = (it or {}).get("path")if not path:diff --git a/runner/server.py b/runner/server.pyindex 750e1c23..9e8b2b9d 100644--- a/runner/server.py+++ b/runner/server.py@@ -7130,7 +7130,15 @@ def _produced_list(ws: str) -> list[dict]:path = path.strip().strip('"')if _produced_keep(status, path):seen.setdefault(path, status.strip() or "?")- return [{"path": k, "status": v} for k, v in seen.items()]+ # mtime rides on each item so a reader can put the newest first: a response carries at most+ # HARNESS_RESP_MAX_FILES of them, and git's path order handed a Mario run its first 24 frames+ # of 1,400 (hosted, 2026-09-25). 0 when the file is gone (a deletion) or cannot be stat'ed.+ def _mtime(rel: str) -> float:+ try:+ return float(os.stat(os.path.join(ws, rel)).st_mtime)+ except OSError:+ return 0.0+ return [{"path": k, "status": v, "mtime": _mtime(k)} for k, v in seen.items()]def _produced_ack(ws: str) -> str:diff --git a/runner/tests/test_produced_cursor.py b/runner/tests/test_produced_cursor.pyindex 9235278c..3740d856 100644--- a/runner/tests/test_produced_cursor.py+++ b/runner/tests/test_produced_cursor.py@@ -64,3 +64,21 @@ def test_a_deleted_file_is_not_offered():_git(d, "add", "-A")_git(d, "commit", "-q", "-m", "checkpoint")assert _produced_list(d) == []+++def test_each_produced_item_says_when_it_was_written():+ """A response carries at most HARNESS_RESP_MAX_FILES produced files, and the gateway puts the+ newest first by this field (a Mario run's 1,400 frames showed its first 24 without it,+ hosted 2026-09-25). A deletion is never a produced file, so the field is only ever a real time."""+ import os+ d = _ws()+ (pathlib.Path(d) / "old.txt").write_text("old")+ (pathlib.Path(d) / "new.txt").write_text("new")+ os.utime(pathlib.Path(d) / "old.txt", (1_700_000_000, 1_700_000_000))+ by = {f["path"]: f for f in _produced_list(d)}+ assert by["old.txt"]["mtime"] == 1_700_000_000.0+ assert by["new.txt"]["mtime"] > by["old.txt"]["mtime"]+ # the field survives a checkpoint: the file is still on disk, the time is still its own+ _git(d, "add", "-A")+ _git(d, "commit", "-q", "-m", "checkpoint")+ assert {f["path"]: f["mtime"] for f in _produced_list(d)}["old.txt"] == 1_700_000_000.0diff --git a/ui/src/app/hr.css b/ui/src/app/hr.cssindex 0038f5a3..1c3be774 100644--- a/ui/src/app/hr.css+++ b/ui/src/app/hr.css@@ -354,6 +354,7 @@ a { color: inherit; text-decoration: none; }/* output file cards (under the answer) */.wbx-files { display: flex; flex-direction: column; gap: 8px; margin-top: 12px; max-width: 560px; }+.wbx-files-more { font-size: 12px; color: var(--muted, #6b6560); margin: 2px 0 4px; }/* One-click "everything from this turn" zip row under the file cards. */.wbx-zipall { display: inline-flex; align-items: center; gap: 7px; align-self: flex-start;font-size: 12.5px; font-weight: 600; font-family: inherit; color: var(--brand); padding: 6px 12px;diff --git a/ui/src/components/ChatAttachments.tsx b/ui/src/components/ChatAttachments.tsxindex 345f01d8..0fc2348e 100644--- a/ui/src/components/ChatAttachments.tsx+++ b/ui/src/components/ChatAttachments.tsx@@ -5,9 +5,13 @@// own thinner versions instead of these: a text pill with an × where an image thumbnail belongs,// and a bare row where the output card belongs. One definition, so a column in an arena is the// same card as a task, because it is the same card.-import React, { useState } from 'react';+import React, { useEffect, useState } from 'react';import { FileTypeIcon } from '@/components/FileTypeIcon';import { containerFileUrl, downloadFile, type RespFile } from '@/lib/chat';+import { harnessFetch } from '@/lib/hfetch';++// What a response lists at most (the gateway's HARNESS_RESP_MAX_FILES); a full list may be a cut.+const LISTED_MAX = 25;const Svg = ({ s = 16, children }: { s?: number; children: React.ReactNode }) => (<svg width={s} height={s} viewBox="0 0 24 24" fill="none" stroke="currentColor"@@ -41,11 +45,25 @@ export function OutputFiles({ files, onPreview }: {}) {// the archive is refused, with the names, when a cited file is no longer there; the row says soconst [zipErr, setZipErr] = useState('');+ // How many files the turn really produced when the list is full: the session's own count of+ // the files changed in its most recent turn. Absent until read; nothing is shown before then.+ const [total, setTotal] = useState<number | null>(null);+ const sid = files[0]?.container_id || '';+ useEffect(() => {+ if (!sid || files.length < LISTED_MAX) { setTotal(null); return; }+ let alive = true;+ harnessFetch(`/api/harness/v1/sessions/${encodeURIComponent(sid)}/files?changed=true`, { cache: 'no-store' })+ .then((r) => (r.ok ? r.json() : null)).then((d: { count?: number } | null) => { if (alive && d && typeof d.count === 'number') setTotal(d.count); })+ .catch(() => undefined);+ return () => { alive = false; };+ }, [sid, files.length]);if (!files.length) return null;+ const more = total !== null && total > files.length;const zipUrl = `/api/harness/v1/sessions/${encodeURIComponent(files[0].container_id)}`+ `/files/archive?files=${encodeURIComponent(files.map((f) => f.file_id).join(','))}`;return (<div className="wbx-files">+ {more && <div className="wbx-files-more">Showing {files.length} of the {total.toLocaleString()} files this turn produced.</div>}{files.map((f, j) => (<div key={j} className="wbx-filecard"onClick={() => onPreview({ url: containerFileUrl(f), name: f.filename })}>