Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 14 additions & 8 deletions codex-rs/core/src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -142,9 +142,12 @@ impl ModelClient {
}

let auth_manager = self.auth_manager.clone();
let auth = auth_manager.as_ref().and_then(|m| m.auth());

let auth_mode = auth.as_ref().map(|a| a.mode);
let auth_mode = auth_manager
.as_ref()
.and_then(|m| m.auth())
.as_ref()
.map(|a| a.mode);

let store = prompt.store && auth_mode != Some(AuthMode::ChatGPT);

Expand Down Expand Up @@ -211,15 +214,18 @@ impl ModelClient {
let mut attempt = 0;
let max_retries = self.provider.request_max_retries();

trace!(
"POST to {}: {}",
self.provider.get_full_url(&auth),
serde_json::to_string(&payload)?
);

loop {
attempt += 1;

// Always fetch the latest auth in case a prior attempt refreshed the token.
let auth = auth_manager.as_ref().and_then(|m| m.auth());

trace!(
"POST to {}: {}",
self.provider.get_full_url(&auth),
serde_json::to_string(&payload)?
);

let mut req_builder = self
.provider
.create_request_builder(&self.client, &auth)
Expand Down
Loading