[BUG] LiteLLM path reports 0 cached and reasoning tokens in the usage summary
I maintainer di solito rispondono entro 1 giorno
Valutazione
- Difficoltà
- 2/5
- Tempo stimato
- 1-3 ore
- Idoneità per principianti
- 78/100
Direzione di ricerca
Inizia dai sei punti di chiamata di _track_token_usage_internal in llm.py, da UsageMetrics.from_provider_dict in types/usage_metrics.py e da tests/test_llm_litellm_usage_events.py. Confronta il modo in cui _usage_to_dict gestisce l’utilizzo di LiteLLM con il modo in cui lo riceve il riepilogo, poi esegui i test esistenti sugli eventi di utilizzo. Il lavoro è completato quando il riepilogo riporta 4 token di prompt memorizzati nella cache e 3 token di ragionamento per la risposta LiteLLM descritta.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
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
- Lingua principale
- Python
- Stelle
- 61.2k
- Fork
- 9.2k
- Merge medio
- 1g 14h
- PR unite (30g)
- 180
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Ha un modello di pull request
- Leggi la guida per i contributori
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 crewAIInc/crewAI
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
I maintainer di solito rispondono entro 1 giorno
-
[FEATURE] Add Straitly as a native OpenAI-compatible LLM providerForse già presa @HashimSyedUBC l’ha presa 2 giorni fa. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
I maintainer di solito rispondono entro 1 giorno
-
[BUG] Native OpenAI sync streaming with response_model returns an empty string and emits no completed event when the parse is missingForse già presa @basil-k-aji-dev l’ha presa 2 giorni fa. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
I maintainer di solito rispondono entro 1 giorno
-
[BUG] Native Azure provider ignores the seed settingForse già presa @basil-k-aji-dev l’ha presa 2 giorni fa. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
crewAIInc/crewAI#9787 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
[BUG] Native OpenAI async streaming does not send response_model as response_formatForse già presa @basil-k-aji-dev l’ha presa 2 giorni fa. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 84/100
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di crewAIInc/crewAI
Issue simili
-
[Bug]: Index worker test drops empty Git config values on WindowsForse già presa @xiaoyesoso l’ha presa oggi. Apertatriage/confirmed
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
agentscope-ai/agentscope#4377 · 2 commenti ·
I maintainer di solito rispondono entro 2 giorni
-
area/config comp/agent P2 type/perf
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
NousResearch/hermes-agent#161039 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
astral-sh/ty-pre-commit#46 ·
-
Fast and light shell approval "Always allow" button shows raw English backticks and scrambles commands in ArabicForse già presa @tylerbea l’ha presa oggi. Apertaagent-ui bug p3
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
verl-project/verl#8893 ·
I maintainer di solito rispondono entro 1 giorno