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(gateway): bill media generation spend as media.usd, once per finished job
richard-epsilla7160c1273555
diff --git a/gateway/app.py b/gateway/app.pyindex fb0358b4..a7abbec9 100644--- a/gateway/app.py+++ b/gateway/app.py@@ -9091,9 +9091,24 @@ def _media_job_out(v: dict | None) -> dict | None:async def _media_job_save(job: dict) -> None:job["updated_at"] = int(time.time() * 1000)+ _media_meter_once(job)await _vg_upsert(_MEDIA_JOB_LABEL, job["id"], _media_job_props(job))+def _media_meter_once(job: dict) -> None:+ """Bill a finished media job exactly once: what the winning render cost plus every failed+ candidate that billed upstream (banked in billed_usd). Pass-through at the provider's price+ as one `media.usd` meter, the same rule as tokens. Reported the moment the job goes terminal;+ the flag is a job property, so a later save of the same job never reports it twice."""+ if job.get("status") not in ("succeeded", "failed") or str(job.get("metered") or "") == "1":+ return+ won = float(job.get("usd") or 0.0) if job.get("status") == "succeeded" else 0.0+ total = round(won + float(job.get("billed_usd") or 0.0), 6)+ job["metered"] = "1"+ if total > 0 and job.get("org"):+ _report_usage(str(job["org"]), "media.usd", total)++async def _media_job_get(jid: str) -> dict | None:if not jid or not jid.startswith("mjob_"):return None