mirror of
https://github.com/openai/codex.git
synced 2026-11-26 07:26:11 +00:00
Move Guardian reviewer configuration into the extension (#45729)
## What changed Move concrete reviewer settings into `guardian-v2` and replace `ReviewerConfigOverrides` with a `ReviewerConfig` callback stored in thread extension data. Apply the callback to each captured parent configuration before preparing context and checking session reuse. Keep model selection, policy prompt construction, and live network state in the core adapter. Preserve the existing read-only reviewer settings and share `reviewer_permission_profile` with inherited environment configuration. ## Testing Update existing Guardian configuration, session reuse, and prewarming tests to use the extension's actual configuration builder, including compiling the shared source in core's test host. GitOrigin-RevId: dfa1dae9f8d4469f2e4f6e64ab842cc662970898
This commit is contained in:
1 parent
7784318b5f
commit
a9d2564bcb
13 files changed
+148
-156
No files matched your search
@@ -8,6 +8,7 @@ use std::sync::Weak;
|
||||
use codex_core::ThreadManager;
|
||||
use codex_core::config::Config;
|
||||
use codex_core::config::Constrained;
|
||||
use codex_core::config::TokenBudgetConfig;
|
||||
use codex_core::guardian_review::GuardianReviewSession;
|
||||
use codex_extension_api::ExtensionFuture;
|
||||
use codex_extension_api::ExtensionRegistryBuilder;
|
||||
@@ -30,6 +31,8 @@ use codex_protocol::protocol::InternalSessionSource;
|
||||
use codex_protocol::protocol::SessionSource;
|
||||
use codex_protocol::protocol::ThreadSource;
|
||||
|
||||
mod reviewer_config;
|
||||
|
||||
/// Owns reviewer agents through the same thread manager as the parent conversation.
|
||||
#[derive(Debug)]
|
||||
struct GuardianExtension {
|
||||
@@ -45,6 +48,11 @@ impl ThreadLifecycleContributor<Config> for GuardianExtension {
|
||||
if input.session_source.is_internal() {
|
||||
return;
|
||||
}
|
||||
input
|
||||
.thread_store
|
||||
.insert(codex_guardian_reviewer::ReviewerConfig::<Config>(
|
||||
reviewer_config::build_reviewer_config,
|
||||
));
|
||||
let manager = self.thread_manager.clone();
|
||||
let runtime = input.thread_store.get_or_init(ReviewerTasks::default);
|
||||
input.thread_store.get_or_init(|| {
|
||||
@@ -74,8 +82,6 @@ impl ThreadLifecycleContributor<Config> for GuardianExtension {
|
||||
) {
|
||||
options.config.ephemeral = true;
|
||||
}
|
||||
options.config.permissions.approval_policy =
|
||||
Constrained::allow_only(AskForApproval::Never);
|
||||
options.session_source =
|
||||
Some(SessionSource::Internal(InternalSessionSource::Guardian));
|
||||
options.thread_source = Some(ThreadSource::GuardianReview);
|
||||
|
||||
@@ -0,0 +1,63 @@
|
||||
//! Applies Guardian's reviewer settings to a fresh copy of the captured parent configuration.
|
||||
//! Managed constraints stay enforced by Config; context and live network state are added by
|
||||
//! the temporary host adapter before it decides whether an existing reviewer can be reused.
|
||||
|
||||
use super::Config;
|
||||
use super::Constrained;
|
||||
use super::TokenBudgetConfig;
|
||||
use codex_features::Feature;
|
||||
use codex_protocol::protocol::AskForApproval;
|
||||
use std::collections::HashMap;
|
||||
|
||||
pub(crate) fn build_reviewer_config(parent_config: &Config) -> anyhow::Result<Config> {
|
||||
let mut config = parent_config.clone();
|
||||
config.model_provider.request_max_retries = Some(1);
|
||||
config.model_provider.stream_max_retries = Some(1);
|
||||
config.include_skill_instructions = false;
|
||||
config.memories.use_memories = false;
|
||||
config.memories.dedicated_tools = false;
|
||||
// An explicit disabled config prevents model defaults from reactivating it.
|
||||
config.token_budget_startup_config = None;
|
||||
config.token_budget = Some(TokenBudgetConfig::default());
|
||||
config.notify = None;
|
||||
config.developer_instructions = None;
|
||||
config.permissions.approval_policy = Constrained::allow_only(AskForApproval::Never);
|
||||
config
|
||||
.permissions
|
||||
.set_permission_profile(codex_guardian_reviewer::reviewer_permission_profile(
|
||||
config.permissions.permission_profile(),
|
||||
))
|
||||
.map_err(|err| {
|
||||
anyhow::anyhow!("guardian review session could not set permission profile: {err}")
|
||||
})?;
|
||||
config.include_apps_instructions = false;
|
||||
config.mcp_servers.set(HashMap::new()).map_err(|err| {
|
||||
anyhow::anyhow!("guardian review session could not clear MCP servers: {err}")
|
||||
})?;
|
||||
for feature in [
|
||||
Feature::Collab,
|
||||
Feature::MultiAgentV2,
|
||||
Feature::GuardianV2,
|
||||
Feature::TokenBudget,
|
||||
Feature::ContextManagement,
|
||||
Feature::CodexHooks,
|
||||
Feature::Apps,
|
||||
Feature::Plugins,
|
||||
Feature::WebSearchRequest,
|
||||
Feature::WebSearchCached,
|
||||
] {
|
||||
config.features.disable(feature).map_err(|err| {
|
||||
anyhow::anyhow!(
|
||||
"guardian review session could not disable `features.{}`: {err}",
|
||||
feature.key()
|
||||
)
|
||||
})?;
|
||||
if config.features.enabled(feature) {
|
||||
tracing::warn!(
|
||||
"guardian review session could not disable `features.{}`; continuing with the feature enabled",
|
||||
feature.key()
|
||||
);
|
||||
}
|
||||
}
|
||||
Ok(config)
|
||||
}
|
||||
Reference in new issue
Block a user