Skip to content

fix: only write AI model prices that changed (#27923) - #28105

Open
ssncferreira wants to merge 1 commit into
release/2.36from
ssncf/2.36-backport-27923
Open

fix: only write AI model prices that changed (#27923)#28105
ssncferreira wants to merge 1 commit into
release/2.36from
ssncf/2.36-backport-27923

Conversation

@ssncferreira

@ssncferreira ssncferreira commented Aug 13, 2026

Copy link
Copy Markdown
Contributor

Backport of #27923

Original PR: #27923 - only write AI model prices that changed
Merge commit: 5efa7ab
Requested by: @ssncferreira

Previously, the AI Gateway price seeder rewrote every row of
`ai_model_prices` on each server start, because `ON CONFLICT` fires on a
key conflict rather than on a value difference. `updated_at` therefore
recorded when the server last restarted rather than when a price last
changed.

Guard the `DO UPDATE` branch so a conflicting row is only rewritten when
one of its four prices differs. The comparison uses `IS DISTINCT FROM`
rather than `<>` because the price columns are nullable, and `<>` yields
NULL when either side is NULL, which would skip the update and leave a
stale price in place.

Related to
https://linear.app/codercom/issue/AIGOV-567/experimental-cli-command-to-set-prices-for-unpriced-ai-models

> [!NOTE]
> Initially generated by Claude Opus 5, modified and reviewed by
@ssncferreira

(cherry picked from commit 5efa7ab)
@ssncferreira
ssncferreira requested a review from mtojek August 13, 2026 10:46
@ssncferreira ssncferreira added the backport/v2.36 Backport PR targeting release/2.36 label Aug 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport/v2.36 Backport PR targeting release/2.36

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant