Skip to content

chore: increase price weight in routing score - #2312

Merged
steebchen merged 1 commit into
mainfrom
increase-price-weight
May 17, 2026
Merged

steebchen merged 1 commit into
mainfrom
increase-price-weight

Conversation

@steebchen

@steebchen steebchen commented May 17, 2026 •

Copy link
Copy Markdown
Member

Summary

  • Bumps PRICE_WEIGHT from 0.3 → 0.6 and IMAGE_PRICE_WEIGHT from 0.5 → 1.0 in packages/actions/src/get-cheapest-from-available-providers.ts.
  • Makes price the single largest weighted-score factor (0.6 vs uptime 0.5, cache 0.2, throughput 0.05, latency 0.025).
  • Note: total non-price weights still sum to 0.775, so other signals retain meaningful influence — this is an intentional, conservative bump rather than fully price-dominant routing.

Test plan

  • pnpm format
  • pnpm build
  • Spot-check provider selection in staging for representative models

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Improvements
    • Optimized provider selection algorithm to prioritize pricing more heavily when routing image generation requests, resulting in more cost-efficient provider selections.

Review Change Stack

Bump PRICE_WEIGHT from 0.3 to 0.6 and IMAGE_PRICE_WEIGHT from 0.5
to 1.0 so price has a larger influence than any single other
factor (uptime, throughput, latency, cache) in weighted routing.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings May 17, 2026 11:35
@coderabbitai

coderabbitai Bot commented May 17, 2026 •

Copy link
Copy Markdown
Contributor

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: c339fcc0-b019-4f71-aef1-c33a1576223e

📥 Commits

Reviewing files that changed from the base of the PR and between 1e9e40a and 1d8e6fc.

📒 Files selected for processing (1)
  • packages/actions/src/get-cheapest-from-available-providers.ts

Walkthrough

This PR modifies the provider selection routing logic by increasing price weighting in the scoring algorithm. The PRICE_WEIGHT constant rises from 0.3 to 0.6, and IMAGE_PRICE_WEIGHT increases from 0.5 to 1.0, making cost a more significant factor when comparing available providers.

Changes

Provider Price Weighting

Layer / File(s) Summary
Price weight constants
packages/actions/src/get-cheapest-from-available-providers.ts
PRICE_WEIGHT increased from 0.3 to 0.6 and IMAGE_PRICE_WEIGHT increased from 0.5 to 1.0 to strengthen price influence in provider selection scoring.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~2 minutes

Possibly related PRs

  • theopenco/llmgateway#2095: Both PRs modify the provider-selection weighted-scoring logic in packages/actions/src/get-cheapest-from-available-providers.ts—one changes the price-related weight constants, and the other adds a prompt-caching term/weight gated by promptTokens, so they directly overlap in the same scoring pathway.
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely summarizes the main change: increasing price weight in the routing score calculation.
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.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch increase-price-weight

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 and usage tips.

Copilot AI 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.

Pull request overview

Adjusts routing weights so price has greater influence in provider selection scoring.

Changes:

  • PRICE_WEIGHT raised from 0.3 to 0.6
  • IMAGE_PRICE_WEIGHT raised from 0.5 to 1.0

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@steebchen
steebchen added this pull request to the merge queue May 17, 2026
Merged via the queue into main with commit 47c26cf May 17, 2026
18 of 19 checks passed
@steebchen
steebchen deleted the increase-price-weight branch May 17, 2026 14:34
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.

2 participants