mirror of
https://github.com/openai/codex.git
synced 2026-05-03 02:46:39 +00:00
Add safety check notification and error handling (#19055)
Adds a new app-server notification that fires when a user account has been flagged for potential safety reasons.
This commit is contained in:
@@ -110,6 +110,8 @@ pub enum CodexErr {
|
||||
UsageLimitReached(UsageLimitReachedError),
|
||||
#[error("Selected model is at capacity. Please try a different model.")]
|
||||
ServerOverloaded,
|
||||
#[error("{message}")]
|
||||
CyberPolicy { message: String },
|
||||
#[error("{0}")]
|
||||
ResponseStreamFailed(ResponseStreamFailed),
|
||||
#[error("{0}")]
|
||||
@@ -186,7 +188,8 @@ impl CodexErr {
|
||||
| CodexErr::Spawn
|
||||
| CodexErr::SessionConfiguredNotFirstEvent
|
||||
| CodexErr::UsageLimitReached(_)
|
||||
| CodexErr::ServerOverloaded => false,
|
||||
| CodexErr::ServerOverloaded
|
||||
| CodexErr::CyberPolicy { .. } => false,
|
||||
CodexErr::Stream(..)
|
||||
| CodexErr::Timeout
|
||||
| CodexErr::UnexpectedStatus(_)
|
||||
@@ -217,6 +220,7 @@ impl CodexErr {
|
||||
| CodexErr::QuotaExceeded
|
||||
| CodexErr::UsageNotIncluded => CodexErrorInfo::UsageLimitExceeded,
|
||||
CodexErr::ServerOverloaded => CodexErrorInfo::ServerOverloaded,
|
||||
CodexErr::CyberPolicy { .. } => CodexErrorInfo::CyberPolicy,
|
||||
CodexErr::RetryLimit(_) => CodexErrorInfo::ResponseTooManyFailedAttempts {
|
||||
http_status_code: self.http_status_code_value(),
|
||||
},
|
||||
|
||||
@@ -1538,6 +1538,9 @@ pub enum EventMsg {
|
||||
/// Model routing changed from the requested model to a different model.
|
||||
ModelReroute(ModelRerouteEvent),
|
||||
|
||||
/// Backend recommends additional account verification for this turn.
|
||||
ModelVerification(ModelVerificationEvent),
|
||||
|
||||
/// Conversation history was compacted (either automatically or manually).
|
||||
ContextCompacted(ContextCompactedEvent),
|
||||
|
||||
@@ -1964,6 +1967,7 @@ pub enum CodexErrorInfo {
|
||||
ContextWindowExceeded,
|
||||
UsageLimitExceeded,
|
||||
ServerOverloaded,
|
||||
CyberPolicy,
|
||||
HttpConnectionFailed {
|
||||
http_status_code: Option<u16>,
|
||||
},
|
||||
@@ -2000,6 +2004,7 @@ impl CodexErrorInfo {
|
||||
Self::ContextWindowExceeded
|
||||
| Self::UsageLimitExceeded
|
||||
| Self::ServerOverloaded
|
||||
| Self::CyberPolicy
|
||||
| Self::HttpConnectionFailed { .. }
|
||||
| Self::ResponseStreamConnectionFailed { .. }
|
||||
| Self::InternalServerError
|
||||
@@ -2183,6 +2188,18 @@ pub struct ModelRerouteEvent {
|
||||
pub reason: ModelRerouteReason,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Copy, Deserialize, Serialize, PartialEq, Eq, JsonSchema, TS)]
|
||||
#[serde(rename_all = "snake_case")]
|
||||
#[ts(rename_all = "snake_case")]
|
||||
pub enum ModelVerification {
|
||||
TrustedAccessForCyber,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Deserialize, Serialize, PartialEq, Eq, JsonSchema, TS)]
|
||||
pub struct ModelVerificationEvent {
|
||||
pub verifications: Vec<ModelVerification>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Deserialize, Serialize, JsonSchema, TS)]
|
||||
pub struct ContextCompactedEvent;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user