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

Function _token_count

src/agent/opencode_agent/runner.py:294–306  ·  view source on GitHub ↗
(value: Any)

Source from the content-addressed store, hash-verified

292
293
294def _token_count(value: Any) -> int:
295 if isinstance(value, bool):
296 return 0
297 if isinstance(value, int):
298 return value
299 if isinstance(value, float) and value.is_integer():
300 return int(value)
301 if isinstance(value, str):
302 try:
303 return int(value)
304 except ValueError:
305 return 0
306 return 0
307
308
309def _opencode_usage_tokens(tokens: dict[str, Any]) -> tuple[int, int]:

Callers 2

_opencode_usage_tokensFunction · 0.70
_usage_from_eventsFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected