Skip to content

feat(codex): add fast tier settings toggle - #367

Merged
diegosouzapw merged 2 commits into
diegosouzapw:mainfrom
kfiramar:feat-codex-fast-toggle
Mar 14, 2026
Merged

diegosouzapw merged 2 commits into
diegosouzapw:mainfrom
kfiramar:feat-codex-fast-toggle

Conversation

@kfiramar

@kfiramar kfiramar commented Mar 14, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • add a default-off dashboard setting for Codex fast service tier
  • inject the fast tier only for Codex requests that do not already set service_tier
  • preserve service_tier when translating OpenAI chat-completions requests into Responses requests

Testing

  • npm run test:plan3

@gemini-code-assist

Copy link
Copy Markdown
Contributor

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 introduces a new feature allowing users to configure a 'fast' service tier for Codex requests via a dashboard setting. When enabled, the system will automatically apply a 'priority' service tier to Codex requests that do not specify one, optimizing performance. It also ensures consistent handling of the service_tier parameter across different request translation processes, and includes the necessary API endpoints, UI components, and startup logic to support this new functionality.

Highlights

  • New Dashboard Setting: Introduced a new dashboard setting to enable a default-off 'fast' service tier for Codex requests.
  • Automatic Service Tier Injection: Implemented logic to automatically inject the 'priority' service tier for Codex requests if the client hasn't explicitly set one and the fast tier setting is enabled.
  • Service Tier Preservation: Ensured that the service_tier parameter is correctly preserved when translating OpenAI chat completion requests to Responses requests.
  • API and UI for Setting: Added a new API route and a dedicated UI component for managing this Codex fast service tier setting.

🧠 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
  • open-sse/executors/codex.ts
    • Added functions to manage and apply a default fast service tier, mapping 'fast' to 'priority' for Codex requests.
  • open-sse/translator/request/openai-responses.ts
    • Updated the translation logic to explicitly pass through the service_tier field from OpenAI to OpenAI Responses requests.
  • src/app/(dashboard)/dashboard/settings/components/CodexServiceTierTab.tsx
    • Created a new React component for the dashboard settings page, providing a toggle to enable/disable the Codex fast service tier.
  • src/app/(dashboard)/dashboard/settings/page.tsx
    • Integrated the CodexServiceTierTab component into the AI settings section of the dashboard.
  • src/app/api/settings/codex-service-tier/route.ts
    • Implemented GET and PUT API endpoints to retrieve and update the Codex fast service tier setting, persisting it to the local database.
  • src/instrumentation.ts
    • Modified the application startup process to load and apply the persisted Codex fast service tier setting.
  • src/shared/validation/schemas.ts
    • Defined a Zod schema (updateCodexServiceTierSchema) for validating the payload when updating the Codex service tier setting.
  • tests/unit/plan3-p0.test.mjs
    • Added new unit tests to verify the correct mapping of 'fast' service tier to 'priority' and the functionality of forcing the fast service tier from settings, as well as preserving service_tier during request translation.
Activity
  • No specific human activity (comments, reviews, or progress updates) has been recorded for this pull request yet.
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. ↩

@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 introduces a new dashboard setting to enable a 'fast' service tier for Codex requests by default. The changes include a new UI component for the setting, an API route to manage it, and updates to the Codex executor to apply the setting. The implementation is solid, but I have a couple of suggestions to improve error handling in the new UI component and to enhance type safety in the new API route.

Comment on lines +22 to +45
const save = async (nextEnabled: boolean) => {
setEnabled(nextEnabled);
setSaving(true);
setStatus("");

try {
const res = await fetch("/api/settings/codex-service-tier", {
method: "PUT",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({ enabled: nextEnabled }),
});

if (res.ok) {
setStatus("saved");
setTimeout(() => setStatus(""), 2000);
} else {
setStatus("error");
}
} catch {
setStatus("error");
} finally {
setSaving(false);
}
};

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.

high

The error handling in the save function can be improved:

  1. Silent Failure: The status is set to "error" on failure, but there is no corresponding UI element to display this error. This means the save operation fails silently for the user.
  2. Inconsistent State: The optimistic UI update is not reverted on failure, leaving the toggle in a state that doesn't match the backend.

To fix the inconsistent state, you can revert the enabled state on failure. For the silent failure, you should add a UI element to display when status === 'error'. Here is a suggestion to fix the state inconsistency:

  const save = async (nextEnabled: boolean) => {
    setEnabled(nextEnabled);
    setSaving(true);
    setStatus("");

    try {
      const res = await fetch("/api/settings/codex-service-tier", {
        method: "PUT",
        headers: { "Content-Type": "application/json" },
        body: JSON.stringify({ enabled: nextEnabled }),
      });

      if (res.ok) {
        setStatus("saved");
        setTimeout(() => setStatus(""), 2000);
      } else {
        setStatus("error");
        setEnabled(!nextEnabled);
      }
    } catch {
      setStatus("error");
      setEnabled(!nextEnabled);
    } finally {
      setSaving(false);
    }
  };

}
}

