Return input/output totals from OpenCode's step-finish token schema.
(tokens: dict[str, Any])
| 307 | |
| 308 | |
| 309 | def _opencode_usage_tokens(tokens: dict[str, Any]) -> tuple[int, int]: |
| 310 | """Return input/output totals from OpenCode's step-finish token schema.""" |
| 311 | cache = tokens.get("cache") if isinstance(tokens.get("cache"), dict) else {} |
| 312 | input_tokens = ( |
| 313 | _token_count(tokens.get("input")) |
| 314 | + _token_count(cache.get("read")) |
| 315 | + _token_count(cache.get("write")) |
| 316 | ) |
| 317 | output_tokens = _token_count(tokens.get("output")) + _token_count( |
| 318 | tokens.get("reasoning") |
| 319 | ) |
| 320 | return input_tokens, output_tokens |
| 321 | |
| 322 | |
| 323 | def _usage_from_events(events: list[dict[str, Any]]) -> tuple[int, int]: |
no test coverage detected