mirror of
https://github.com/openai/codex.git
synced 2026-11-20 22:40:37 +00:00
Use serving assessments for adaptive Guardian review (#58075)
## What changed - Match final serving assessments to their response and output item, then retain them with tool invocations and code cells across waits. - Use matching assessments instead of asynchronous scoring for adaptive review: low-risk actions can skip synchronous review, while elevated-risk actions require it. - Revalidate captured authorization and policy before approval. Require fresh review for stale or incomplete authorization, preserve explicit review requirements, and discard assessments when hooks rewrite tool input. - Keep asynchronous scoring as the fallback when an assessment is missing or does not match. ## Testing Add integration coverage for direct and nested tool calls, hook rewrites, explicit escalation, interrupted responses, catalog-driven policy, incomplete authorization, and assessment retention across code-cell yields and waits. GitOrigin-RevId: 4346a227204137f018c03c34b302d6f1e9592c96
This commit is contained in:
@@ -20,7 +20,10 @@ use codex_protocol::protocol::TurnContextItem;
|
||||
use tokio_util::sync::CancellationToken;
|
||||
|
||||
/// Request-scoped state that may change between model sampling requests.
|
||||
#[derive(Clone)]
|
||||
pub(crate) struct StepContext {
|
||||
/// Final serving value for this invocation; retained by its code cell across waits.
|
||||
pub(crate) serving_assessment: Option<Arc<crate::guardian::ServingAssessment>>,
|
||||
pub(crate) turn: Arc<TurnContext>,
|
||||
/// Preempts this request and yields its code-mode observations when user input arrives.
|
||||
pub(crate) preempt: Option<CancellationToken>,
|
||||
@@ -38,7 +41,7 @@ pub(crate) struct StepContext {
|
||||
/// Admitted executor hooks bound to this step's discovery, plugin policy, and MCP routing.
|
||||
pub(crate) executor_hook_sources: Vec<ExecutorPluginHookSource>,
|
||||
/// Keeps the extension inputs used to build this step's tools for its World State as well.
|
||||
pub(crate) extension_data: ExtensionData,
|
||||
pub(crate) extension_data: Arc<ExtensionData>,
|
||||
/// The exact MCP connections, configuration, and catalog captured for this step.
|
||||
pub(crate) mcp: Arc<McpBinding>,
|
||||
/// The finalized tool plan advertised and executed for this exact sampling request.
|
||||
|
||||
Reference in New Issue
Block a user