fix(runtime): keep unpriced turns distinguishable from free ones after reload

Abierto
#4,683 0 comentarios 0 reacciones 1 asignado Ver en GitHub

Los mantenedores suelen responder en 1 día

@dgageot ya está trabajando en esto.

Desde el 21/10/2026.

Evaluación

Este issue todavía no se ha evaluado.

Descripción

area/api area/runtime area/sessions

Problem

When a model has no known price (not in the models.dev catalogue and no cost: override), the runtime records the turn's cost as $0, with a warning (loop.go). chat.Message.Cost and the compaction item's Cost are plain float64, so the distinction is lost on save.

In memory, hooks, telemetry and the budget tracker already tell the two apart: nil means unpriced, 0 means free (BudgetUsageEvent.Unpriced). After a session is saved and reloaded, every unpriced turn reads as free, and session totals understate the real cost without saying so.

Proposal

  • Persist whether a message's (and a compaction item's) cost is known, additively, e.g. an unpriced flag next to cost in the stored JSON.
  • Surface it in session totals and the API: "$1.23 + unpriced turns" rather than "$1.23".
  • Keep old sessions readable; their missing flag means "priced".

Acceptance criteria

  • An unpriced turn stays unpriced after a SQLite save and reload, and a free one (cost: {}) stays free.
  • Session totals and the API distinguish them.
  • Old sessions load unchanged.

Found while planning #4654.

Lenguaje dominante
Go
Estrellas
4.7k
Forks
565
Merge medio
18 h 52 min
PR fusionados (30 d)
221

Preparar el entorno

Abrir en Codespaces

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
  • Sin plantilla de pull request
  • Sin guía de contribución

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de docker/docker-agent

Todos los issues de docker/docker-agent

Issues similares

Más issues de Go

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.