fix(codex): translate service_tier "fast" to "priority" instead of stripping it#431
fix(codex): translate service_tier "fast" to "priority" instead of stripping it#431ynlmz wants to merge 1 commit intorouter-for-me:mainfrom
Conversation
Summary of ChangesHello, 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 addresses an issue where client-specified Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Changelog
Using Gemini Code AssistThe 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
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 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
|
There was a problem hiding this comment.
Code Review
This pull request correctly translates the service_tier from "fast" to "priority" for Codex requests, instead of stripping it. The change is well-implemented and also includes an update to a related code comment for better clarity. I have one suggestion to improve maintainability by using constants for the string literals introduced.
| if v := gjson.GetBytes(rawJSON, "service_tier"); v.Exists() && v.String() == "fast" { | ||
| rawJSON, _ = sjson.SetBytes(rawJSON, "service_tier", "priority") | ||
| } |
There was a problem hiding this comment.
To improve readability and maintainability, consider extracting the magic strings "service_tier", "fast", and "priority" into named constants defined at the package level.
For example:
const (
serviceTierField = "service_tier"
openAIServiceTierFast = "fast"
codexServiceTierPriority = "priority"
)Then you can use these constants here:
if v := gjson.GetBytes(rawJSON, serviceTierField); v.Exists() && v.String() == openAIServiceTierFast {
rawJSON, _ = sjson.SetBytes(rawJSON, serviceTierField, codexServiceTierPriority)
}
Problem
The Codex Responses translator currently strips the
service_tierfield entirely before forwarding requests. This means clients requesting"service_tier": "fast"silently lose their tier preference, and all Codex requests are treated as default tier.Solution
Instead of deleting
service_tier, translate the OpenAI-standard value"fast"to the Codex-equivalent"priority". All otherservice_tiervalues are passed through unchanged.Before:
After:
Changes
internal/translator/codex/openai/responses/codex_openai-responses_request.goservice_tiervalue translation ("fast"→"priority")service_tierdeletionTesting
Verified manually against Codex backend — requests with
"service_tier": "fast"now correctly resolve to priority tier responses.