fix(ai): capture usage from choice.usage for non-standard OpenAI-compatible providers

Some OpenAI-compatible providers (e.g., Moonshot/Kimi) return usage
data in chunk.choices[0].usage instead of the standard chunk.usage.
Extract usage parsing into a helper and check choice.usage as fallback.

closes #2017
This commit is contained in:
Mario Zechner
2026-03-10 16:28:09 +01:00
parent 23109b113d
commit 4535415300
2 changed files with 36 additions and 22 deletions

View File

@@ -5,6 +5,7 @@
### Fixed
- Fixed GitHub Copilot device-code login polling to respect OAuth slow-down intervals, wait before the first token poll, and include a clearer clock-drift hint in WSL/VM environments when repeated slow-downs lead to timeout.
- Fixed usage statistics not being captured for OpenAI-compatible providers that return usage in `choice.usage` instead of the standard `chunk.usage` (e.g., Moonshot/Kimi) ([#2017](https://github.com/badlogic/pi-mono/issues/2017))
## [0.57.1] - 2026-03-07