Cached input is priced at 10% of input for every model; dollar cap undercounts
Los mantenedores suelen responder en 1 día
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 3/5
- Tiempo estimado
- 1-2 días
- Aptitud para principiantes
- 75/100
- Tipo de issue
- Error
- Claridad
- Bien especificado
- Estado de actividad
- Activo
- Stack tecnológico
- go
- Área
- backend-api-design, databases
Línea de trabajo
Start with Pricer.Cost in internal/llm/pricing.go and trace how PricesFromConfig in internal/llm/wrap.go maps the [pricing] fields defined in internal/config/config.go. Check the cached token usage reported in internal/llm/openai.go and the pricing section in docs/config.md. Run the relevant tests, then make test-short; done means configured cache prices affect costs and the documented fallback and built-in override behavior match the acceptance criteria.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
Summary
When a price entry has no cache prices, cached input is charged at 10% of the input price. That ratio fits one vendor; a [pricing] entry cannot override it, so for other endpoints the recorded cost and the spend cap are understated.
Where
internal/llm/pricing.go:86-92(Pricer.Costderivesread = Input * 0.10,write = Input * 1.25)internal/llm/wrap.go:219-225(PricesFromConfigcopies only input and output prices)internal/config/config.go:323-326([pricing]has two keys)internal/llm/openai.go:253-255(cached tokens reported by OpenAI-compatible endpoints)docs/config.md:334-346
Details
A [pricing] entry can only carry input_per_mtok and output_per_mtok, so every model priced by the operator gets the derived cache prices with no way to change them. The OpenAI-compatible provider reports cached tokens, and the agent loop resends a growing prefix each turn, so most input tokens of a long conversation are cached ones. docs/config.md states the 125% write rule for the built-in table only and says nothing about cached reads for [pricing] entries.
Assumption behind the medium confidence: that some OpenAI-compatible vendors bill cached input at more than 10% of the input price.
Impact
For such an endpoint usage.CostUSD is lower than the real charge, the budget accumulates the low figure and the spend cap fires late. Example: 100,000 prompt tokens of which 90,000 cached, at 2.5 per million input, is recorded as $0.0475; at half price for cached input the real cost is $0.1375. An operator override of a built-in model also silently loses that model's own cache-read price.
Suggested fix
Add optional cache_read_per_mtok and cache_write_per_mtok to [pricing] and copy them in PricesFromConfig. When they are absent for a model that is not in the built-in table, price cached tokens at the full input price (an overestimate keeps the cap honest), and document the rule in docs/config.md.
Acceptance criteria
-
[pricing]accepts the two cache keys andPricer.Costuses them - A model priced only by input and output charges cached tokens at the input price
- An override of a built-in model keeps the built-in cache prices unless it sets its own
- docs/config.md states the rule
Getting started
- Relevant files: docs/config.md, internal/config/config.go, internal/llm/openai.go, internal/llm/pricing.go, internal/llm/wrap.go
- How to run tests:
make test-short(Unix) or.\make.ps1 test-short(Windows PowerShell);make lintbefore you call it done - Related docs: docs/config.md (pricing section)
Filed by repo-audit/full-audit at 50e92ec. Severity: medium. Effort: S. audit-key: bug|internal/llm/pricing.go|Pricer.Cost
- Lenguaje dominante
- Go
- Estrellas
- 0
- Forks
- 1
- Merge medio
- 8 h 14 min
- PR fusionados (30 d)
- 3
Preparar el entorno
Inicia el contenedor de desarrollo del proyecto en tu navegador, con tu propia cuenta de GitHub.
- Incluye un Dockerfile o un 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 TMHSDigital/Spackle
-
ci good first issue severity: low
Dificultad 2/5 1-3 horas Aptitud para principiantes 77/100
TMHSDigital/Spackle#206 ·
Los mantenedores suelen responder en 1 día
-
ci severity: low
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
TMHSDigital/Spackle#205 ·
Los mantenedores suelen responder en 1 día
-
bug good first issue severity: low
Dificultad 2/5 1-3 horas Aptitud para principiantes 82/100
TMHSDigital/Spackle#199 ·
Los mantenedores suelen responder en 1 día
-
bug good first issue severity: low
Dificultad 2/5 1-3 horas Aptitud para principiantes 87/100
TMHSDigital/Spackle#195 ·
Los mantenedores suelen responder en 1 día
-
documentation good first issue severity: medium
Dificultad 1/5 Menos de una hora Aptitud para principiantes 90/100
TMHSDigital/Spackle#188 ·
Los mantenedores suelen responder en 1 día
Todos los issues de TMHSDigital/Spackle
Issues similares
-
deskclose human-decided leaves the legacy decision-needed label and applies no human-decidedAbiertobug effort:s impact:med raised-by:worker risk:low to:worker
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
medici-finance/assay#8120 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
factory:subtask
Dificultad 1/5 Menos de una hora Aptitud para principiantes 72/100
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 77/100
agent-substrate/substrate#4308 ·
Los mantenedores suelen responder en 2 días
-
bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
celestiaorg/celestia-app#8877 ·
Los mantenedores suelen responder en 1 día
-
sweep
Dificultad 1/5 Menos de una hora Aptitud para principiantes 84/100
bketelsen/truenas-mcp#112 ·
Los mantenedores suelen responder en 1 día