Preserve Guardian parent response IDs across sampling requests (#45441)

## Why

Running code-mode cells can request Guardian review while the next response is in flight. Clearing the response ID before that response emits `response.created` leaves those reviews without a `parent_response_id`.

## What changed

Keep the latest response ID received in the turn until a later `response.created` replaces it, including across sampling retries.

## Testing

Add regression coverage for reviews before and after a response handoff and for a fresh turn that must not inherit the previous turn's ID. Update retry coverage to expect the last known parent when the retry supplies no response ID.

GitOrigin-RevId: af0a08de09edad59e1a7ade7904a42d616b05679
This commit is contained in:
jif authored and copyberry committed 2026-09-14 15:13:13 +00:00
1 parent f8bed26f7b
commit b6a5d5bb14
5 files changed
+203 -13

No files matched your search

+2 -4
View File
@@ -1564,10 +1564,8 @@ async fn run_sampling_request(
let mut original_input = None;
let mut executed_tool_calls_by_output = HashMap::new();
loop {
// A retry must not attribute the next tool call to the previous response.
turn_context
.extension_data
.remove::<codex_api::ResponseId>();
// Running code-mode cells can request review while this response is in flight.
// Keep the latest received ID until response.created replaces it.
let prompt_input = if let Some(input) = initial_input.take() {
input
} else {