mirror of
https://github.com/openai/codex.git
synced 2026-11-27 23:50:52 +00:00
Add opt-in structured errors for Guardian circuit-breaker interruptions (#48796)
## Why Guardian denial-limit interruptions lack a structured error identifying the cause. Make this opt-in because older clients may not recognize the new error in shared history. ## What changed - Add `auto_review.circuit_break_action = "strict"` to attach `TooManyDenials` to the interrupted turn. The default leaves the error unset. - Expose `turn.error.codexErrorInfo = "tooManyDenials"` in app-server notifications and saved history, and update protocol schemas and generated types. - Preserve the warning, denial limit, and interrupted status without emitting a separate error notification. ## Testing Add an integration test covering omitted, `default`, and `strict` settings, checking warnings, live turn errors, the absence of separate error notifications, and persisted turn errors after restart. GitOrigin-RevId: cb5d379e64728d4d7b9daf834c13756e4a70db31
This commit is contained in:
@@ -6,6 +6,7 @@ use crate::codex_thread::CodexThread;
|
||||
use codex_extension_api::ThreadIdleCause;
|
||||
use codex_protocol::error::CodexErr;
|
||||
use codex_protocol::error::Result as CodexResult;
|
||||
use codex_protocol::protocol::ErrorEvent;
|
||||
use codex_protocol::protocol::EventMsg;
|
||||
use codex_protocol::protocol::Op;
|
||||
use codex_protocol::protocol::TurnAbortReason;
|
||||
@@ -85,8 +86,12 @@ impl Session {
|
||||
// The caller may be inside the task that cancellation must join.
|
||||
let _ = reply.send(active_turn.is_some());
|
||||
if let Some(active_turn) = active_turn {
|
||||
self.finish_turn_abort(active_turn, TurnAbortReason::Interrupted)
|
||||
.await;
|
||||
self.finish_turn_abort(
|
||||
active_turn,
|
||||
TurnAbortReason::Interrupted,
|
||||
/*error*/ None,
|
||||
)
|
||||
.await;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -94,6 +99,7 @@ impl Session {
|
||||
self: &Arc<Self>,
|
||||
turn_id: &str,
|
||||
warning: EventMsg,
|
||||
error: Option<ErrorEvent>,
|
||||
) {
|
||||
let Some(turn) = self.turn_context_for_sub_id(turn_id).await else {
|
||||
return;
|
||||
@@ -104,7 +110,7 @@ impl Session {
|
||||
let turn_id = turn_id.to_owned();
|
||||
drop(runtime.spawn(async move {
|
||||
if session
|
||||
.abort_turn_if_active(&turn_id, TurnAbortReason::Interrupted)
|
||||
.abort_turn_if_active(&turn_id, TurnAbortReason::Interrupted, error)
|
||||
.await
|
||||
{
|
||||
// Extension aborts bypass normal task completion; user interrupts do not.
|
||||
|
||||
@@ -1599,6 +1599,7 @@ async fn bounded_replay_matches_full_replay_after_empty_turn_compactions(
|
||||
codex_protocol::protocol::TurnAbortedEvent {
|
||||
turn_id: Some(format!("wake-{window_number}")),
|
||||
reason: TurnAbortReason::Interrupted,
|
||||
error: None,
|
||||
started_at: None,
|
||||
completed_at: None,
|
||||
duration_ms: None,
|
||||
@@ -2130,6 +2131,7 @@ async fn record_initial_history_resumed_aborted_turn_without_id_clears_active_tu
|
||||
turn_id: None,
|
||||
started_at: None,
|
||||
reason: TurnAbortReason::Interrupted,
|
||||
error: None,
|
||||
completed_at: None,
|
||||
duration_ms: None,
|
||||
},
|
||||
@@ -2268,6 +2270,7 @@ async fn record_initial_history_resumed_unmatched_abort_preserves_active_turn_fo
|
||||
turn_id: Some(unmatched_abort_turn_id),
|
||||
started_at: None,
|
||||
reason: TurnAbortReason::Interrupted,
|
||||
error: None,
|
||||
completed_at: None,
|
||||
duration_ms: None,
|
||||
},
|
||||
|
||||
@@ -815,6 +815,7 @@ async fn interrupting_regular_turn_waiting_on_startup_prewarm_emits_turn_aborted
|
||||
let EventMsg::TurnAborted(TurnAbortedEvent {
|
||||
turn_id,
|
||||
reason,
|
||||
error: _,
|
||||
started_at,
|
||||
completed_at,
|
||||
duration_ms,
|
||||
@@ -11473,6 +11474,7 @@ impl SessionTask for ExtensionInterruptedTask {
|
||||
EventMsg::Warning(codex_protocol::protocol::WarningEvent {
|
||||
message: "extension interrupted this turn".into(),
|
||||
}),
|
||||
/*error*/ None,
|
||||
)
|
||||
.await;
|
||||
|
||||
@@ -11853,6 +11855,7 @@ async fn extension_interrupt_survives_the_calling_runtime() {
|
||||
EventMsg::Warning(codex_protocol::protocol::WarningEvent {
|
||||
message: "extension interrupted this turn".into(),
|
||||
}),
|
||||
/*error*/ None,
|
||||
)
|
||||
.await;
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user