Skip to content

feat(openai-router): use per-model retry config from WorkerRegistry - #935

Merged
CatherineSue merged 1 commit into
mainfrom
feat/openai-router-retry-from-registry
Mar 26, 2026
Merged

CatherineSue merged 1 commit into
mainfrom
feat/openai-router-retry-from-registry

Conversation

@CatherineSue

@CatherineSue CatherineSue commented Mar 26, 2026 •

Copy link
Copy Markdown
Member

Description

Part of the per-worker resilience refactor series: #799 → #803 → #821 → #836 → #875 → #881 / #933 → this PR.

Problem

OpenAI router uses a single global retry_config for all requests, ignoring per-model retry config set by workers.

Solution

Resolve per-model retry config from WorkerRegistry in route_chat() before passing it to ChatRouterContext, falling back to the router-level default.

Independent of #881 (HTTP router) and #933 (gRPC router).

Changes

  • route_chat() in OpenAI router resolves retry config from WorkerRegistry per model ID

Test Plan

  • cargo test -p smg --lib — all 450 tests pass
  • Pre-commit hooks pass (rustfmt, clippy, codespell, DCO)
Checklist
  • cargo +nightly fmt passes
  • cargo clippy --all-targets --all-features -- -D warnings passes
  • (Optional) Documentation updated
  • (Optional) Please join us on Slack #sig-smg to discuss, review, and merge PRs

Summary by CodeRabbit

  • Bug Fixes
    • Enhanced retry configuration handling by enabling per-model resolution. The system now applies model-specific retry configurations when available, with automatic fallback to default settings, improving overall reliability and resilience.

Summary by CodeRabbit

OpenAI router now resolves per-model retry config from WorkerRegistry
before passing it to ChatRouterContext, falling back to the router-level
default if no worker group override exists.

Signed-off-by: Chang Su <chang.s.su@oracle.com>
@coderabbitai

coderabbitai Bot commented Mar 26, 2026 •

Copy link
Copy Markdown

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: d82c5b85-c4d7-4604-9850-f59767745676

📥 Commits

Reviewing files that changed from the base of the PR and between f04d3ee and 4ef1e59.

📒 Files selected for processing (1)
  • model_gateway/src/routers/openai/router.rs

📝 Walkthrough

Walkthrough

The OpenAI router's chat routing method now resolves per-model retry configuration from the worker registry, with fallback to the router-level default configuration if unavailable. The chat routing context is updated to receive this selected configuration instead of the router's global retry config.

Changes

Cohort / File(s) Summary
OpenAI Router Retry Configuration
model_gateway/src/routers/openai/router.rs
Updated route_chat to resolve per-model retry config via worker_registry.get_retry_config(model_id) with fallback to router-level default; passes selected config to ChatRouterContext.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Possibly related PRs

Suggested labels

model-gateway, openai

Suggested reviewers

  • key4ng
  • slin1237

Poem

🐰 Per model, the retry config now flows,
From worker registry where wisdom grows,
With fallback grace when lookup shows no trace,
The router routes with smarter pace! ✨

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and specifically describes the main change: the OpenAI router now uses per-model retry configuration from WorkerRegistry instead of a single global config.

✏️ 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 feat/openai-router-retry-from-registry

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

@gemini-code-assist gemini-code-assist 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.

Code Review

This pull request implements per-model retry configurations in the OpenAI router, allowing for model-specific retry logic with a default fallback. A review comment suggests refactoring the configuration retrieval to return references to avoid unnecessary clones and improve efficiency.

Comment thread model_gateway/src/routers/openai/router.rs
@CatherineSue
CatherineSue merged commit 4e78351 into main Mar 26, 2026
32 checks passed
@CatherineSue
CatherineSue deleted the feat/openai-router-retry-from-registry branch March 26, 2026 21:55
@github-actions github-actions Bot added model-gateway Model gateway crate changes openai OpenAI router changes labels Mar 26, 2026
smfirmin pushed a commit to smfirmin/smg that referenced this pull request Apr 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

model-gateway Model gateway crate changes openai OpenAI router changes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant