fix(proxy): tolerate a StandardLoggingPayload without total_tokens

Some call types (e.g. aretrieve_batch) build a payload without total_tokens,
so indexing it raised KeyError and tripped the cost-tracking error path. Read
it with a .get default of 0 like the DB-side write, suppressing just the one
overload-unknown diagnostic with a reason.
This commit is contained in:
Srivatsa03 2026-10-11 22:57:34 -05:00
parent f949f1735b
commit fe6edbef4c

View file

@ -741,7 +741,9 @@ def _extract_total_tokens(sl_object: StandardLoggingPayload | None) -> int:
"""
if sl_object is None:
return 0
return sl_object["total_tokens"]
return sl_object.get( # pyright: ignore[reportUnknownMemberType] # StandardLoggingPayload.get overload is partially unknown; total_tokens is a required int
"total_tokens", 0
)
async def _update_database_and_spend_counters(