LiteLLM integration does not report cached, reasoning, or cache-write token usage
@alexander-alderman-webb já está trabalhando nisso.
Desde 23/2/2026.
Avaliação
Esta issue ainda não foi avaliada.
Descrição
How do you use Sentry?
Sentry Saas (sentry.io)
Version
2.52.0
Steps to Reproduce
- Initialize Sentry with the LiteLLM integration and tracing enabled
- Make a completion call through LiteLLM to a provider that supports prompt caching (e.g., OpenAI, Anthropic, etc.)
- Inspect the resulting span data in Sentry's AI Agents dashboard
Expected Result
The span should include all available token usage detail attributes, just like the OpenAI and Anthropic integrations do:
gen_ai.usage.input_tokens(total input tokens)gen_ai.usage.input_tokens.cached(cached input tokens, subset of total)gen_ai.usage.input_tokens.cache_write(cache write tokens, if available)gen_ai.usage.output_tokens(total output tokens)gen_ai.usage.output_tokens.reasoning(reasoning tokens, subset of total)gen_ai.usage.total_tokens
This data is necessary for Sentry to correctly calculate model costs using the formula documented here:
input cost = (input_tokens - cached_tokens) x input_rate + cached_tokens x cached_rate
Without cached/reasoning token breakdown, all tokens are charged at the full standard rate, producing inaccurate cost estimates.
Actual Result
The LiteLLM integration's _success_callback only extracts three basic fields:
record_token_usage(
span,
input_tokens=getattr(usage, "prompt_tokens", None),
output_tokens=getattr(usage, "completion_tokens", None),
total_tokens=getattr(usage, "total_tokens", None),
)
The input_tokens_cached, input_tokens_cache_write, and output_tokens_reasoning parameters of record_token_usage() are never passed. Therefore, cost calculations in the AI Agents dashboard overestimate costs for cached-heavy workloads (all input tokens billed at the full rate) and misattribute output vs. reasoning token costs.
- Linguagem predominante
- Python
- Estrelas
- 2.2k
- Forks
- 672
- Merge médio
- 22h 54min
- PRs com merge (30d)
- 235
Guia de contribuição
Primeiros passos
- Leia a issue inteira e depois o guia de contribuição do projeto.
- Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
- Faça um fork do repositório e trabalhe em uma branch.
- Abra um pull request que referencie o número da issue.
Mais de getsentry/sentry-python
-
Python
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 65/100
getsentry/sentry-python#7668 · 1 comentário ·
-
Python
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 65/100
getsentry/sentry-python#7671 · 1 comentário ·
-
Python
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 65/100
getsentry/sentry-python#7663 · 1 comentário ·
-
Python
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 65/100
getsentry/sentry-python#7660 · 1 comentário ·
-
Python
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 65/100
getsentry/sentry-python#7652 · 1 comentário ·
Todas as issues de getsentry/sentry-python
Issues semelhantes
-
agent-ready documentation needs-triage
Dificuldade 1/5 1-3 horas Facilidade para iniciantes 88/100
-
documentation
Dificuldade 1/5 Menos de uma hora Facilidade para iniciantes 91/100
-
workflow-status page template still says reusable workflows are "triggered only by workflow_call:" Aberta
Dificuldade 1/5 Menos de uma hora Facilidade para iniciantes 92/100
-
instance instance add
Dificuldade 1/5 Menos de uma hora Facilidade para iniciantes 72/100
searxng/searx-instances#939 · 1 comentário ·
-
area-deployment area-integrations triage:bot-seen
Dificuldade 2/5 Meio dia Facilidade para iniciantes 86/100