MCPcopy Index your code
hub / github.com/IBM/AssetOpsBench / _opencode_usage_tokens

Function _opencode_usage_tokens

src/agent/opencode_agent/runner.py:309–320  ·  view source on GitHub ↗

Return input/output totals from OpenCode's step-finish token schema.

(tokens: dict[str, Any])

Source from the content-addressed store, hash-verified

307
308
309def _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
323def _usage_from_events(events: list[dict[str, Any]]) -> tuple[int, int]:

Callers 1

_usage_from_eventsFunction · 0.85

Calls 2

_token_countFunction · 0.70
getMethod · 0.45

Tested by

no test coverage detected