Google LLM plugin leaves Gemini thinking tokens out of completion_tokens
I maintainer di solito rispondono entro 1 giorno
Valutazione
- Difficoltà
- 2/5
- Tempo stimato
- 1-3 ore
- Idoneità per principianti
- 38/100
- Tipo di issue
- Bug
- Chiarezza
- Specificata chiaramente
- Stato di attività
- Ferma
- Stack tecnologico
- python
- Ambito
- backend-api-design
Direzione di ricerca
Start in livekit/plugins/google/llm.py and inspect how CompletionUsage is built from usage_metadata; compare with the reasoning-token handling mentioned in realtime_api.py and issue #7326. Reproduce the supplied usage chunk and check that completion and reasoning tokens match the expected values; pull request #7891 is already open for this issue.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Bug Description
For Gemini thinking models (2.5, 3), usageMetadata reports the answer tokens (candidatesTokenCount) and the thinking tokens (thoughtsTokenCount) separately. Both are billed as output, and totalTokenCount includes both.
livekit-plugins-google's LLM (livekit/plugins/google/llm.py, the CompletionUsage built from usage_metadata) sets completion_tokens = candidates_token_count and doesn't set reasoning_tokens. CompletionUsage documents reasoning_tokens as "already counted in completion_tokens". So with thinking on:
completion_tokensunder-reports output,reasoning_tokensis 0,prompt_tokens + completion_tokens != total_tokens.
Usage metrics and any cost computed from completion_tokens come out low.
#7326 adds reasoning tokens for the Gemini Live RealtimeModel (realtime_api.py). This is the same gap in the non-realtime LLM.
Expected Behavior
completion_tokens = candidates_token_count + thoughts_token_count and reasoning_tokens = thoughts_token_count, matching how CompletionUsage defines them and how the OpenAI-compatible path reports completion_tokens_details.reasoning_tokens.
Reproduction Steps
google.LLM(model="gemini-2.5-flash", api_key=..., http_options=types.HttpOptions(base_url=<local server>)) against a server that streams one chunk with:
"usageMetadata": {"promptTokenCount": 10, "candidatesTokenCount": 5, "thoughtsTokenCount": 40, "totalTokenCount": 55}
The usage chunk is completion_tokens=5 reasoning_tokens=0 total_tokens=55 (expected completion_tokens=45 reasoning_tokens=40).
Package Versions
livekit-agents and livekit-plugins-google from main (f548149).
This issue was drafted with Claude Code; the reproduction above was run on main to confirm the output.
- Lingua principale
- Python
- Stelle
- 14.6k
- Fork
- 3.9k
- Merge medio
- 3g 1h
- PR unite (30g)
- 166
Preparare l'ambiente
Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di livekit/agents
-
Agent state stays "speaking" after a realtime reply in sessions without audio outputForse già presa @Luke-salinero l’ha presa 1 giorno fa. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
I maintainer di solito rispondono entro 1 giorno
-
Assistant markup is stripped from chat history when expressive mode is offForse già presa @ShivamSharma43 l’ha presa 9 giorni fa. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
I maintainer di solito rispondono entro 1 giorno
-
docs: openai.LLM vs openai.responses.LLM for HTTP OpenAI-compat hostsForse di nuovo libera @AbarnaaSree l’ha presa 48 giorni fa e non c’è nessuna pull request aperta. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
livekit/agents#7022 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 45/100
I maintainer di solito rispondono entro 1 giorno
-
Muse STT audio buffered before the websocket connection stays delayed for the whole streamForse già presa @DEVJHAWAR11 l’ha presa oggi. Apertabug
Difficoltà 3/5 1-2 giorni Idoneità per principianti 35/100
livekit/agents#7876 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di livekit/agents
Issue simili
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
omegaup/omegaup#10353 · 1 commento ·
I maintainer di solito rispondono entro 5 giorni
-
bot-triaged module: LrScheduler module: optimizer triaged
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
I maintainer di solito rispondono entro 1 giorno
-
documentation glm5 llm-model
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
vllm-project/vllm-ascend#19062 ·
I maintainer di solito rispondono entro 1 giorno
-
Author Page: shuai-zhao-llmApertaauthor-page correction
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
acl-org/acl-anthology#10496 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno