Conversation
|
This pull request targeted The base branch has been automatically changed to |
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
🟡 Changes recommended
Configured User-Agent handling remains incomplete and inconsistent, with additional test, documentation, and shared-default updates needed.
Get a fresh assessment by requesting another Copilot review.
Pull request overview
Adds configured or official fallback Codex User-Agent headers to OAuth token exchange and refresh requests.
Changes:
- Resolves configured or fallback User-Agent values.
- Applies them to exchange and refresh requests.
- Adds fallback, configuration, and refresh tests.
File summaries
| File | Reviewed changes and findings |
|---|---|
internal/auth/codex/openai_auth.go |
Adds User-Agent resolution and request headers. Findings: three nit issues (3, 3, and 1 votes) covering exchange-test coverage, shared default constant, and configuration documentation; two moderate issues (1 vote each) covering fetch_codex_models config propagation and precedence consistency with inference requests. |
internal/auth/codex/openai_auth_test.go |
Tests fallback, configuration override, and refresh behavior. |
Review details
Suppressed comments (3)
internal/auth/codex/openai_auth.go:69
CodexHeaderDefaults.UserAgentis documented inconfig.example.yaml:717-723andinternal/config/config_types.go:130-136as applying only to Codex model requests, but this new helper also applies it to the OAuth token endpoint. Update the configuration documentation so users know that the setting controls token exchange and refresh requests as well.
if ua := strings.TrimSpace(o.cfg.CodexHeaderDefaults.UserAgent); ua != "" {
internal/auth/codex/openai_auth.go:62
- The configured UA is still lost on the
fetch_codex_modelsrefresh path:cmd/fetch_codex_models/main.go:197callsNewCodexAuthWithProxyURL(nil, auth.ProxyURL)even though that command loadedcfgfromconfig.yamlat lines 85-92. A configuredcodex-header-defaults.user-agentis therefore ignored for this supported background refresh path; propagate the loaded config into the auth service.
cfg: cfg,
internal/auth/codex/openai_auth.go:70
- When
codex-header-defaults.user-agentis configured, this makes OAuth requests use that value, but inference requests for models withconfig.override_headerstill unconditionally replace the UA withcodexUserAgentinapplyModelHeaderOverrides(covered byinternal/runtime/executor/codex_websockets_executor_test.go:1923-1943). The two paths therefore still have different fingerprints, contrary to the PR's stated consistency goal; align the precedence in both paths.
func (o *CodexAuth) effectiveUserAgent() string {
if o != nil && o.cfg != nil {
if ua := strings.TrimSpace(o.cfg.CodexHeaderDefaults.UserAgent); ua != "" {
return ua
- Files reviewed: 2/2 changed files
- Comments generated: 2
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| ClientID = "app_EMoamEEZ73f0CkXaXp7hrann" | ||
| RedirectURI = "http://localhost:1455/auth/callback" | ||
| codexRefreshTimeout = 30 * time.Second | ||
| defaultCodexAuthUserAgent = "codex-tui/0.154.0 (Mac OS 26.5.2; arm64) iTerm.app/3.6.11 (codex-tui; 0.154.0)" |
|
|
||
| req.Header.Set("Content-Type", "application/x-www-form-urlencoded") | ||
| req.Header.Set("Accept", "application/json") | ||
| req.Header.Set("User-Agent", o.effectiveUserAgent()) |
…change token test
Summary
Currently,
internal/auth/codex/openai_auth.gosends token exchange and token refresh requests tohttps://auth.openai.com/oauth/tokenwithout setting aUser-Agentheader. As a result, Go's defaulthttp.Clientautomatically emitsUser-Agent: Go-http-client/2.0.This PR ensures that all requests to the token endpoint carry an official Codex client
User-Agent:codex-header-defaults.user-agentfromconfig.yamlif configured.codex-tui/0.154.0 (Mac OS 26.5.2; arm64) iTerm.app/3.6.11 (codex-tui; 0.154.0)).Benefits
Go-http-clientfingerprint during background OAuth token refreshes.