Include parent evidence in recorded Guardian reviews (#63770)

## Why

An archived worker's transcript can omit the original user instructions and
assistant context that Guardian needs to assess a recorded tool call.

## What changed

Let clients supply optional `rootEvidence` to experimental
`thread/guardianReview` on an idle, ephemeral non-subagent thread. Guardian
reviews the ordered parent messages and omission flags alongside the worker
history loaded through `thread/inject_items`. The parent evidence stays out
of the worker history, and `usedRootEvidence: true` confirms that the review
used it.

Guardian can reuse reviewer history when the evidence is unchanged. Changing
or omitting the evidence resets that history.

## Testing

Add an app-server integration test covering rejection on persisted threads,
reviewer history reuse and reset, and review without executing the tool call.

GitOrigin-RevId: a4e78d770af5ad29864cb745b2e31f0fc921f213
This commit is contained in:
RJ
2026-11-24 23:56:17 +00:00
committed by copyberry
parent ff2ee6212c
commit e1492bd86d
12 changed files with 294 additions and 4 deletions
@@ -216,8 +216,15 @@ impl TurnRequestProcessor {
EnsureConversationListenerResult::Attached => {}
EnsureConversationListenerResult::ConnectionClosed => return Ok(None),
}
// Older servers silently ignore rootEvidence. Acknowledge it on success so clients
// can distinguish a worker review from one that used only the injected history.
let used_root_evidence = params.root_evidence.is_some();
let result = thread
.guardian_review(&params.tool_call, cancellation)
.guardian_review_with_root_evidence(
&params.tool_call,
params.root_evidence,
cancellation,
)
.await
.map_err(|err| match err.details() {
CodexErrorDetails::InvalidRequest(message) => invalid_request(message.clone()),
@@ -225,6 +232,7 @@ impl TurnRequestProcessor {
})?;
Ok(Some(
ThreadGuardianReviewResponse {
used_root_evidence,
call_id: result.call_id,
assessment: ThreadGuardianAssessment {
outcome: result.assessment.outcome,