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:
Eric Traut
2026-04-22 22:24:12 -07:00
committed by GitHub
parent 02170996e6
commit bbff4ee61a
61 changed files with 1414 additions and 15 deletions

View File

@@ -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(),
},

View File

@@ -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;