usage
usage
¶
Read a harness's per-session usage record after an interactive sheet.
Interactive (tmux) sessions have no JSON stdout to parse, so token usage is
recovered from the record the harness itself writes for the session. The
profile's cli.interactive.usage block says where that record lives and how
to read it; nothing here is specific to one harness.
Safety contract: the file is streamed line by line (never loaded whole), malformed lines are skipped, and no message content is ever logged or kept — only integer token counts and a model name leave this module.
Classes¶
UsageReading
dataclass
¶
Functions:¶
unmeasured
¶
resolve_record_path
¶
Expand ~ and {session_id}; return the newest matching file.
Source code in src/marianne/execution/instruments/interactive/usage.py
read_usage_file
¶
Stream path and total one usage entry per dedupe key.
A response can be written as several lines sharing a dedupe key; the LAST one carries the final counts, so earlier ones are overwritten. Lines with no dedupe key count individually. Sidechain (subagent) lines are included when they are in the same file.
Source code in src/marianne/execution/instruments/interactive/usage.py
apply_usage
¶
Fill the result's token fields, or mark it unmeasured (never zero).
Unmeasured travels through usage_unmeasured, which the musician folds
into the existing cost_uncertain flag that mzt status renders.
Source code in src/marianne/execution/instruments/interactive/usage.py
read_session_usage
¶
Blocking read for one session; callers run it via asyncio.to_thread.