-
Notifications
You must be signed in to change notification settings - Fork 12k
refactor: load agent identity runtime eagerly #19763
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -212,7 +212,7 @@ impl CodexAuth { | |
| "agent identity auth is missing an agent identity token.", | ||
| )); | ||
| }; | ||
| return Self::from_agent_identity_jwt(&agent_identity); | ||
| return Self::from_agent_identity_jwt(&agent_identity).await; | ||
| } | ||
|
|
||
| let storage_mode = auth_dot_json.storage_mode(auth_credentials_store_mode); | ||
|
|
@@ -246,9 +246,9 @@ impl CodexAuth { | |
| .await | ||
| } | ||
|
|
||
| pub fn from_agent_identity_jwt(jwt: &str) -> std::io::Result<Self> { | ||
| pub async fn from_agent_identity_jwt(jwt: &str) -> std::io::Result<Self> { | ||
| let record = AgentIdentityAuthRecord::from_agent_identity_jwt(jwt)?; | ||
| Ok(Self::AgentIdentity(AgentIdentityAuth::new(record))) | ||
| Ok(Self::AgentIdentity(AgentIdentityAuth::load(record).await?)) | ||
|
Comment on lines
+249
to
+251
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Useful? React with 👍 / 👎.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We shouldn't be able to start up Codex Agent Identity without network access, this is fine. |
||
| } | ||
|
|
||
| pub fn auth_mode(&self) -> AuthMode { | ||
|
|
@@ -322,16 +322,6 @@ impl CodexAuth { | |
| } | ||
| } | ||
|
|
||
| pub async fn initialize_runtime( | ||
| &self, | ||
| _chatgpt_base_url: Option<String>, | ||
| ) -> std::io::Result<()> { | ||
| match self { | ||
| Self::AgentIdentity(auth) => auth.ensure_runtime().await, | ||
| Self::ApiKey(_) | Self::Chatgpt(_) | Self::ChatgptAuthTokens(_) => Ok(()), | ||
| } | ||
| } | ||
|
|
||
| /// Returns `None` if Codex backend auth does not expose an account id. | ||
| pub fn get_account_id(&self) -> Option<String> { | ||
| match self { | ||
|
|
@@ -749,7 +739,9 @@ async fn load_auth( | |
| } | ||
|
|
||
| if let Some(agent_identity) = read_codex_agent_identity_from_env() { | ||
| return CodexAuth::from_agent_identity_jwt(&agent_identity).map(Some); | ||
| return CodexAuth::from_agent_identity_jwt(&agent_identity) | ||
| .await | ||
| .map(Some); | ||
| } | ||
|
|
||
| // Fall back to the configured persistent store (file/keyring/auto) for managed auth. | ||
|
|
@@ -1400,12 +1392,7 @@ impl AuthManager { | |
| tracing::error!("Failed to refresh token: {}", err); | ||
| return Some(auth); | ||
| } | ||
| let auth = self.auth_cached()?; | ||
| if let Err(err) = auth.initialize_runtime(self.chatgpt_base_url.clone()).await { | ||
| tracing::error!("Failed to initialize auth runtime: {err}"); | ||
| return None; | ||
| } | ||
| Some(auth) | ||
| self.auth_cached() | ||
| } | ||
|
|
||
| /// Force a reload of the auth information from auth.json. Returns | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.