Skip to content

Fix #391: automate models.dev pricing refresh - #522

Open
willwashburn wants to merge 3 commits into
mainfrom
issue-391-pricing-sync-workflow
Open

Fix #391: automate models.dev pricing refresh#522
willwashburn wants to merge 3 commits into
mainfrom
issue-391-pricing-sync-workflow

Conversation

@willwashburn

@willwashburn willwashburn commented Aug 3, 2026

Copy link
Copy Markdown
Member

Fixes #391

This adds a weekly Monday 09:17 UTC workflow, with manual dispatch, that runs the sanctioned pnpm run pricing:update refresh and opens or updates a non-draft review PR on the fixed automation/models-dev-pricing branch. No-change runs create no empty PR, and the workflow never pushes to main, publishes, tags, or releases.

The updater validates the fetched JSON, rejects a provider-count regression or a model-count collapse greater than 10%, retains critical Anthropic/OpenAI entries, and runs the full relayburn-sdk test suite against the newly embedded snapshot before creating a PR. Its generated PR body reports primary-provider model and price changes separately, links an extended workflow summary, and is clamped below GitHub's body limit. Actions use immutable SHAs, and write permissions are limited to the update job.

Against current main, today's upstream refresh correctly fails the full SDK gate because the existing last-provider-wins flattening lets reseller entries replace first-party tariffs. Open PR #510 fixes that root cause by giving Anthropic, OpenAI, Google, Google Vertex, and xAI entries precedence; the first pricing refresh after #510 merges is expected to pass.

Local verification covered the refresh script, JSON/integrity and summary generation, repeat-refresh no-change behavior, the SDK safety gate, actionlint, YAML parsing, and the PR-body clamp. Cron dispatch, create-pull-request's fixed-branch create/update/no-change behavior, and GITHUB_TOKEN's suppression of follow-on pull-request workflows remain unproven until the workflow runs on GitHub.

🤖 Generated with Claude Code.

@coderabbitai

coderabbitai Bot commented Aug 3, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@willwashburn, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 49 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 168baad8-024f-40da-a324-199d1e02c4be

📥 Commits

Reviewing files that changed from the base of the PR and between 44c82c9 and d758299.

📒 Files selected for processing (1)
  • .github/workflows/update-pricing.yml
📝 Walkthrough

Walkthrough

The PR adds a scheduled and manual workflow that refreshes models.dev pricing, validates snapshot changes, runs Rust SDK tests when needed, and creates or updates a pull request. The README documents this automation.

Changes

Pricing refresh automation

Layer / File(s) Summary
Refresh and validate pricing data
.github/workflows/update-pricing.yml
The workflow refreshes the pricing snapshot, checks provider and model counts, verifies critical entries, categorizes changes, and exposes whether the snapshot changed.
Run affected Rust SDK tests
.github/workflows/update-pricing.yml
When pricing changes, the workflow installs the pinned Rust toolchain, caches Cargo artifacts, and runs cargo test -p relayburn-sdk.
Publish the generated snapshot
.github/workflows/update-pricing.yml, README.md
The workflow creates or updates a non-draft pull request from a fixed automation branch. The README documents the schedule, validation, and test behavior.

Estimated code review effort: 4 (Complex) | ~45 minutes

Sequence Diagram(s)

sequenceDiagram
  participant GitHubActions
  participant PricingUpdate as pnpm run pricing:update
  participant ModelsDev as models.dev
  participant Validation as Node validation step
  participant RustSDK as cargo test -p relayburn-sdk
  participant PullRequest as create-pull-request

  GitHubActions->>PricingUpdate: start pricing refresh
  PricingUpdate->>ModelsDev: retrieve current pricing
  PricingUpdate->>GitHubActions: write refreshed snapshot
  GitHubActions->>Validation: validate snapshot and detect changes
  Validation->>GitHubActions: publish summaries and changed output
  GitHubActions->>RustSDK: run tests when pricing changed
  GitHubActions->>PullRequest: create or update pricing pull request
Loading

Poem

A rabbit checks the prices bright,
Updates snapshots through the night.
Tests hop through the Rusty code,
Then opens a pull request road.
“Fresh model costs!” the bunny sings.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed The title clearly identifies the automated models.dev pricing refresh, which is the main change in the pull request.
Description check ✅ Passed The description directly explains the workflow, validation safeguards, SDK tests, and pull request behavior introduced by the changeset.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch issue-391-pricing-sync-workflow

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no potential bugs to report.

