Skip to content

fix(tui): allow localPassword-only management auth for standalone mode#2253

Closed
arjaygg wants to merge 3 commits intorouter-for-me:mainfrom
arjaygg:codex/standalone-management-auth-fix
Closed

fix(tui): allow localPassword-only management auth for standalone mode#2253
arjaygg wants to merge 3 commits intorouter-for-me:mainfrom
arjaygg:codex/standalone-management-auth-fix

Conversation

@arjaygg
Copy link

@arjaygg arjaygg commented Mar 20, 2026

Summary

  • allow the management middleware to accept standalone local-password auth without requiring a remote management key
  • keep the guard in place when no management credential source is configured at all

Testing

  • go test ./internal/api/handlers/management/...

Gemini CLI and others added 3 commits March 20, 2026 16:44
When no RemoteManagement.SecretKey and no MANAGEMENT_PASSWORD env var are
set, the middleware previously rejected all requests before reaching the
localPassword check. This caused TUI standalone mode to fail with
"embedded server is not ready" after all 30 polling retries received 403.

Fix adds `&& h.localPassword == ""` to the forbidden guard so that
standalone TUI sessions (which rely solely on the auto-generated
localPassword) can authenticate successfully.

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
@gemini-code-assist
Copy link
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 enhances the management authentication process by allowing local password-only access in standalone mode. It also improves model fallback reporting in the Gemini CLI Executor and adds tracking for model fallback events in usage statistics, providing more detailed insights into model usage.

Highlights

  • Management Authentication: The management middleware now accepts standalone local-password authentication for standalone mode, allowing access without requiring a remote management key.
  • Model Fallback Reporting: Introduced reporting of model fallback scenarios in Gemini CLI Executor, setting the x-cliproxy-model-fallback header to indicate when a different model is used.
  • Usage Statistics: Enhanced usage statistics to track model fallback events, including a new totalFailovers metric and the recording of both requested and actual models.

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

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.

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

The pull request introduces comprehensive changes to support model failover tracking and enhances management authentication for standalone mode. Key updates include adding RequestedModel and ActualModel fields to usage reporting structures, implementing logic to record model fallbacks, and updating the management middleware to accept localPassword for localhost-only access. The changes are well-integrated across multiple files, ensuring that usage statistics accurately reflect model fallbacks and that the management interface is secure yet flexible for TUI standalone deployments. The modifications to cliPreviewFallbackOrder also reflect updated model fallback sequences, which is a data-driven improvement.

@arjaygg arjaygg closed this Mar 20, 2026
@arjaygg arjaygg deleted the codex/standalone-management-auth-fix branch March 20, 2026 11:19
Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: dff3e67aee

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines 774 to 778
return []string{
// "gemini-2.5-pro-preview-05-06",
// "gemini-2.5-pro-preview-06-05",
"gemini-2.0-pro-exp-02-05",
"gemini-2.0-flash",
"gemini-1.5-pro",
}

Choose a reason for hiding this comment

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

P2 Badge Avoid enabling Gemini CLI fallbacks that CountTokens can't use

Adding extra candidates here makes GeminiCLIExecutor.CountTokens start retrying on 429, but that function still loops with for range models and builds every request from baseModel instead of the fallback entry. For throttled gemini-2.5-* count-tokens calls, this will now resend the same upstream request 3-4 times, increasing latency and quota pressure while still failing instead of ever trying gemini-2.0-*/1.5-*.

Useful? React with 👍 / 👎.

Comment on lines +383 to +385
if attemptModel != baseModel {
reporter.setActualModel(attemptModel)
}

Choose a reason for hiding this comment

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

P2 Badge Report Gemini CLI failovers for non-stream responses too

This only updates actualModel for ExecuteStream. The non-stream Execute path uses the same 429 fallback loop but still publishes usage with RequestedModel == ActualModel and returns upstream headers unchanged, so regular chat/completions requests that fall back from gemini-2.5-* to 2.0/1.5 are invisible to both clients and the new total_failovers accounting. The reporting now depends on whether the caller set stream=true.

Useful? React with 👍 / 👎.

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