mirror of
https://github.com/openai/codex.git
synced 2026-11-11 14:32:25 +00:00
Surface misalignment policy violations as typed errors (#38682)
## What changed - Recognize `misalignment_policy_violation` errors from response streams and HTTP 400 or 403 responses. - Preserve the upstream message, use a fallback for blank messages, and treat the error as non-retryable. - Expose `misalignmentPolicyViolation` through the app-server protocol and generated schemas so turns fail with a typed terminal error. ## Testing - Cover streamed and HTTP policy violations, fallback messages, retry behavior, and app-server turn completion. GitOrigin-RevId: fd3485bf0be7bfe3d51c078bbc36a081692fd57f
This commit is contained in:
1 parent
4e9a1a9073
commit
eb147c0db3
32 files changed
+299
-2
No files matched your search
@@ -132,6 +132,8 @@ pub enum CodexErrorDetails {
|
||||
ServerOverloaded,
|
||||
#[error("{message}")]
|
||||
CyberPolicy { message: String },
|
||||
#[error("{message}")]
|
||||
MisalignmentPolicyViolation { message: String },
|
||||
#[error("{0}")]
|
||||
ResponseStreamFailed(ResponseStreamFailed),
|
||||
#[error("{0}")]
|
||||
@@ -383,7 +385,8 @@ impl CodexErr {
|
||||
| CodexErrorDetails::SessionConfiguredNotFirstEvent
|
||||
| CodexErrorDetails::UsageLimitReached(_)
|
||||
| CodexErrorDetails::ServerOverloaded
|
||||
| CodexErrorDetails::CyberPolicy { .. } => false,
|
||||
| CodexErrorDetails::CyberPolicy { .. }
|
||||
| CodexErrorDetails::MisalignmentPolicyViolation { .. } => false,
|
||||
CodexErrorDetails::Stream(..)
|
||||
| CodexErrorDetails::Timeout
|
||||
| CodexErrorDetails::RequestTimeout
|
||||
@@ -426,6 +429,9 @@ impl CodexErr {
|
||||
| CodexErrorDetails::UsageNotIncluded => CodexErrorInfo::UsageLimitExceeded,
|
||||
CodexErrorDetails::ServerOverloaded => CodexErrorInfo::ServerOverloaded,
|
||||
CodexErrorDetails::CyberPolicy { .. } => CodexErrorInfo::CyberPolicy,
|
||||
CodexErrorDetails::MisalignmentPolicyViolation { .. } => {
|
||||
CodexErrorInfo::MisalignmentPolicyViolation
|
||||
}
|
||||
CodexErrorDetails::RetryLimit(_) => CodexErrorInfo::ResponseTooManyFailedAttempts {
|
||||
http_status_code: self.http_status_code_value(),
|
||||
},
|
||||
|
||||
Reference in new issue
Block a user