Accept an explicit tool call in Guardian review requests (#63654)

## Why

Selecting the final item in an idle thread's history ties Guardian review
to what was recorded. For example, a client may record an `exec` script
and need an assessment of an individual `exec_command` from that script.

## What changed

Require `toolCall` in the experimental `thread/guardianReview` request.
Guardian assesses the supplied `function_call` or `custom_tool_call`
against the idle thread's full history without appending or executing it.

## Testing

Cover rejection of requests missing `toolCall` and verify that Guardian
sees the recorded script alongside each command submitted for review.
Check that only the original script call is persisted in the thread.

GitOrigin-RevId: a1ce61e10e98107b38db60071dd63f189ef33ad1
This commit is contained in:
swastik-oai
2026-11-24 14:35:46 +00:00
committed by copyberry
parent 5f2bd3342f
commit 53fe98bdc2
14 changed files with 168 additions and 132 deletions
@@ -960,7 +960,7 @@ client_request_definitions! {
response: v2::ThreadItemsReadResponse,
},
#[experimental("thread/guardianReview")]
/// Review the idle thread's final injected exec_command without executing it.
/// Assess a supplied tool call against an idle thread's history without executing it.
ThreadGuardianReview => "thread/guardianReview" {
params: v2::ThreadGuardianReviewParams,
serialization: thread_id(params.thread_id),
@@ -1855,12 +1855,15 @@ pub struct ThreadReadResponse {
/// Sequential calls on the same loaded thread can reuse Guardian history across
/// direct reviews and live approvals. The reviewer keeps a separate conversation
/// from the actor and follows the parent thread's normal persistence settings.
/// A retry evaluates the final call again under the current policy.
/// A retry evaluates the supplied call again under the current policy.
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, JsonSchema, TS)]
#[serde(rename_all = "camelCase")]
#[ts(export_to = "v2/")]
pub struct ThreadGuardianReviewParams {
pub thread_id: String,
/// A plaintext Responses API function_call or custom_tool_call to assess against
/// the idle thread's history. The call is neither appended nor executed.
pub tool_call: Box<ResponseItem>,
}
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, JsonSchema, TS)]