View in Devin Review to see 1 additional finding.

Open in Devin Review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 44c82c9753

ℹ️ 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".

Comment thread .github/workflows/update-pricing.yml

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (2)
.github/workflows/update-pricing.yml (2)

18-23: 🩺 Stability & Availability | 🔵 Trivial | ⚡ Quick win

Consider bounding the job with timeout-minutes.

This job has no timeout-minutes, so it defaults to GitHub's 360-minute job timeout. The job performs a network fetch, a Rust toolchain install, and a cargo test run; a hang in any of these could occupy a runner for hours before the default timeout kicks in. Add an explicit, tighter timeout (for example 30-60 minutes) to fail fast on stuck steps.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In @.github/workflows/update-pricing.yml around lines 18 - 23, Add an explicit
timeout-minutes value to the update-pricing job, near runs-on and permissions,
using a tighter bound such as 30–60 minutes so stalled network, toolchain, or
cargo test steps terminate promptly.

89-96: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick win

Hardcoded critical model IDs will need routine upkeep.

The critical-entry guard hardcodes exact model IDs (claude-sonnet-4-6, gpt-5.5). When Anthropic or OpenAI rename or retire these specific IDs upstream, this step throws and blocks every subsequent weekly run until a maintainer updates the string, even though the refresh itself is healthy. Consider matching by a stable prefix (for example, "at least one anthropic model ID starting with claude-") or moving the critical-list to a small config file that is easier to keep current, to reduce how often this check needs a manual bump.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In @.github/workflows/update-pricing.yml around lines 89 - 96, Update the
critical-entry guard in the pricing validation loop to avoid exact model IDs
that require routine updates. Validate that each provider has at least one
current model matching a stable provider-specific prefix, such as Anthropic IDs
beginning with “claude-” and OpenAI IDs beginning with the appropriate stable
prefix, while preserving the existing failure for missing critical coverage.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In @.github/workflows/update-pricing.yml:
- Around line 24-27: Update the actions/checkout step named “Checkout main” to
disable persisted credentials by setting persist-credentials to false, allowing
create-pull-request to configure the remote credentials without conflicts.

---

Nitpick comments:
In @.github/workflows/update-pricing.yml:
- Around line 18-23: Add an explicit timeout-minutes value to the update-pricing
job, near runs-on and permissions, using a tighter bound such as 30–60 minutes
so stalled network, toolchain, or cargo test steps terminate promptly.
- Around line 89-96: Update the critical-entry guard in the pricing validation
loop to avoid exact model IDs that require routine updates. Validate that each
provider has at least one current model matching a stable provider-specific
prefix, such as Anthropic IDs beginning with “claude-” and OpenAI IDs beginning
with the appropriate stable prefix, while preserving the existing failure for
missing critical coverage.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 42901b70-36b3-4896-9b73-d318e4609880

📥 Commits

Reviewing files that changed from the base of the PR and between 962b2b7 and 44c82c9.

📒 Files selected for processing (2)
  • .github/workflows/update-pricing.yml
  • README.md

Comment thread .github/workflows/update-pricing.yml

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All reported issues were addressed across 2 files

Reply with feedback, questions, or to request a fix.

Re-trigger cubic

Comment thread .github/workflows/update-pricing.yml
Comment thread .github/workflows/update-pricing.yml
Comment thread .github/workflows/update-pricing.yml
@willwashburn

Copy link
Copy Markdown
Member Author

Automated review follow-up:

  • Added timeout-minutes: 30 for the valid runner-hang nit.
  • Kept exact critical model IDs intentionally. The guard is short and anchored to models burn prices today; a broad claude-/OpenAI prefix would pass after losing the current high-impact entries and weaken the integrity check.
  • The duplicate-Authorization warning is inapplicable to pinned create-pull-request v8: the cited bug was fixed in v7.0.9, and the official v8 README pairs checkout v6 with the default credential behavior. The PR action is the final step.
  • Critical cost changes are expected output of a pricing refresh, so freezing cost/limits against the prior snapshot would prevent legitimate updates. Exact-value SDK tests are the safety gate for resolved first-party tariff regressions.
  • rustup toolchain install without an explicit argument is the repository's intentional rust-toolchain.toml-driven pattern from .github/workflows/ci.yml; this PR's just-green cargo job ran that same command successfully.

No changes were made for the three inapplicable findings.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Make scheduled workflow to update models.dev price list periodically

1 participant