#25805·coder

feat(agents): expose per-response cost on assistant messages

Author: DevelopmentCatsCreated May 28, 2026Updated Oct 1, 2026

Problem

Coder Agents already records the dollar cost of each assistant turn — chat_messages.total_cost_micros is stored alongside token usage, runtime, and model_config_id for every response. However, this per-message cost is not exposed anywhere in the UI.

Today, cost is only surfaced in aggregate:

  • site/src/pages/AgentsPage/components/ChatCostSummaryView.tsx — totals per chat / per model
  • site/src/pages/AgentsPage/components/PRInsightsView.tsx — totals per PR (cost per merged PR)
  • site/src/pages/AgentsPage/AgentSettingsSpendPageView.tsx — totals per user

There is no way for a user to look at a single assistant response and answer "how much did that one cost?"

Proposal

Surface the per-response cost on each assistant message in the Agents transcript, sourced from the existing chat_messages.total_cost_micros field. No new backend storage is required.

Suggested placement:

  • An unobtrusive footer on each assistant message bubble (e.g. next to the existing model name / runtime indicator), formatted with the existing formatCostMicros helper.
  • On hover/click, expand to show the breakdown that is already stored: input / output / total / reasoning / cache_creation / cache_read tokens, runtime, and the resolved model.
  • Respect the existing unpriced behavior — if total_cost_micros is null (provider/model not priced), show tokens only and omit the dollar amount, matching how ChatCostSummaryView already treats unpriced messages.

Why

  • Debuggability — users notice expensive turns immediately instead of only seeing them folded into a daily/chat total.
  • Model selection feedback — makes the cost difference between models / thinking levels visible at the point of decision.
  • Consistency — the data is already persisted and already shown in aggregate; per-message display closes the obvious gap.
  • Tooling cost transparency — turns with heavy tool use (large reads, MCP roundtrips) become visually distinct from cheap turns.

Out of scope (for this issue)

  • Pricing image generation or other auxiliary runs (tracked separately, e.g. via chat_auxiliary_runs work in #25790).
  • Changing how cost is computed or stored.
  • New cost analytics endpoints.

Related

  • coder/mux#1821 — cost segregation per task within a workspace (different granularity, complementary).
  • coder/blink.so#1294 — per-model breakdown in chat usage panel (different project, similar spirit).
  • #25790 — touches per-run cost accounting for side questions; explicitly notes per-run cost is not currently exposed on the API.

Filed via Coder Agents on @DevelopmentCats's behalf.