Skip to content

Support Codex ChatGPT auth#248

Merged
emal-avala merged 1 commit intomainfrom
codex/codex-chatgpt-auth
Apr 27, 2026
Merged

Support Codex ChatGPT auth#248
emal-avala merged 1 commit intomainfrom
codex/codex-chatgpt-auth

Conversation

@emal-avala
Copy link
Copy Markdown
Member

Summary

  • Adds auth_mode = "codex_chatgpt" / --auth-mode codex_chatgpt to reuse an existing codex login ChatGPT session without storing tokens in agent-code config.
  • Adds Codex auth.json token loading/refresh and routes this auth mode through an OpenAI Responses provider path for https://chatgpt.com/backend-api/codex.
  • Documents the setup flow and updates ROADMAP 7.11 to mark this as partial OAuth progress while leaving full browser OAuth/keychain UX open.

Test plan

  • cargo check --all-targets
  • cargo clippy --all-targets -- -D warnings
  • cargo fmt --all -- --check
  • cargo test -p agent-code-lib codex_auth
  • cargo test -p agent-code-lib openai::tests
  • cargo test -p agent-code-lib api_config_parses_codex_chatgpt_auth_mode_from_toml
  • cargo test --workspace --lib --tests -- --skip bwrap
  • Live smoke: cargo run -p agent-code -- --auth-mode codex_chatgpt --model gpt-5.4 --prompt "Reply with exactly: ok" --max-turns 2 --verbose
  • cargo test --all-targets currently fails in this container on existing bwrap sandbox tests with bwrap: setting up uid map: Permission denied.

@emal-avala emal-avala marked this pull request as ready for review April 27, 2026 04:08
@emal-avala emal-avala merged commit 6f6de41 into main Apr 27, 2026
14 checks passed
@emal-avala emal-avala deleted the codex/codex-chatgpt-auth branch April 27, 2026 04:08
@emal-avala emal-avala mentioned this pull request Apr 27, 2026
6 tasks
Copy link
Copy Markdown

@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: 150961eed0

ℹ️ 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 +270 to +274
let mut body = serde_json::json!({
"model": request.model,
"input": messages_to_responses_input(&request.messages),
"stream": true,
"store": false,
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Forward max token budget to Responses API

build_responses_body never maps request.max_tokens into the Responses payload (e.g. max_output_tokens), so api.max_output_tokens and per-turn token caps are silently ignored in codex_chatgpt mode. That can materially increase latency/cost and defeats callers that expect provider implementations to honor ProviderRequest::max_tokens like the other backends do.

Useful? React with 👍 / 👎.

Comment on lines +627 to +629
if response_has_function_call(parsed.get("response")) {
stop_reason = Some(StopReason::ToolUse);
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Handle incomplete Responses as MaxTokens stops

The response.completed path only marks ToolUse and otherwise falls back to EndTurn, but never checks response.status / incomplete_details for truncation reasons like max_output_tokens. In that case, truncated generations are treated as successful completions, so the max-output recovery path in query/mod.rs (which depends on StopReason::MaxTokens) will not run.

Useful? React with 👍 / 👎.

@emal-avala emal-avala changed the title [codex] support Codex ChatGPT auth Support Codex ChatGPT auth Apr 27, 2026
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