Wait for requested delay in rate limit errors (#2266)

Fixes: https://github.com/openai/codex/issues/2131

Response doesn't have the delay in a separate field (yet) so parse the
message.
This commit is contained in:
pakrym-oai
2025-08-13 15:43:54 -07:00
committed by GitHub
parent 37fc4185ef
commit 41eb59a07d
5 changed files with 152 additions and 22 deletions

View File

@@ -1,6 +1,7 @@
use reqwest::StatusCode;
use serde_json;
use std::io;
use std::time::Duration;
use thiserror::Error;
use tokio::task::JoinError;
use uuid::Uuid;
@@ -42,8 +43,10 @@ pub enum CodexErr {
/// handshake has succeeded but **before** it finished emitting `response.completed`.
///
/// The Session loop treats this as a transient error and will automatically retry the turn.
///
/// Optionally includes the requested delay before retrying the turn.
#[error("stream disconnected before completion: {0}")]
Stream(String),
Stream(String, Option<Duration>),
#[error("no conversation with id: {0}")]
ConversationNotFound(Uuid),