mirror of
https://github.com/openai/codex.git
synced 2026-09-13 11:47:17 +00:00
## Why App-server clients need the explanation and steering instruction returned with a misalignment policy violation to offer a user-confirmed continuation. Missing or incomplete details must continue to behave as a terminal block. ## What changed - Parse optional misalignment classification, explanation, and steering details from streamed and HTTP Responses errors and propagate them through core errors. - Include the details in live app-server `error` and `turn/completed` payloads and export the corresponding protocol schemas and TypeScript types. - Keep explanations and steering messages out of serialized rollout events and redact them from debug output. - Document how clients can resume with `turn/start` after user confirmation. ## Testing - Cover streamed, HTTP, and WebSocket-wrapped errors, including malformed and classification-only details. - Verify live app-server notifications expose resumable details without writing the explanation or steering message to the rollout. GitOrigin-RevId: 329258a444c2cd91d0c57ab1720830b33ddcfac5
52 lines
1.4 KiB
Rust
52 lines
1.4 KiB
Rust
use crate::rate_limits::RateLimitError;
|
|
use codex_client::TransportError;
|
|
use codex_protocol::protocol::MisalignmentErrorDetails;
|
|
use http::StatusCode;
|
|
use std::time::Duration;
|
|
use thiserror::Error;
|
|
|
|
#[derive(Debug, Error)]
|
|
pub enum ApiError {
|
|
#[error(transparent)]
|
|
Transport(#[from] TransportError),
|
|
#[error("api error {status}: {message}")]
|
|
Api { status: StatusCode, message: String },
|
|
#[error("stream error: {0}")]
|
|
Stream(String),
|
|
#[error("context window exceeded")]
|
|
ContextWindowExceeded,
|
|
#[error("quota exceeded")]
|
|
QuotaExceeded,
|
|
#[error("usage not included")]
|
|
UsageNotIncluded,
|
|
#[error("retryable error: {message}")]
|
|
Retryable {
|
|
message: String,
|
|
delay: Option<Duration>,
|
|
},
|
|
#[error("rate limit exceeded: {message}")]
|
|
RateLimitExceeded {
|
|
message: String,
|
|
delay: Option<Duration>,
|
|
},
|
|
#[error("rate limit: {0}")]
|
|
RateLimit(String),
|
|
#[error("invalid request: {message}")]
|
|
InvalidRequest { message: String },
|
|
#[error("cyber policy: {message}")]
|
|
CyberPolicy { message: String },
|
|
#[error("misalignment policy violation: {message}")]
|
|
MisalignmentPolicyViolation {
|
|
message: String,
|
|
misalignment: Option<MisalignmentErrorDetails>,
|
|
},
|
|
#[error("server overloaded")]
|
|
ServerOverloaded,
|
|
}
|
|
|
|
impl From<RateLimitError> for ApiError {
|
|
fn from(err: RateLimitError) -> Self {
|
|
Self::RateLimit(err.to_string())
|
|
}
|
|
}
|