Google LLM plugin leaves Gemini thinking tokens out of completion_tokens
Los mantenedores suelen responder en 1 día
Evaluación
- Dificultad
- 2/5
- Tiempo estimado
- 1-3 horas
- Aptitud para principiantes
- 38/100
- Tipo de issue
- Error
- Claridad
- Bien especificado
- Estado de actividad
- Estancado
- Stack tecnológico
- python
- Área
- backend-api-design
Línea de trabajo
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.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
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.
- Lenguaje dominante
- Python
- Estrellas
- 14.6k
- Forks
- 3.9k
- Merge medio
- 3 d 3 h
- PR fusionados (30 d)
- 199
Preparar el entorno
Este proyecto no incluye contenedor de desarrollo, Dockerfile ni guía de contribución, así que la configuración corre por tu cuenta: empieza por su README y consulta nuestra guía para la primera contribución para los pasos generales.
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de livekit/agents
-
Assistant markup is stripped from chat history when expressive mode is offPosiblemente ocupada @ShivamSharma43 la tomó hace 18 días. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
Los mantenedores suelen responder en 1 día
-
docs: openai.LLM vs openai.responses.LLM for HTTP OpenAI-compat hostsQuizá libre de nuevo @AbarnaaSree la tomó hace 57 días y no hay ningún pull request abierto. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
livekit/agents#7022 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
Dificultad 5/5 Más de una semana Aptitud para principiantes 35/100
Los mantenedores suelen responder en 1 día
-
TranslationRoomIO: unset_track() before a track is linked stalls startup, so the translation is never publishedPosiblemente ocupada @RaphaelFakhri la tomó hace 1 día. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 20/100
livekit/agents#8114 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
OpenAI Realtime engine: expose the WebSocket close code and reason to subclassesPosiblemente ocupada @ninglinLiu la tomó hace 3 días. Abierto
Dificultad 3/5 1-2 días Aptitud para principiantes 35/100
livekit/agents#8076 · 1 comentario ·
Los mantenedores suelen responder en 1 día
Todos los issues de livekit/agents
Issues similares
-
[Resource] agent-claimcheckAbierto
Dificultad 1/5 Menos de una hora Aptitud para principiantes 85/100
yzhao062/awesome-auditable-ai#45 ·
Los mantenedores suelen responder en 3 días
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 62/100
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 65/100
NVIDIA/flare-local-inference#90 ·
Los mantenedores suelen responder en 1 día
-
area/streaming comp/gateway P2 platform/telegram type/bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
NousResearch/hermes-agent#144897 ·
Los mantenedores suelen responder en 1 día
-
request-theme
Dificultad 1/5 Menos de una hora Aptitud para principiantes 66/100
LizardByte/ThemerrDB#9575 ·
Los mantenedores suelen responder en 1 día