Skip to content

The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.

fix(codex): surface session-expired error when OAuth token refresh fails on expired token

shanuf1a71a6b3581
diff --git a/src/openhuman/inference/openai_oauth/store.rs b/src/openhuman/inference/openai_oauth/store.rs
index 807fb42635..2a9923b1ca 100644
--- a/src/openhuman/inference/openai_oauth/store.rs
+++ b/src/openhuman/inference/openai_oauth/store.rs
@@ -332,6 +332,18 @@ pub fn lookup_openai_oauth_credentials(
}
Err(e) => {
log::warn!("{LOG_PREFIX} oauth refresh failed: {e}");
+ // If the token has already passed its expiry there is no
+ // point proceeding — the next inference call will hit 401
+ // and the user sees a generic error with no remedy.
+ // Surface it as a session-expired error so the classifier
+ // routes the user to sign in again rather than showing
+ // "Something went wrong". (#5869)
+ if token_set.is_expiring_within(std::time::Duration::ZERO) {
+ return Err(format!(
+ "Codex session expired — token refresh failed: {e}. \
+ Please sign in to Codex again in Settings → Integrations."
+ ));
+ }
}
}
}