fix: only write AI model prices that changed by ssncferreira · Pull Request #27923 · coder/coder · GitHub
Skip to content

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

Merged
ssncferreira merged 1 commit into
mainfrom
ssncf/ai-model-prices-skip-unchanged
Aug 10, 2026
Merged

fix: only write AI model prices that changed#27923
ssncferreira merged 1 commit into
mainfrom
ssncf/ai-model-prices-skip-unchanged

Conversation

@ssncferreira

@ssncferreira ssncferreira commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

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

Copy link
Copy Markdown
Contributor Author

@ssncferreira
ssncferreira force-pushed the ssncf/ai-model-prices-skip-unchanged branch from af32a32 to 94d27db Compare August 6, 2026 15:38
@ssncferreira
ssncferreira force-pushed the ssncf/ai-model-prices-skip-unchanged branch from 94d27db to 9690f4b Compare August 10, 2026 14:56
@linear-code

linear-code Bot commented Aug 10, 2026

Copy link
Copy Markdown

@ssncferreira
ssncferreira marked this pull request as ready for review August 10, 2026 15:03
@ssncferreira
ssncferreira merged commit 5efa7ab into main Aug 10, 2026
42 checks passed
@ssncferreira
ssncferreira deleted the ssncf/ai-model-prices-skip-unchanged branch August 10, 2026 15:33
@github-actions github-actions Bot locked and limited conversation to collaborators Aug 10, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants