mirror of
https://github.com/openai/codex.git
synced 2026-09-20 12:47:38 +00:00
Simplify Guardian timeout fallback plumbing
This commit is contained in:
@@ -114,6 +114,10 @@ enum TurnMultiAgentRuntime {
|
||||
}
|
||||
|
||||
impl TurnContext {
|
||||
pub(crate) fn guardian_timeout_manual_fallback_enabled(&self) -> bool {
|
||||
self.manual_approval_fallback_enabled
|
||||
}
|
||||
|
||||
pub(crate) fn permission_profile(&self) -> PermissionProfile {
|
||||
self.permission_profile.clone()
|
||||
}
|
||||
|
||||
@@ -57,7 +57,6 @@ struct ApprovalDecision {
|
||||
|
||||
struct ApprovalRequestOptions {
|
||||
evaluate_permission_request_hooks: bool,
|
||||
manual_fallback_for_guardian_timeout: bool,
|
||||
}
|
||||
|
||||
impl ToolOrchestrator {
|
||||
@@ -154,7 +153,6 @@ impl ToolOrchestrator {
|
||||
let otel_ci = &tool_ctx.call_id;
|
||||
let strict_auto_review = tool_ctx.session.strict_auto_review_enabled_for_turn().await;
|
||||
let use_guardian = routes_approval_to_guardian(turn_ctx) || strict_auto_review;
|
||||
let manual_fallback_for_guardian_timeout = turn_ctx.manual_approval_fallback_enabled;
|
||||
|
||||
// 1) Approval
|
||||
let mut already_approved = false;
|
||||
@@ -184,7 +182,6 @@ impl ToolOrchestrator {
|
||||
tool_ctx,
|
||||
ApprovalRequestOptions {
|
||||
evaluate_permission_request_hooks: false,
|
||||
manual_fallback_for_guardian_timeout,
|
||||
},
|
||||
&otel,
|
||||
)
|
||||
@@ -226,7 +223,6 @@ impl ToolOrchestrator {
|
||||
tool_ctx,
|
||||
ApprovalRequestOptions {
|
||||
evaluate_permission_request_hooks: !strict_auto_review,
|
||||
manual_fallback_for_guardian_timeout,
|
||||
},
|
||||
&otel,
|
||||
)
|
||||
@@ -415,7 +411,6 @@ impl ToolOrchestrator {
|
||||
tool_ctx,
|
||||
ApprovalRequestOptions {
|
||||
evaluate_permission_request_hooks: !strict_auto_review,
|
||||
manual_fallback_for_guardian_timeout,
|
||||
},
|
||||
&otel,
|
||||
)
|
||||
@@ -584,7 +579,7 @@ impl ToolOrchestrator {
|
||||
otel_source,
|
||||
);
|
||||
|
||||
if !options.manual_fallback_for_guardian_timeout
|
||||
if !turn.guardian_timeout_manual_fallback_enabled()
|
||||
|| !matches!(decision, ReviewDecision::TimedOut)
|
||||
|| guardian_review_id.is_none()
|
||||
{
|
||||
|
||||
@@ -68,6 +68,7 @@ impl ToolRuntime<(), ()> for TimeoutThenManualRuntime {
|
||||
async fn guardian_timeout_falls_back_to_manual_approval() {
|
||||
let (session, mut turn) = crate::session::tests::make_session_and_context().await;
|
||||
turn.session_source = SessionSource::Cli;
|
||||
turn.manual_approval_fallback_enabled = true;
|
||||
let session = Arc::new(session);
|
||||
let turn = Arc::new(turn);
|
||||
let tool_ctx = ToolCtx {
|
||||
@@ -94,7 +95,6 @@ async fn guardian_timeout_falls_back_to_manual_approval() {
|
||||
&tool_ctx,
|
||||
super::ApprovalRequestOptions {
|
||||
evaluate_permission_request_hooks: false,
|
||||
manual_fallback_for_guardian_timeout: true,
|
||||
},
|
||||
&turn.session_telemetry,
|
||||
)
|
||||
@@ -153,7 +153,6 @@ async fn guardian_timeout_stays_terminal_when_manual_fallback_is_disabled() {
|
||||
&tool_ctx,
|
||||
super::ApprovalRequestOptions {
|
||||
evaluate_permission_request_hooks: false,
|
||||
manual_fallback_for_guardian_timeout: false,
|
||||
},
|
||||
&turn.session_telemetry,
|
||||
)
|
||||
|
||||
@@ -367,7 +367,7 @@ impl ExecvePromptRequest {
|
||||
decision: ReviewDecision,
|
||||
) -> PromptDecision {
|
||||
if !matches!(decision, ReviewDecision::TimedOut)
|
||||
|| !self.turn.manual_approval_fallback_enabled
|
||||
|| !self.turn.guardian_timeout_manual_fallback_enabled()
|
||||
{
|
||||
return PromptDecision {
|
||||
decision,
|
||||
|
||||
Reference in New Issue
Block a user