openai/codex · error · anyhow::Error
Agent Identity authentication is unavailable
Error message
Agent Identity authentication is unavailable
What it means
Returned by load_exec_server_remote_auth_provider when AuthManager::shared_from_config did not yield an auth mode compatible with remote exec-server use — the resolved CodexAuth does not satisfy is_supported_exec_server_remote_auth (ChatGPT or API key auth) or the manager itself is unavailable for this configuration.
Solutions
- Verify CODEX_ACCESS_TOKEN is valid and not expired
- Run `codex login` to populate auth state
- Check auth.json/CODEX_HOME is readable
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at codex-rs/cli/src/main.rs:1985 when the library encounters an invalid state.
Common situations: See trigger scenarios.
Understand the failure class
- Authentication and authorization failures — expired tokens, bad credentials, and missing scopes.
AI-assisted analysis of openai/codex@339751715c (2026-08-25).
Data as JSON: /api/errors/046f0abf4a28d8a5.
Report an issue: GitHub.
Appendix: source
Thrown at codex-rs/cli/src/main.rs:1985
.await
.map_err(anyhow::Error::from_boxed)
}
}
async fn load_exec_server_remote_auth_provider(
config: &codex_core::config::Config,
base_url: &str,
use_agent_identity_auth: bool,
) -> anyhow::Result<codex_api::SharedAuthProvider> {
if use_agent_identity_auth {
read_codex_access_token_from_env().ok_or_else(|| {
anyhow::anyhow!("CODEX_ACCESS_TOKEN is required when --use-agent-identity-auth is set")
})?;
let auth = AuthManager::shared_from_config(config, /*enable_codex_api_key_env*/ false)
.await?
.auth()
.await
.ok_or_else(|| anyhow::anyhow!("Agent Identity authentication is unavailable"))?;
if !matches!(auth, CodexAuth::AgentIdentity(_)) {
anyhow::bail!(
"CODEX_ACCESS_TOKEN did not provide permitted Agent Identity authentication"
);
}
return Ok(codex_model_provider::auth_provider_from_auth(&auth));
}
let (auth_manager, auth) = load_exec_server_remote_auth(
config,
"remote exec-server registration requires ChatGPT authentication or API key authentication; run `codex login` or set CODEX_API_KEY",
)
.await?;
if !is_supported_exec_server_remote_auth(&auth) {
anyhow::bail!(
"remote exec-server registration requires ChatGPT authentication or API key authentication; Agent Identity auth requires --use-agent-identity-auth"
);View on GitHub (pinned to 339751715c)