mirror of
https://github.com/openai/codex.git
synced 2026-11-18 22:20:48 +00:00
Add experimental Guardian review for injected thread commands (#58119)
## What changed Expose `thread/guardianReview` to review an idle thread's final injected `exec_command` without executing it. Return the call ID and Guardian assessment, or `null` for the assessment when exec policy skips approval. Subscribe the requesting connection to the thread, enforce input and model-provider restrictions, and cancel an in-flight review when the connection disconnects so the thread is released promptly. ## Testing Add integration coverage for assessment responses, policy-skipped reviews, model-provider enforcement, and WebSocket disconnect cancellation. GitOrigin-RevId: e8ad5598e8f101a937447ebe26136310bb76c8d1
This commit is contained in:
@@ -51,9 +51,11 @@ const EXPERIMENTAL_CLIENT_METHOD_DEPENDENCY_TYPES: &[&str] = &[
|
||||
"BedrockEnvironmentCredential",
|
||||
"EnvironmentShellInfo",
|
||||
"EnvironmentStatusKind",
|
||||
"GuardianAssessmentOutcome",
|
||||
"RemoteControlClient",
|
||||
"RemoteControlClientsListOrder",
|
||||
"ThreadBackgroundTerminal",
|
||||
"ThreadGuardianAssessment",
|
||||
"ThreadSearchOccurrence",
|
||||
"ThreadSearchTextRange",
|
||||
"TurnSettingsUpdateStatus",
|
||||
|
||||
@@ -907,6 +907,13 @@ client_request_definitions! {
|
||||
serialization: None,
|
||||
response: v2::ThreadItemsReadResponse,
|
||||
},
|
||||
#[experimental("thread/guardianReview")]
|
||||
/// Review the idle thread's final injected exec_command without executing it.
|
||||
ThreadGuardianReview => "thread/guardianReview" {
|
||||
params: v2::ThreadGuardianReviewParams,
|
||||
serialization: thread_id(params.thread_id),
|
||||
response: v2::ThreadGuardianReviewResponse,
|
||||
},
|
||||
/// Append raw Responses API items to the thread history without starting a user turn.
|
||||
ThreadInjectItems => "thread/inject_items" {
|
||||
params: v2::ThreadInjectItemsParams,
|
||||
|
||||
@@ -1740,6 +1740,35 @@ pub struct ThreadReadResponse {
|
||||
pub read_state: Option<ThreadReadState>,
|
||||
}
|
||||
|
||||
/// Calling `thread/guardianReview` subscribes the connection to the thread.
|
||||
/// The subscription remains after the review completes, keeping the thread loaded
|
||||
/// until the client calls `thread/unsubscribe` or disconnects.
|
||||
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, JsonSchema, TS)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
#[ts(export_to = "v2/")]
|
||||
pub struct ThreadGuardianReviewParams {
|
||||
pub thread_id: String,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, JsonSchema, TS)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
#[ts(export_to = "v2/")]
|
||||
pub struct ThreadGuardianReviewResponse {
|
||||
pub call_id: String,
|
||||
/// Null when exec policy skips approval.
|
||||
pub assessment: Option<ThreadGuardianAssessment>,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, JsonSchema, TS)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
#[ts(export_to = "v2/")]
|
||||
pub struct ThreadGuardianAssessment {
|
||||
pub outcome: codex_protocol::protocol::GuardianAssessmentOutcome,
|
||||
pub risk_level: super::GuardianRiskLevel,
|
||||
pub user_authorization: super::GuardianUserAuthorization,
|
||||
pub rationale: String,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, JsonSchema, TS)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
#[ts(export_to = "v2/")]
|
||||
|
||||
Reference in New Issue
Block a user