Separate Codex error details from retry metadata (#34996)

## What changed

- Wrap `CodexErrorDetails` and an optional retry delay in `CodexErr`, allowing any mapped error to preserve server-provided retry timing.
- Generate the payload-free `CodexErrKind` classification alongside the error details and reuse it for analytics.
- Update error handling sites to inspect `CodexErr::details()` while preserving existing display, debug, protocol mapping, and retryability behavior.

## Testing

- Add coverage for legacy debug formatting, error-specific retryability, and retry-delay propagation through API error mapping.

GitOrigin-RevId: d3ab8a305f2a2ee21d0c0a8c8c388b06dda9c59a
This commit is contained in:
Adam Perry @ OpenAI authored and copyberry committed 2026-07-23 19:32:26 +00:00
1 parent 265cd2e100
commit 7bafdada8b
40 files changed
+741 -435

No files matched your search

+5 -1
View File
@@ -5,6 +5,7 @@ use crate::mcp_tool_call::MCP_TOOL_APPROVAL_QUESTION_ID_PREFIX;
use async_channel::bounded;
use codex_mcp::CODEX_APPS_MCP_SERVER_NAME;
use codex_protocol::config_types::ApprovalsReviewer;
use codex_protocol::error::CodexErrorDetails;
use codex_protocol::models::NetworkPermissions;
use codex_protocol::models::ResponseItem;
use codex_protocol::protocol::AgentStatus;
@@ -216,7 +217,10 @@ async fn run_codex_thread_interactive_respects_pre_cancelled_spawn() {
.await
.expect("cancelled delegate spawn should not hang");
assert!(matches!(result, Err(CodexErr::TurnAborted)));
assert!(matches!(
result,
Err(err) if matches!(err.details(), CodexErrorDetails::TurnAborted)
));
}
#[tokio::test]