[BUG] LiteLLM path reports 0 cached and reasoning tokens in the usage summary
Los mantenedores suelen responder en 1 día
@basil-k-aji-dev ya está trabajando en esto.
Desde el 25/11/2026.
- #9797 de @basil-k-aji-dev — abierto
Evaluación
- Dificultad
- 2/5
- Tiempo estimado
- 1-3 horas
- Aptitud para principiantes
- 78/100
Línea de trabajo
Empieza por los seis puntos de llamada de _track_token_usage_internal en llm.py, UsageMetrics.from_provider_dict en types/usage_metrics.py y tests/test_llm_litellm_usage_events.py. Compara cómo _usage_to_dict gestiona el uso de LiteLLM con cómo lo recibe el resumen y, después, ejecuta las pruebas existentes de eventos de uso. El trabajo estará terminado cuando el resumen indique 4 tokens de prompt en caché y 3 tokens de razonamiento para la respuesta de LiteLLM descrita.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
Description
On the LiteLLM path, get_token_usage_summary() reports 0 cached and 0 reasoning tokens even though the usage event has them. llm.py passes the raw LiteLLM Usage object to _track_token_usage_internal, and UsageMetrics.from_provider_dict (types/usage_metrics.py) reads prompt_tokens_details only when it is a dict and reads reasoning_tokens only at the top level. In LiteLLM the details are pydantic objects (PromptTokensDetailsWrapper, CompletionTokensDetailsWrapper), so both counts are lost. _usage_to_dict (whose docstring says it mirrors _track_token_usage_internal) flattens them correctly for the event.
Steps to Reproduce
- Build a hermetic
ModelResponsewithusagecarryingprompt_tokens_details={"cached_tokens": 4}andcompletion_tokens_details={"reasoning_tokens": 3}(as intests/test_llm_litellm_usage_events.py). - Run it through the LiteLLM call path.
llm.get_token_usage_summary().cached_prompt_tokensis 0.
Expected behavior
cached_prompt_tokens == 4 and reasoning_tokens == 3.
Screenshots/Code snippets
Usage under-reports cache hits and reasoning tokens for every model on the LiteLLM fallback.
Evidence
Code reading of llm.py (six _track_token_usage_internal call sites) and types/usage_metrics.py at 97f2424. I can send a fix in llm.py (passing the flattened usage) with a test in the existing usage-events test file.
Operating System
Linux (Debian-based)
Python Version
3.12
crewAI Version
1.15.45 (origin/main at 97f2424)
crewAI Tools Version
Not relevant
Virtual Environment
uv
- Lenguaje dominante
- Python
- Estrellas
- 61.2k
- Forks
- 9.2k
- Merge medio
- 1 d 14 h
- PR fusionados (30 d)
- 180
Preparar el entorno
- Sin Dockerfile ni archivo de Docker Compose
- Tiene una plantilla de pull request
- Leer la guía de contribución
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 crewAIInc/crewAI
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 76/100
Los mantenedores suelen responder en 1 día
-
[FEATURE] Add Straitly as a native OpenAI-compatible LLM providerPosiblemente ocupada @HashimSyedUBC la tomó hace 2 días. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
Los mantenedores suelen responder en 1 día
-
[BUG] Native OpenAI sync streaming with response_model returns an empty string and emits no completed event when the parse is missingPosiblemente ocupada @basil-k-aji-dev la tomó hace 2 días. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 82/100
Los mantenedores suelen responder en 1 día
-
[BUG] Native Azure provider ignores the seed settingPosiblemente ocupada @basil-k-aji-dev la tomó hace 2 días. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 82/100
crewAIInc/crewAI#9787 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
[BUG] Native OpenAI async streaming does not send response_model as response_formatPosiblemente ocupada @basil-k-aji-dev la tomó hace 2 días. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 84/100
Los mantenedores suelen responder en 1 día
Todos los issues de crewAIInc/crewAI
Issues similares
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
fedora-infra/anitya#2272 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 80/100
unitaryfoundation/mitiq#3205 ·
Los mantenedores suelen responder en 6 días
-
[Bug]: Index worker test drops empty Git config values on WindowsPosiblemente ocupada @xiaoyesoso la tomó hoy. Abiertotriage/confirmed
Dificultad 2/5 1-3 horas Aptitud para principiantes 82/100
agentscope-ai/agentscope#4377 · 2 comentarios ·
Los mantenedores suelen responder en 2 días
-
area/config comp/agent P2 type/perf
Dificultad 2/5 1-3 horas Aptitud para principiantes 75/100
NousResearch/hermes-agent#161039 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
astral-sh/ty-pre-commit#46 ·