fix: restore defensive behavior for unknown usage types

- Restore original defensive behavior: return Usage(0,0,0) for unknown types instead of raising ValueError
- Keep explicit ResponseAPIUsage handling to fix the bug where it was incorrectly returning 0 tokens
- Maintain backward compatibility by preserving original error handling approach
This commit is contained in:
Alexsander Hamir 2026-01-14 11:46:04 -08:00
parent d5f76a4da4
commit 19c9bb5c17

View file

@ -4525,8 +4525,13 @@ class StandardLoggingPayloadSetup:
)
elif isinstance(usage, dict):
return Usage(**usage)
raise ValueError(f"usage is required, got={usage} of type {type(usage)}")
else:
# Unknown type - return 0 tokens (defensive behavior)
return Usage(
prompt_tokens=0,
completion_tokens=0,
total_tokens=0,
)
@staticmethod
def get_model_cost_information(