export async function PUT(request) {

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.

medium

For improved type safety and code clarity, the request parameter in the PUT handler should be typed. You can use the Request type from next/server.

You will need to update the import statement at the top of the file to include it:

import { NextResponse, type Request } from "next/server";
Suggested change
export async function PUT(request) {
export async function PUT(request: Request) {

@kilo-code-bot

kilo-code-bot Bot commented Mar 14, 2026 •

Copy link
Copy Markdown

Code Review Summary

Status: 1 Issue Found | Recommendation: Address before merge

Overview

Severity Count
CRITICAL 1
WARNING 0
SUGGESTION 0
Issue Details (click to expand)

CRITICAL

File Line Issue
src/app/api/settings/codex-service-tier/route.ts 47 Race condition - in-memory state updated before database persistence
Existing Comments (2)

The following issues were already flagged by previous reviewers and are NOT duplicated here:

File Line Issue
src/app/(dashboard)/dashboard/settings/components/CodexServiceTierTab.tsx 47 Error handling and state inconsistency on save failure
src/app/api/settings/codex-service-tier/route.ts N/A Missing type annotation for request parameter
Files Reviewed (8 files)
  • open-sse/executors/codex.ts - Added service tier normalization
  • open-sse/translator/request/openai-responses.ts - Pass through service_tier
  • src/app/(dashboard)/dashboard/settings/components/CodexServiceTierTab.tsx - New UI component
  • src/app/(dashboard)/dashboard/settings/page.tsx - Added new tab
  • src/app/api/settings/codex-service-tier/route.ts - New API endpoint
  • src/instrumentation.ts - Startup restoration of settings
  • src/shared/validation/schemas.ts - Added validation schema
  • tests/unit/plan3-p0.test.mjs - Added tests

Note: The existing comments cover important issues including error handling in the UI component and type safety. The race condition issue reported above is a new finding that should be addressed.

@kfiramar
kfiramar force-pushed the feat-codex-fast-toggle branch from a23ec7f to 2dfc356 Compare March 14, 2026 18:38
Add a default-off dashboard setting that injects Codex fast service tier only when the request did not already specify one.

Also preserve service_tier through OpenAI-to-Responses translation and restore the setting at startup.
@kfiramar
kfiramar force-pushed the feat-codex-fast-toggle branch from 2dfc356 to 00188f7 Compare March 14, 2026 18:41
}

const config = validation.data;
setDefaultFastServiceTierEnabled(config.enabled);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

CRITICAL: Race condition - in-memory state updated before database

The in-memory state (setDefaultFastServiceTierEnabled) is updated on line 47 BEFORE the database is updated on line 48. If updateSettings throws an error, the in-memory state will be inconsistent with the persisted state.

Consider updating the database first, then updating in-memory state, or wrap both in a transaction with rollback capability.

@diegosouzapw
diegosouzapw merged commit 27d66e4 into diegosouzapw:main Mar 14, 2026
diegosouzapw added a commit that referenced this pull request Mar 14, 2026
- PR #368: gpt-5.4 in Codex model registry (cx/gpt-5.4, codex/gpt-5.4)
- PR #367: Codex fast tier toggle (default-off, full stack, 48 tests)
- PR #366: Codex quota policy 5h/weekly with auto-rotation
- fix #356: analytics charts show provider display names not raw IDs
prakersh pushed a commit to prakersh/OmniRoute that referenced this pull request Mar 26, 2026
Thanks @kfiramar! Codex fast-tier toggle merged 🎉 — default-off, full stack (UI tab + API + executor injection + translator passthrough + startup restore). 48 tests passing. Users can now enable flex tier in Dashboard → Settings → Codex Service Tier.
prakersh pushed a commit to prakersh/OmniRoute that referenced this pull request Mar 26, 2026
- PR diegosouzapw#368: gpt-5.4 in Codex model registry (cx/gpt-5.4, codex/gpt-5.4)
- PR diegosouzapw#367: Codex fast tier toggle (default-off, full stack, 48 tests)
- PR diegosouzapw#366: Codex quota policy 5h/weekly with auto-rotation
- fix diegosouzapw#356: analytics charts show provider display names not raw IDs
Poid-ZA pushed a commit to Poid-ZA/OmniRoute that referenced this pull request Aug 5, 2026
Thanks @kfiramar! Codex fast-tier toggle merged 🎉 — default-off, full stack (UI tab + API + executor injection + translator passthrough + startup restore). 48 tests passing. Users can now enable flex tier in Dashboard → Settings → Codex Service Tier.
Poid-ZA pushed a commit to Poid-ZA/OmniRoute that referenced this pull request Aug 5, 2026
- PR diegosouzapw#368: gpt-5.4 in Codex model registry (cx/gpt-5.4, codex/gpt-5.4)
- PR diegosouzapw#367: Codex fast tier toggle (default-off, full stack, 48 tests)
- PR diegosouzapw#366: Codex quota policy 5h/weekly with auto-rotation
- fix diegosouzapw#356: analytics charts show provider display names not raw IDs
muhamadgalihsaputra pushed a commit to niyatna/NiyatnaRoute that referenced this pull request Sep 27, 2026
Thanks @kfiramar! Codex fast-tier toggle merged 🎉 — default-off, full stack (UI tab + API + executor injection + translator passthrough + startup restore). 48 tests passing. Users can now enable flex tier in Dashboard → Settings → Codex Service Tier.
muhamadgalihsaputra pushed a commit to niyatna/NiyatnaRoute that referenced this pull request Sep 27, 2026
- PR diegosouzapw#368: gpt-5.4 in Codex model registry (cx/gpt-5.4, codex/gpt-5.4)
- PR diegosouzapw#367: Codex fast tier toggle (default-off, full stack, 48 tests)
- PR diegosouzapw#366: Codex quota policy 5h/weekly with auto-rotation
- fix diegosouzapw#356: analytics charts show provider display names not raw IDs
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