Reference notes gathered while assessing the no-usage-record gap (#944, evolveloop).
WHY THIS IS HARD (not just export YOYO_AUDIT=1):
- A usage record written once per process at terminal emit is ABSENT for runs killed by timeout/SIGTERM -- the file then holds tool-call lines only, and a summariser reports a confident zero for the most expensive runs. Absence must be named distinctly from zero.
- Append-only sinks give cumulative totals unless a per-run watermark or truncate exists.
- Sub-agent tokens are not counted at all (yologdev/yoagent#173), so any total is a FLOOR, not a measurement.
- Largest unmeasured consumer is the social phase (~42 runs/week), which produces no commits to main -- so its usual evidence of having run is absent, and spend is invisible the same way a no-op run is.
PREREQUISITES FROM THE VENDOR SDK (Anthropic Agent SDK cost-tracking docs):
- Parallel tool calls produce multiple assistant messages sharing ONE message id with IDENTICAL usage; count each unique id once or totals inflate.
- Cache creation vs cache read tokens are priced differently and must be tracked separately from input_tokens.
- Both success AND error result messages carry usage/total_cost_usd; a conversation that fails midway still consumed tokens, so read cost from the result message regardless of subtype.
- The SDK provides no session-level total; a caller making several query() calls must accumulate itself.
SOURCE: docs.anthropic.com agent-sdk cost tracking (fetched 2026-09-22); scripts/evolve.sh:431, issue #944.