Skip to content

fix(acp): defer authentication until required - #924

Open
matt2e wants to merge 2 commits into
mainfrom
codex-broken
Open

fix(acp): defer authentication until required#924
matt2e wants to merge 2 commits into
mainfrom
codex-broken

Conversation

@matt2e

@matt2e matt2e commented Aug 21, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Defer ACP authentication until session creation/loading returns AuthRequired
  • Retry session setup after selecting a usable authentication method, preferring existing agent-managed logins over API-key methods
  • Add tests covering lazy authentication and auth-method selection

Tests

  • Push hooks passed: crates-fmt, crates-test, crates-lint, differ-ci, staged-ci

Signed-off-by: Matt Toohey <contact@matttoohey.com>

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

Copy link
Copy Markdown

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

ℹ️ About Codex in GitHub

Codex has been enabled to automatically 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 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread crates/acp-client/src/driver.rs Outdated
Comment on lines +2571 to +2573
AuthMethod::EnvVar(method) => method.vars.iter().all(|var| {
var.optional || std::env::var_os(&var.name).is_some_and(|value| !value.is_empty())
}),

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 Check credentials in the agent process environment

When an ACP agent requires an EnvVar method and its credential exists only in the captured working-directory shell environment, this checks the Staged process's std::env instead of the environment actually supplied to the agent via env_snapshot. This is common for GUI launches where API keys are loaded by shell initialization, and causes select_auth_method to reject a valid method after AuthRequired, preventing session creation even though the running agent received the credential. Pass the effective child environment into selection or let the agent validate the method.

Useful? React with 👍 / 👎.

Signed-off-by: Matt Toohey <contact@matttoohey.com>
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