diff --git a/benchmarks/harbor-buzz-orchestra/src/harbor_buzz_orchestra/accounting.py b/benchmarks/harbor-buzz-orchestra/src/harbor_buzz_orchestra/accounting.py index b3820da0b7..6cf07b78e9 100644 --- a/benchmarks/harbor-buzz-orchestra/src/harbor_buzz_orchestra/accounting.py +++ b/benchmarks/harbor-buzz-orchestra/src/harbor_buzz_orchestra/accounting.py @@ -84,8 +84,12 @@ _ANSI_RE = re.compile(r"\x1b\[[0-9;]*[a-zA-Z]") # fields) degrades to "no samples" rather than a wrong number. USAGE_MARKER = "goose usage update" _SESSION_RE = re.compile(r"\bsession_id=(\S+)") -_INPUT_RE = re.compile(r"\binput=(\d+)\b") -_OUTPUT_RE = re.compile(r"\boutput=(\d+)\b") +# Older buzz-acp builds render cumulative counters as `input=123`; current +# builds retain their optional type in the tracing field and render +# `input=Some(123)`. Accept both representations so a source update cannot make +# a real, billed run look like zero usage. +_INPUT_RE = re.compile(r"\binput=(?:Some\()?(\d+)(?:\))?") +_OUTPUT_RE = re.compile(r"\boutput=(?:Some\()?(\d+)(?:\))?") # The cache-served subset of `input`, added to the usage line by buzz-acp. Absent # in logs written by an agent build that predates it, which is why a missing # field must read as "unknown" (fall back to the modelled rate) and never as 0 — diff --git a/benchmarks/harbor-buzz-orchestra/tests/test_accounting.py b/benchmarks/harbor-buzz-orchestra/tests/test_accounting.py index 7cde72492b..e126e235d4 100644 --- a/benchmarks/harbor-buzz-orchestra/tests/test_accounting.py +++ b/benchmarks/harbor-buzz-orchestra/tests/test_accounting.py @@ -64,6 +64,16 @@ def test_parse_usage_log_reads_the_coloured_lines_a_real_trial_produces(): ) +def test_parse_usage_log_reads_optional_counters_from_current_buzz_acp(): + text = ( + "2026-08-18T23:25:39Z DEBUG acp::usage: goose usage update " + "session_id=ses_current input=Some(5738) output=Some(1802) cached=0" + ) + assert accounting.parse_usage_log(text) == ( + accounting.SessionUsage("ses_current", 5738, 1802, 0), + ) + + def test_parse_handoffs_reads_coloured_lines_too(): """Same formatter, same escapes — the compaction bound must not silently zero.""" text = (