mirror of
https://github.com/openai/codex.git
synced 2026-12-02 00:31:03 +00:00
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:
@@ -1144,22 +1144,17 @@ impl CodexThread {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Review the final injected tool call without executing it.
|
||||
/// Review the supplied tool call without executing it.
|
||||
pub async fn guardian_review(
|
||||
&self,
|
||||
tool_call: &ResponseItem,
|
||||
cancellation: &CancellationToken,
|
||||
) -> CodexResult<crate::guardian_review::GuardianReviewResult> {
|
||||
if self.session.active_turn.lock().await.is_some() {
|
||||
return Err(CodexErr::InvalidRequest("thread has an active turn".into()));
|
||||
}
|
||||
let history = self.session.clone_history().await;
|
||||
let tool_call = history.raw_items().next_back().cloned().ok_or_else(|| {
|
||||
CodexErr::InvalidRequest(
|
||||
"expected a final plaintext exec_command, apply_patch, request_permissions, or MCP call"
|
||||
.into(),
|
||||
)
|
||||
})?;
|
||||
crate::guardian::review_tool_call(&self.session, history, &tool_call, cancellation).await
|
||||
crate::guardian::review_tool_call(&self.session, history, tool_call, cancellation).await
|
||||
}
|
||||
|
||||
/// Inject raw Responses items. Plaintext agent-mail batches in a native MAv2
|
||||
|
||||
Reference in New Issue
Block a user