[BUG] LiteLLM path reports 0 cached and reasoning tokens in the usage summary
メンテナーはふだん 1 日以内に返信
評価
調査の方向性
まず、llm.py にある _track_token_usage_internal の6つの呼び出し箇所、types/usage_metrics.py の UsageMetrics.from_provider_dict、および tests/test_llm_litellm_usage_events.py を確認してください。_usage_to_dict が LiteLLM の使用量をどのように扱うかと、要約がそれをどのように受け取るかを比較し、その後、既存の使用量イベントテストを実行してください。説明されている LiteLLM の応答に対して、要約にキャッシュ済みのプロンプトトークンが4、推論トークンが3と報告されれば完了です。
索引モデルが issue の本文から書いたものです。
説明
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
- 主要言語
- Python
- スター
- 61.2k
- フォーク
- 9.2k
- 平均マージ
- 1日 14時間
- マージ済み PR(30日)
- 180
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
crewAIInc/crewAI のほかの issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
メンテナーはふだん 1 日以内に返信
-
[FEATURE] Add Straitly as a native OpenAI-compatible LLM provider対応中かも @HashimSyedUBC が 2 日前に担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
メンテナーはふだん 1 日以内に返信
-
[BUG] Native OpenAI sync streaming with response_model returns an empty string and emits no completed event when the parse is missing対応中かも @basil-k-aji-dev が 2 日前に担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
メンテナーはふだん 1 日以内に返信
-
[BUG] Native Azure provider ignores the seed setting対応中かも @basil-k-aji-dev が 2 日前に担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
crewAIInc/crewAI#9787 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
[BUG] Native OpenAI async streaming does not send response_model as response_format対応中かも @basil-k-aji-dev が 2 日前に担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 84/100
メンテナーはふだん 1 日以内に返信
crewAIInc/crewAI の issue をすべて見る
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
fedora-infra/anitya#2272 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 80/100
unitaryfoundation/mitiq#3205 ·
メンテナーはふだん 6 日以内に返信
-
[Bug]: Index worker test drops empty Git config values on Windows対応中かも @xiaoyesoso が今日担当しました。 オープンtriage/confirmed
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
agentscope-ai/agentscope#4377 · コメント 2 件 ·
メンテナーはふだん 2 日以内に返信
-
area/config comp/agent P2 type/perf
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
NousResearch/hermes-agent#161039 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
astral-sh/ty-pre-commit#46 ·