[BUG] LiteLLM path reports 0 cached and reasoning tokens in the usage summary
Maintainer thường phản hồi trong vòng 1 ngày
Đánh giá
- Độ khó
- 2/5
- Thời gian dự kiến
- 1-3 giờ
- Mức phù hợp với người mới
- 78/100
Hướng nghiên cứu
Bắt đầu với sáu vị trí gọi _track_token_usage_internal trong llm.py, UsageMetrics.from_provider_dict trong types/usage_metrics.py và tests/test_llm_litellm_usage_events.py. So sánh cách _usage_to_dict xử lý mức sử dụng của LiteLLM với cách bản tóm tắt nhận dữ liệu đó, rồi chạy các bài kiểm thử sự kiện sử dụng hiện có. Công việc hoàn tất khi bản tóm tắt báo cáo 4 token prompt được lưu vào bộ nhớ đệm và 3 token suy luận cho phản hồi LiteLLM được mô tả.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
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
- Ngôn ngữ chính
- Python
- Star
- 61.2k
- Fork
- 9.2k
- Merge trung bình
- 1 ngày 14 giờ
- Pull request đã merge (30 ngày)
- 180
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của crewAIInc/crewAI
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
Maintainer thường phản hồi trong vòng 1 ngày
-
[FEATURE] Add Straitly as a native OpenAI-compatible LLM providerCó thể đã có người làm @HashimSyedUBC đã nhận 2 ngày trước. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
Maintainer thường phản hồi trong vòng 1 ngày
-
[BUG] Native OpenAI sync streaming with response_model returns an empty string and emits no completed event when the parse is missingCó thể đã có người làm @basil-k-aji-dev đã nhận 2 ngày trước. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
Maintainer thường phản hồi trong vòng 1 ngày
-
[BUG] Native Azure provider ignores the seed settingCó thể đã có người làm @basil-k-aji-dev đã nhận 2 ngày trước. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
crewAIInc/crewAI#9787 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
[BUG] Native OpenAI async streaming does not send response_model as response_formatCó thể đã có người làm @basil-k-aji-dev đã nhận 2 ngày trước. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 84/100
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của crewAIInc/crewAI
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
fedora-infra/anitya#2272 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 80/100
unitaryfoundation/mitiq#3205 ·
Maintainer thường phản hồi trong vòng 6 ngày
-
[Bug]: Index worker test drops empty Git config values on WindowsCó thể đã có người làm @xiaoyesoso đã nhận hôm nay. Đang mởtriage/confirmed
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
agentscope-ai/agentscope#4377 · 2 bình luận ·
Maintainer thường phản hồi trong vòng 2 ngày
-
area/config comp/agent P2 type/perf
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
NousResearch/hermes-agent#161039 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
astral-sh/ty-pre-commit#46 ·