mirror of
https://github.com/openai/codex.git
synced 2026-11-18 23:02:23 +00:00
Handle bio policy errors in Codex (#31439)
## Summary - Treat streamed Responses `bio_policy` failures as terminal invalid requests instead of retryable stream errors. - Recognize the new biology policy code and message in the TUI while preserving the legacy `invalid_prompt` contract. - Keep the existing dedicated biology safety notice and add regression/snapshot coverage for all supported error shapes. ## Why [openai/openai#1068559](https://github.com/openai/openai/pull/1068559) gates a Responses API contract change from `invalid_prompt` and the legacy message to `bio_policy` and new biology copy. Without this compatibility change, streamed blocks are retried as transient failures and the OSS TUI falls back to a generic/raw error instead of the dedicated safety notice. ## Validation - `just test -p codex-api` — 137 passed - `just test -p codex-tui app_server_safety_access_errors_render_dedicated_notice` — passed - `just fix -p codex-api` - `just fix -p codex-tui` - `just fmt` - `just test -p codex-tui` — 2,957 passed; two reproducible failures remain in untouched Guardian feature-flag persistence tests: - `update_feature_flags_disabling_guardian_clears_review_policy_and_restores_default` - `update_feature_flags_disabling_guardian_clears_manual_review_policy_without_history`
This commit is contained in:
1 parent
f6e251c3ac
commit
78df1237d1
4 files changed
+89
-30
No files matched your search
@@ -5,8 +5,15 @@
|
||||
|
||||
use super::*;
|
||||
|
||||
const SAFETY_ACCESS_BLOCK_PREFIX: &str =
|
||||
const LEGACY_SAFETY_ACCESS_BLOCK_PREFIX: &str =
|
||||
"Invalid prompt: we've limited access to this content for safety reasons.";
|
||||
const BIO_POLICY_SAFETY_ACCESS_BLOCK_PREFIX: &str =
|
||||
"This content was flagged for possible biological risk.";
|
||||
|
||||
fn is_safety_access_block_message(message: &str) -> bool {
|
||||
message.starts_with(LEGACY_SAFETY_ACCESS_BLOCK_PREFIX)
|
||||
|| message.starts_with(BIO_POLICY_SAFETY_ACCESS_BLOCK_PREFIX)
|
||||
}
|
||||
|
||||
impl ChatWidget {
|
||||
/// Synchronize the bottom-pane "task running" indicator with the current lifecycles.
|
||||
@@ -430,11 +437,12 @@ impl ChatWidget {
|
||||
.is_some_and(is_app_server_cyber_policy_error)
|
||||
{
|
||||
self.on_cyber_policy_error();
|
||||
} else if message.starts_with(SAFETY_ACCESS_BLOCK_PREFIX)
|
||||
} else if is_safety_access_block_message(&message)
|
||||
|| serde_json::from_str::<serde_json::Value>(&message).is_ok_and(|response| {
|
||||
response["error"]["message"]
|
||||
.as_str()
|
||||
.is_some_and(|message| message.starts_with(SAFETY_ACCESS_BLOCK_PREFIX))
|
||||
response["error"]["code"].as_str() == Some("bio_policy")
|
||||
|| response["error"]["message"]
|
||||
.as_str()
|
||||
.is_some_and(is_safety_access_block_message)
|
||||
})
|
||||
{
|
||||
self.input_queue.submit_pending_steers_after_interrupt = false;
|
||||
|
||||
Reference in new issue
Block a user