mirror of
https://github.com/openai/codex.git
synced 2026-04-24 14:45:27 +00:00
client
This commit is contained in:
@@ -2193,10 +2193,18 @@ async fn try_run_turn(
|
||||
});
|
||||
|
||||
sess.persist_rollout_items(&[rollout_item]).await;
|
||||
if let Some(message) = maybe_codex_status_warning(sess.as_ref()).await {
|
||||
sess.send_event(&turn_context, EventMsg::Warning(WarningEvent { message }))
|
||||
.await;
|
||||
}
|
||||
let sess_clone = Arc::clone(&sess);
|
||||
let turn_context_clone = Arc::clone(&turn_context);
|
||||
tokio::spawn(async move {
|
||||
if let Some(message) = maybe_codex_status_warning(sess_clone.as_ref()).await {
|
||||
sess_clone
|
||||
.send_event(
|
||||
&turn_context_clone,
|
||||
EventMsg::Warning(WarningEvent { message }),
|
||||
)
|
||||
.await;
|
||||
}
|
||||
});
|
||||
|
||||
let mut stream = turn_context
|
||||
.client
|
||||
|
||||
@@ -70,15 +70,15 @@ async fn fetch_codex_health() -> Result<ComponentHealth> {
|
||||
let status_widget_url = status_widget_url();
|
||||
|
||||
let client = reqwest::Client::builder()
|
||||
.connect_timeout(Duration::from_secs(5))
|
||||
.timeout(Duration::from_secs(10))
|
||||
.connect_timeout(Duration::from_millis(200))
|
||||
.timeout(Duration::from_millis(300))
|
||||
.build()
|
||||
.context("building HTTP client")?;
|
||||
|
||||
let transport = ReqwestTransport::new(client);
|
||||
let policy = RetryPolicy {
|
||||
max_attempts: 2,
|
||||
base_delay: Duration::from_millis(200),
|
||||
max_attempts: 0,
|
||||
base_delay: Duration::from_millis(100),
|
||||
retry_on: RetryOn {
|
||||
retry_429: true,
|
||||
retry_5xx: true,
|
||||
|
||||
@@ -99,7 +99,7 @@ async fn warns_once_per_status_change_only_when_unhealthy() {
|
||||
let _responses_mock = mount_sse_once_with_delay(
|
||||
&responses_server,
|
||||
stalled_response,
|
||||
Duration::from_millis(2000),
|
||||
Duration::from_millis(300),
|
||||
)
|
||||
.await;
|
||||
|
||||
@@ -132,31 +132,24 @@ async fn warns_once_per_status_change_only_when_unhealthy() {
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
let mut task_completes = 0usize;
|
||||
let mut warnings = Vec::new();
|
||||
while task_completes < 2 {
|
||||
let mut saw_warning = false;
|
||||
let mut saw_complete = false;
|
||||
while !(saw_warning && saw_complete) {
|
||||
let event = codex.next_event().await.expect("event");
|
||||
match event.msg {
|
||||
EventMsg::Warning(WarningEvent { message }) => warnings.push(message),
|
||||
EventMsg::TaskComplete(_) => task_completes += 1,
|
||||
EventMsg::Warning(WarningEvent { message }) => {
|
||||
assert_eq!(
|
||||
message,
|
||||
"Codex is experiencing a partial outage. If a response stalls, try again later. You can follow incident updates at status.openai.com.",
|
||||
);
|
||||
saw_warning = true;
|
||||
}
|
||||
EventMsg::TaskComplete(_) => {
|
||||
saw_complete = true;
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
|
||||
assert!(
|
||||
!warnings.is_empty(),
|
||||
"expected at least one warning for non-operational status"
|
||||
);
|
||||
assert_eq!(
|
||||
warnings[0],
|
||||
"Codex is experiencing a major outage. If a response stalls, try again later. You can follow incident updates at status.openai.com.",
|
||||
);
|
||||
if warnings.len() > 1 {
|
||||
assert_eq!(
|
||||
warnings[1],
|
||||
"Codex is experiencing a partial outage. If a response stalls, try again later. You can follow incident updates at status.openai.com.",
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
fn status_payload(status: &str) -> ResponseTemplate {
|
||||
|
||||
Reference in New Issue
Block a user