feat: remove native chat cost tracking in favor of AI Gateway cost data - #27330
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 95cbc02c86
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
@codex review |
|
Codex Review: Didn't find any major issues. Hooray! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
7252fd8 to
4109148
Compare
|
@codex review |
|
Codex Review: Didn't find any major issues. Keep it up! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
4109148 to
0ee5f17
Compare
|
@codex review |
|
Codex Review: Didn't find any major issues. Bravo. Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
0ee5f17 to
57e4f39
Compare
|
@codex review |
|
Codex Review: Didn't find any major issues. Another round soon, please! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
57e4f39 to
850b601
Compare
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 850b601baf
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
850b601 to
28425bb
Compare
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 28425bb24a
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
@codex review |
1 similar comment
|
@codex review |
|
Codex Review: Didn't find any major issues. You're on a roll. Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
14f7276 to
693e298
Compare
|
Force-pushed after rebasing the stack onto Upstream #27579 removed the Change here: the chat lifecycle hook response types from upstream #27429 share a Validated per branch:
|
|
@codex review
|
|
Codex Review: Didn't find any major issues. Can't wait for the next one! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
nickvigilante
left a comment
There was a problem hiding this comment.
Docs LGTM with changes. Thanks for this!
There was a problem hiding this comment.
As a total aside, I was confused when I tried to search for "usage insights" in the docs, and I had to go to manifest.json to figure out that the page's title is actually "Spend management" now. Should we rename and redirect this page? Is "Spend management" closer to what we want to convey for this page? If so, the URL should also be updated.
There was a problem hiding this comment.
Accepted the rename in 533779f7cf8: the page is now spend-management.md, and the manifest plus all in-repo links use the new path. The public redirect from the old URL must be added to coder/coder.com's redirects.json, so I am leaving this thread open until that companion change lands.\n\n> Mux applied this feedback on Mike's behalf.
There was a problem hiding this comment.
Nick, could you add the companion redirect in coder/coder.com? The coder/coder rename and link updates are already pushed.
{"source":"/docs/ai-coder/agents/platform-controls/usage-insights","destination":"/docs/ai-coder/agents/platform-controls/spend-management","permanent":true}Mux posted this request on Mike's behalf.
There was a problem hiding this comment.
Done — companion redirect is up in coder/coder.com#1001, and I've added you as reviewer there. It adds the permanent /docs/ai-coder/agents/platform-controls/usage-insights → /docs/ai-coder/agents/platform-controls/spend-management redirect.
I flagged on that PR that it should not merge until this one lands, so we don't redirect the still-live page to a path that doesn't exist yet. Leaving this thread open until both merge.
There was a problem hiding this comment.
PR here for your review: https://github.com/coder/coder.com/pull/1001
nickvigilante
left a comment
There was a problem hiding this comment.
This approval is for docs only, which LGTM!
|
@codex review
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 3dd61f2c9a
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
@codex review
|
There was a problem hiding this comment.
💡 Codex Review
coder/docs/ai-coder/agents/platform-controls/spend-management.md
Lines 26 to 28 in f0483b9
When an administrator upgrades with existing per-model pricing and accumulated chat_messages.total_cost_micros data, this page explains that usage-limit values are not migrated but never gives the equivalent warning for native cost tracking. This change removes the pricing controls and aggregate cost APIs without migrating or exposing those historical totals through the AI Gateway surfaces, so operators cannot tell that old spend history becomes inaccessible or whether they should export it before upgrading. Add explicit migration guidance for the removed pricing metadata and cost history.
AGENTS.md reference: AGENTS.md:L12-L12
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
Addressed the native cost migration guidance in @codex review
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 2a4d91d49e
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
@codex review The current head
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 8238fc026c
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
@codex review The current head
|
Chats priced their own messages: chatcost computed a per-message cost from per-model prices stored in each model config, persisted it on chat_messages.total_cost_micros, and aggregated it for the admin cost views. The AI Gateway already records cost for every request it proxies, so this was a second, divergent accounting of the same spend with no admin UI for its prices. Removes the chatcost package and all total_cost_micros plumbing, the admin cost aggregate endpoints and SQL, the per-model pricing form fields, and the Analytics and Spend cost UI. The column itself is not dropped here. InsertChatMessages stops writing it, so it lingers nullable and unwritten until a follow-up release drops it. Dropping it now would break InsertChatMessages, and therefore every chat message insert, on a replica still running the previous release. The per-chat cost endpoint gains a retention caveat in its swagger description, so docs/reference/api/chats.md states that cost comes from AI Gateway data under its own retention period and that fully purged chats report zero. Two things deliberately survive. GetChatMessageSummariesPerChat keeps feeding telemetry, with only its cost projection removed. ChatModelCallConfig still tolerates a stored cost object and the older top-level pricing keys, since existing model configs contain them and strict decoding would otherwise reject those rows.
The comment still referred to analytics nav buttons after this stack removed the Analytics page. mobileBack hides the whole mobile actions menu, which carries settings plus the sound and notification toggles.
|
Codex Review: Didn't find any major issues. Nice work! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: fb6c996f89
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
@codex review The current head remains
|

Stack Context
This stack makes AI Gateway data and budgets the source of truth for AI spend controls.
main: remove native chat cost tracking and its dedicated admin UI.Summary
Removes native per-message price calculation, model pricing fields, cost persistence, aggregate cost queries, and admin cost API types. It also deletes the Analytics and Spend pages plus their legacy redirects. The AI Gateway-backed per-chat cost row and compact budget indicators remain.
The spend documentation is renamed to
spend-management.mdand updated for the remaining surfaces, group budget APIs, CSV export, upgrade handling for native pricing and cost history, and the absence of a deployment-wide spend dashboard. The per-chat cost API documents that data follows AI Gateway retention and reports zero after all matching requests are purged.No schema is dropped in this release.
chat_messages.total_cost_microsremains nullable and unwritten so replicas from the previous release can continue inserting messages during rolling upgrades. #27600 tracks removal after the compatibility window.