Skip to content

fix(codex): translate service_tier "fast" to "priority" instead of stripping it#431

Open
ynlmz wants to merge 1 commit intorouter-for-me:mainfrom
ynlmz:fix/codex-service-tier-translation
Open

fix(codex): translate service_tier "fast" to "priority" instead of stripping it#431
ynlmz wants to merge 1 commit intorouter-for-me:mainfrom
ynlmz:fix/codex-service-tier-translation

Conversation

@ynlmz
Copy link

@ynlmz ynlmz commented Mar 11, 2026

Problem

The Codex Responses translator currently strips the service_tier field 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 other service_tier values are passed through unchanged.

Before:

rawJSON, _ = sjson.DeleteBytes(rawJSON, "service_tier")

After:

if v := gjson.GetBytes(rawJSON, "service_tier"); v.Exists() && v.String() == "fast" {
    rawJSON, _ = sjson.SetBytes(rawJSON, "service_tier", "priority")
}

Changes

  • internal/translator/codex/openai/responses/codex_openai-responses_request.go
    • Added service_tier value translation ("fast""priority")
    • Removed the unconditional service_tier deletion
    • Updated comment to reflect that both token limit and sampling fields are stripped

Testing

Verified manually against Codex backend — requests with "service_tier": "fast" now correctly resolve to priority tier responses.

@gemini-code-assist
Copy link

Summary of Changes

Hello, 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 service_tier preferences were being lost during translation to the Codex backend. By introducing a specific translation for the "fast" tier to "priority" and ceasing the blanket removal of the service_tier field, the system now correctly honors client preferences for priority processing, ensuring that requests are handled with the intended service level.

Highlights

  • Service Tier Translation: Implemented logic to translate the OpenAI-standard service_tier value of "fast" to the Codex-equivalent "priority" when processing requests.
  • Removed Unconditional Stripping: The previous behavior of unconditionally stripping the service_tier field from requests has been removed, allowing other service_tier values to pass through unchanged.
  • Comment Update: Updated an inline comment to accurately reflect that both token limit and sampling fields are stripped during the translation process.

🧠 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
  • internal/translator/codex/openai/responses/codex_openai-responses_request.go
    • Added conditional logic to translate service_tier from "fast" to "priority".
    • Removed the unconditional deletion of the service_tier field.
    • Updated a comment to include 'sampling fields' in the list of stripped fields.
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.

Copy link

@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 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.

Comment on lines +23 to +25
if v := gjson.GetBytes(rawJSON, "service_tier"); v.Exists() && v.String() == "fast" {
rawJSON, _ = sjson.SetBytes(rawJSON, "service_tier", "priority")
}

Choose a reason for hiding this comment

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

medium

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)
}

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.

1 participant