Skip to content

v6.8.31#394

Merged
luispater merged 8 commits intomainfrom
plus
Feb 27, 2026
Merged

v6.8.31#394
luispater merged 8 commits intomainfrom
plus

Conversation

@luispater
Copy link

No description provided.

@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 introduces significant enhancements to API interaction and system stability. It refines how the system handles rate limits from external APIs by parsing detailed retry information and implements a concurrency control mechanism for authentication refreshes. Additionally, it expands the system's capabilities by integrating a new AI model, ensuring broader compatibility and functionality.

Highlights

  • API Error Handling: Improved Codex API error handling to specifically parse and utilize retry-after information from HTTP headers or error bodies, enabling more intelligent rate limit management.
  • New Model Integration: Added support for the new 'gemini-3.1-flash-image' model, including its specific thinking support configuration.
  • Concurrency Control for Auth Refreshes: Implemented a concurrency limit for authentication token refreshes to prevent resource exhaustion or rate limiting issues during peak refresh cycles.
  • API Response Enhancement: Exposed the 'next_retry_after' timestamp in the authentication file API response, providing clients with visibility into when a rate-limited authentication can be retried.

🧠 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/api/handlers/management/auth_files.go
    • Added 'next_retry_after' field to the authentication file entry in the API response.
  • internal/registry/model_definitions_static_data.go
    • Added configuration for the 'gemini-3.1-flash-image' model, including its thinking support levels.
  • internal/runtime/executor/codex_executor.go
    • Replaced direct statusErr creation with newCodexStatusErr in Execute, executeCompact, and ExecuteStream functions.
    • Introduced newCodexStatusErr function to encapsulate statusErr creation and integrate retry-after logic.
    • Added parseCodexRetryAfter function to extract retry duration from HTTP 429 responses based on error body content.
  • internal/runtime/executor/codex_executor_retry_test.go
    • Added a new test file with comprehensive unit tests for the parseCodexRetryAfter function, covering various retry scenarios.
  • sdk/cliproxy/auth/conductor.go
    • Defined refreshMaxConcurrency constant to limit concurrent authentication refreshes.
    • Added a refreshSemaphore channel to the Manager struct to control concurrency.
    • Initialized the refreshSemaphore in the NewManager function.
    • Introduced refreshAuthWithLimit function to acquire a semaphore lock before calling refreshAuth.
    • Modified checkRefreshes to use refreshAuthWithLimit for concurrent refresh operations.
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.

@luispater luispater merged commit 65a8781 into router-for-me:main Feb 27, 2026
2 checks passed
@luispater luispater deleted the plus branch February 27, 2026 08:18
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 introduces several improvements across the codebase. It adds support for parsing Retry-After information from Codex API error responses to handle rate limiting more effectively. Concurrency for authentication token refreshes is now limited to improve stability. Additionally, the next_retry_after field is exposed in the auth files management API, and a new model configuration has been added. The changes are well-implemented and include relevant tests. My review includes one suggestion to refactor a new test file to use a table-driven approach for better maintainability.

