Propagate response tickets to Guardian reviews (#42758)

## What changed

- Request and parse server-issued Guardian tickets for eligible Codex backend responses.
- Scope each ticket to the response that produced a Guardian review or classifier request, including HTTP and WebSocket retries, without adding it to model-visible or persisted context.
- Validate ticket shape, reserve its metadata keys, redact it from debug and request-body logging, and attach it only at the Guardian transport boundary.

## Testing

- Cover ticket parsing, endpoint and authentication routing, retry scoping, classifier retries, and redaction for compressed and uncompressed requests.

GitOrigin-RevId: 6219dd15c9f19ed3387de516aac1b8e7c9cdb0e3
This commit is contained in:
jif authored and copyberry committed 2026-09-04 12:56:26 +00:00
1 parent 97e46694e1
commit cc4b8bdeb8
32 files changed
+562 -44

No files matched your search

+9 -1
View File
@@ -1437,6 +1437,10 @@ async fn run_sampling_request(
let mut original_input = None;
let mut executed_tool_calls_by_output = HashMap::new();
loop {
// A retry must not lend a previous response's ticket to the next tool call.
turn_context
.extension_data
.remove::<codex_protocol::guardian_ticket::GuardianTicket>();
let prompt_input = if let Some(input) = initial_input.take() {
input
} else {
@@ -2372,7 +2376,11 @@ async fn try_run_sampling_request(
record_turn_ttft_metric(&turn_context, &event).await;
match event {
ResponseEvent::Created => {}
ResponseEvent::Created { guardian_ticket } => {
if let Some(ticket) = guardian_ticket {
turn_context.extension_data.insert(ticket);
}
}
ResponseEvent::OutputItemDone(mut item) => {
assign_missing_streamed_response_item_id(&mut item, active_item.as_ref());
if analytics_tool_call_ids.len() < MAX_ANALYTICS_TOOL_CALL_IDS_PER_RESPONSE {