Expose resumable misalignment details through app server (#40952)

## 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
This commit is contained in:
Francis Chalissery authored and copyberry committed 2026-08-26 18:42:44 +00:00
1 parent 0e9a2bae52
commit 7276d67081
63 files changed
+1604 -15

No files matched your search

@@ -1173,6 +1173,7 @@ async fn live_app_server_failed_turn_does_not_duplicate_error_history() {
chat.handle_server_notification(
ServerNotification::Error(ErrorNotification {
error: AppServerTurnError {
misalignment: None,
message: "permission denied".to_string(),
codex_error_info: None,
additional_details: None,
@@ -1196,6 +1197,7 @@ async fn live_app_server_failed_turn_does_not_duplicate_error_history() {
items: Vec::new(),
status: AppServerTurnStatus::Failed,
error: Some(AppServerTurnError {
misalignment: None,
message: "permission denied".to_string(),
codex_error_info: None,
additional_details: None,
@@ -1330,6 +1332,7 @@ async fn live_app_server_stream_recovery_restores_previous_status_header() {
chat.handle_server_notification(
ServerNotification::Error(ErrorNotification {
error: AppServerTurnError {
misalignment: None,
message: "Reconnecting... 1/5".to_string(),
codex_error_info: Some(CodexErrorInfo::Other),
additional_details: None,
@@ -1408,6 +1411,7 @@ async fn live_app_server_server_overloaded_error_renders_warning() {
chat.handle_server_notification(
ServerNotification::Error(ErrorNotification {
error: AppServerTurnError {
misalignment: None,
message: "server overloaded".to_string(),
codex_error_info: Some(CodexErrorInfo::ServerOverloaded),
additional_details: None,
@@ -1450,6 +1454,7 @@ async fn live_app_server_cyber_policy_error_renders_dedicated_notice() {
chat.handle_server_notification(
ServerNotification::Error(ErrorNotification {
error: AppServerTurnError {
misalignment: None,
message: "server fallback message".to_string(),
codex_error_info: Some(CodexErrorInfo::CyberPolicy),
additional_details: None,
@@ -415,6 +415,7 @@ pub(super) fn handle_error(
chat.handle_server_notification(
ServerNotification::Error(ErrorNotification {
error: AppServerTurnError {
misalignment: None,
message: message.into(),
codex_error_info,
additional_details: None,
@@ -448,6 +449,7 @@ pub(super) fn handle_stream_error_with_replay(
chat.handle_server_notification(
ServerNotification::Error(ErrorNotification {
error: AppServerTurnError {
misalignment: None,
message: message.into(),
codex_error_info: None,
additional_details,
@@ -95,6 +95,7 @@ async fn replayed_failed_turns_preserve_overload_warnings_between_retries() {
/*duration_ms*/ None,
/*error*/
Some(AppServerTurnError {
misalignment: None,
message: error_message.to_string(),
codex_error_info: Some(CodexErrorInfo::ServerOverloaded),
additional_details: None,
@@ -1024,6 +1025,7 @@ async fn replayed_retryable_app_server_error_keeps_turn_running() {
chat.handle_server_notification(
ServerNotification::Error(ErrorNotification {
error: AppServerTurnError {
misalignment: None,
message: "Reconnecting... 1/5".to_string(),
codex_error_info: None,
additional_details: Some("Idle timeout waiting for SSE".to_string()),
@@ -76,6 +76,7 @@ async fn misalignment_policy_failure_stops_the_thread_and_renders_once() {
AppServerTurnStatus::Failed,
/*duration_ms*/ None,
Some(AppServerTurnError {
misalignment: None,
message: ERROR_MESSAGE.to_string(),
codex_error_info: Some(CodexErrorInfo::MisalignmentPolicyViolation),
additional_details: None,