Comment on lines +10 to +61
func TestParseCodexRetryAfter(t *testing.T) {
now := time.Unix(1_700_000_000, 0)

t.Run("resets_in_seconds", func(t *testing.T) {
body := []byte(`{"error":{"type":"usage_limit_reached","resets_in_seconds":123}}`)
retryAfter := parseCodexRetryAfter(http.StatusTooManyRequests, body, now)
if retryAfter == nil {
t.Fatalf("expected retryAfter, got nil")
}
if *retryAfter != 123*time.Second {
t.Fatalf("retryAfter = %v, want %v", *retryAfter, 123*time.Second)
}
})

t.Run("prefers resets_at", func(t *testing.T) {
resetAt := now.Add(5 * time.Minute).Unix()
body := []byte(`{"error":{"type":"usage_limit_reached","resets_at":` + itoa(resetAt) + `,"resets_in_seconds":1}}`)
retryAfter := parseCodexRetryAfter(http.StatusTooManyRequests, body, now)
if retryAfter == nil {
t.Fatalf("expected retryAfter, got nil")
}
if *retryAfter != 5*time.Minute {
t.Fatalf("retryAfter = %v, want %v", *retryAfter, 5*time.Minute)
}
})

t.Run("fallback when resets_at is past", func(t *testing.T) {
resetAt := now.Add(-1 * time.Minute).Unix()
body := []byte(`{"error":{"type":"usage_limit_reached","resets_at":` + itoa(resetAt) + `,"resets_in_seconds":77}}`)
retryAfter := parseCodexRetryAfter(http.StatusTooManyRequests, body, now)
if retryAfter == nil {
t.Fatalf("expected retryAfter, got nil")
}
if *retryAfter != 77*time.Second {
t.Fatalf("retryAfter = %v, want %v", *retryAfter, 77*time.Second)
}
})

t.Run("non-429 status code", func(t *testing.T) {
body := []byte(`{"error":{"type":"usage_limit_reached","resets_in_seconds":30}}`)
if got := parseCodexRetryAfter(http.StatusBadRequest, body, now); got != nil {
t.Fatalf("expected nil for non-429, got %v", *got)
}
})

t.Run("non usage_limit_reached error type", func(t *testing.T) {
body := []byte(`{"error":{"type":"server_error","resets_in_seconds":30}}`)
if got := parseCodexRetryAfter(http.StatusTooManyRequests, body, now); got != nil {
t.Fatalf("expected nil for non-usage_limit_reached, got %v", *got)
}
})
}

Choose a reason for hiding this comment

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

medium

This test function can be refactored into a table-driven test to improve maintainability and make it easier to add new test cases. This approach reduces code duplication and clearly separates test cases' data from the test logic.

func TestParseCodexRetryAfter(t *testing.T) {
	now := time.Unix(1_700_000_000, 0)
	resetAtFuture := now.Add(5 * time.Minute).Unix()
	resetAtPast := now.Add(-1 * time.Minute).Unix()

	durationPtr := func(d time.Duration) *time.Duration {
		return &d
	}

	testCases := []struct {
		name       string
		statusCode int
		body       []byte
		want       *time.Duration
	}{
		{
			name:       "resets_in_seconds",
			statusCode: http.StatusTooManyRequests,
			body:       []byte(`{"error":{"type":"usage_limit_reached","resets_in_seconds":123}}`),
			want:       durationPtr(123 * time.Second),
		},
		{
			name:       "prefers resets_at",
			statusCode: http.StatusTooManyRequests,
			body:       []byte(`{"error":{"type":"usage_limit_reached","resets_at":` + itoa(resetAtFuture) + `,"resets_in_seconds":1}}`),
			want:       durationPtr(5 * time.Minute),
		},
		{
			name:       "fallback when resets_at is past",
			statusCode: http.StatusTooManyRequests,
			body:       []byte(`{"error":{"type":"usage_limit_reached","resets_at":` + itoa(resetAtPast) + `,"resets_in_seconds":77}}`),
			want:       durationPtr(77 * time.Second),
		},
		{
			name:       "non-429 status code",
			statusCode: http.StatusBadRequest,
			body:       []byte(`{"error":{"type":"usage_limit_reached","resets_in_seconds":30}}`),
			want:       nil,
		},
		{
			name:       "non usage_limit_reached error type",
			statusCode: http.StatusTooManyRequests,
			body:       []byte(`{"error":{"type":"server_error","resets_in_seconds":30}}`),
			want:       nil,
		},
		{
			name:       "empty body",
			statusCode: http.StatusTooManyRequests,
			body:       []byte{},
			want:       nil,
		},
		{
			name:       "no retry fields",
			statusCode: http.StatusTooManyRequests,
			body:       []byte(`{"error":{"type":"usage_limit_reached"}}`),
			want:       nil,
		},
	}

	for _, tc := range testCases {
		t.Run(tc.name, func(t *testing.T) {
			got := parseCodexRetryAfter(tc.statusCode, tc.body, now)

			if tc.want == nil {
				if got != nil {
					t.Fatalf("expected nil, got %v", *got)
				}
				return
			}

			if got == nil {
				t.Fatalf("expected %v, got nil", *tc.want)
			}

			if *got != *tc.want {
				t.Fatalf("got %v, want %v", *got, *tc.want)
			}
		})
	}
}

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.

3 participants