Skip to content

[model-gateway] use worker crate in openai router#14330

Merged
slin1237 merged 4 commits intomainfrom
oai-router-n/8
Dec 3, 2025
Merged

[model-gateway] use worker crate in openai router#14330
slin1237 merged 4 commits intomainfrom
oai-router-n/8

Conversation

@slin1237
Copy link
Copy Markdown
Collaborator

@slin1237 slin1237 commented Dec 3, 2025

Checklist

@gemini-code-assist
Copy link
Copy Markdown
Contributor

Summary of Changes

Hello @slin1237, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request significantly refactors the OpenAI router by integrating it with the new worker management system. The primary goal is to centralize the discovery, health checking, and selection of OpenAI-compatible API endpoints through a WorkerRegistry. This change streamlines the router's internal logic, making it more robust and scalable by abstracting away direct endpoint management and delegating these responsibilities to the Worker abstraction. It ensures that the router dynamically adapts to available and healthy workers, improving overall system reliability and maintainability.

Highlights

  • OpenAI Router Refactoring: The OpenAI router has been refactored to leverage the new worker crate, centralizing worker management and model discovery within the WorkerRegistry.
  • WorkerRegistry Integration: The OpenAIRouter now relies on the AppContext's WorkerRegistry to find and select appropriate workers for models, replacing its previous direct management of worker URLs and endpoint probing logic.
  • Simplified Router Creation: The create_openai_router function no longer requires a list of worker URLs, as workers are expected to be registered externally via the WorkerRegistry.
  • Decentralized Circuit Breaker: Circuit breaker logic has been moved from the OpenAIRouter to individual Worker instances, allowing for more granular control and fault tolerance per worker.
  • Enhanced Model Discovery: The get_models endpoint now aggregates model information directly from the ModelCards of registered workers in the WorkerRegistry, including primary IDs and aliases, rather than probing external endpoints.
  • Updated Test Infrastructure: Test cases have been updated to reflect the new worker-centric design, using helper functions to register external workers in the AppContext before router initialization.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@slin1237 slin1237 added the run-ci label Dec 3, 2025
Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

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 is a significant and well-executed refactoring of the OpenAI router to use the worker crate abstractions. The changes simplify the router's logic by delegating worker management, health checks, and model discovery to the WorkerRegistry. This makes the OpenAIRouter much cleaner and more maintainable. The test suite has also been updated thoroughly to reflect these changes.

I've identified a couple of critical issues related to potential panics when handling API keys, which could crash the service. I've also included some medium-severity suggestions to improve the robustness of the model information retrieval. Overall, this is a great improvement to the codebase.

Comment thread sgl-router/src/routers/openai/router.rs Outdated
Comment thread sgl-router/src/routers/openai/router.rs Outdated
Comment thread sgl-router/src/routers/openai/router.rs Outdated
Comment thread sgl-router/src/routers/openai/router.rs Outdated
@slin1237 slin1237 merged commit 3881510 into main Dec 3, 2025
56 checks passed
@slin1237 slin1237 deleted the oai-router-n/8 branch December 3, 2025 21:36
tom-jerr pushed a commit to tom-jerr/sglang that referenced this pull request Dec 4, 2025
yingluosanqian pushed a commit to yingluosanqian/sglang that referenced this pull request Dec 4, 2025
tonyluj pushed a commit to openanolis/sglang that referenced this pull request Dec 5, 2025
tonyluj pushed a commit to openanolis/sglang that referenced this pull request Dec 5, 2025
yuchengz816-bot pushed a commit to yuchengz816-bot/sglang that referenced this pull request Dec 8, 2025
Kevin-XiongC pushed a commit to novitalabs/sglang that referenced this pull request Dec 9, 2025
tonyluj pushed a commit to openanolis/sglang that referenced this pull request Dec 12, 2025
tonyluj pushed a commit to openanolis/sglang that referenced this pull request Dec 12, 2025
tonyluj pushed a commit to openanolis/sglang that referenced this pull request Dec 12, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants