Record provider error subreasons in turn analytics (#65356)

## Why

Broad error categories make it hard to distinguish a model missing from
the accessible catalog, an unsupported request value, and a route rate
limit from other failures in the same categories.

## What changed

Carry three structured provider subreasons through `CodexErr` and record
them in `codex_error_subreason` only when they match the turn's terminal
failure.

- `model_not_in_accessible_catalog` for a matching HTTP 400 model-not-found error.
- `unsupported_value` for an HTTP 400 invalid-request error with that code.
- `route_rate_limit_exceeded` for a route-specific HTTP 429 that exhausts retries.

## Testing

Cover subreason mapping, including wrapped WebSocket invalid requests,
and verify that turn analytics omit subreasons for successful turns and
mismatched terminal errors. Exercise recovery from a route-specific
HTTP 429 using `Retry-After`.

GitOrigin-RevId: 02d82082334e775020850e1a52ba7baff401cff1
This commit is contained in:
yuhan-oai
2026-12-02 23:28:28 +00:00
committed by copyberry
parent 5b3615f1fe
commit 3a6ecd7366
11 changed files with 427 additions and 29 deletions
+1
View File
@@ -3401,6 +3401,7 @@ mod tests {
ApiError::ModelNotFound {
message: message(),
status: Some(http::StatusCode::NOT_FOUND),
subreason: None,
},
ApiError::InvalidPrompt { message: message() },
ApiError::ContentPolicyViolation {