openhands.core.message_utils
get_token_usage_for_event
def get_token_usage_for_event(event: Event,
metrics: Metrics) -> TokenUsage | None
Returns at most one token usage record for the model_response.id
in this event's
tool_call_metadata
.
If no response_id is found, or none match in metrics.token_usages, returns None.
get_token_usage_for_event_id
def get_token_usage_for_event_id(events: list[Event], event_id: int,
metrics: Metrics) -> TokenUsage | None
Starting from the event with .id == event_id and moving backwards in events
,
find the first TokenUsage record (if any) associated with a response_id from
tool_call_metadata.model_response.id.
Returns the first match found, or None if none is found.