mirror of
https://github.com/openai/codex.git
synced 2026-11-28 23:34:06 +00:00
Reload user config after local plugin installation (#42593)
## Why Loaded threads can retain their previous configuration after a local plugin is installed, preventing the plugin's bundled MCP servers and pending user-config changes from taking effect in the current session. ## What changed - Reload user configuration for loaded threads after installing a local plugin. - Refresh MCP and hook runtimes only after the new configuration is applied. - Keep installation successful if configuration reload fails, while logging the failure. ## Testing - Verify an installed plugin's MCP tool can be called from a thread that was started before installation. - Update the hook runtime test to verify installation applies a staged hook configuration change to the loaded session. GitOrigin-RevId: 63f5a5c7f16303e51cf940e8d9dc3b45c50ae2a9
This commit is contained in:
1 parent
ec84e69261
commit
2387310b52
5 files changed
+71
-40
No files matched your search
@@ -163,12 +163,12 @@ impl ConfigRequestProcessor {
|
||||
| "personality"
|
||||
)
|
||||
});
|
||||
let reload_user_config = params.reload_user_config;
|
||||
let should_reload = params.reload_user_config;
|
||||
let response = self.batch_write_inner(params).await?;
|
||||
if !session_defaults_only {
|
||||
self.handle_config_mutation().await;
|
||||
if reload_user_config {
|
||||
self.reload_user_config().await;
|
||||
if should_reload {
|
||||
reload_user_config(&self.config_manager, &self.thread_manager).await;
|
||||
}
|
||||
}
|
||||
Ok(ClientResponsePayload::ConfigBatchWrite(response))
|
||||
@@ -183,7 +183,7 @@ impl ConfigRequestProcessor {
|
||||
.handle_config_mutation_result(self.set_experimental_feature_enablement(params).await)
|
||||
.await?;
|
||||
if !response.enablement.is_empty() {
|
||||
self.reload_user_config().await;
|
||||
reload_user_config(&self.config_manager, &self.thread_manager).await;
|
||||
}
|
||||
self.outgoing
|
||||
.send_response_as(
|
||||
@@ -321,38 +321,6 @@ impl ConfigRequestProcessor {
|
||||
Ok(ExperimentalFeatureEnablementSetResponse { enablement })
|
||||
}
|
||||
|
||||
async fn reload_user_config(&self) {
|
||||
match self.load_latest_config(/*fallback_cwd*/ None).await {
|
||||
Ok(_) => {}
|
||||
Err(err) => {
|
||||
tracing::warn!(
|
||||
"failed to rebuild user config for runtime refresh: {}",
|
||||
err.message
|
||||
);
|
||||
return;
|
||||
}
|
||||
};
|
||||
let thread_ids = self.thread_manager.list_thread_ids().await;
|
||||
for thread_id in thread_ids {
|
||||
let Ok(thread) = self.thread_manager.get_thread(thread_id).await else {
|
||||
continue;
|
||||
};
|
||||
let current_config = thread.config().await;
|
||||
let next_config = match self
|
||||
.config_manager
|
||||
.load_latest_config_for_thread(current_config.as_ref())
|
||||
.await
|
||||
{
|
||||
Ok(config) => config,
|
||||
Err(err) => {
|
||||
tracing::warn!(%thread_id, %err, "failed to reload thread configuration");
|
||||
continue;
|
||||
}
|
||||
};
|
||||
thread.refresh_runtime_config(next_config).await;
|
||||
}
|
||||
}
|
||||
|
||||
async fn emit_plugin_toggle_events(
|
||||
&self,
|
||||
pending_changes: std::collections::BTreeMap<String, bool>,
|
||||
@@ -374,6 +342,38 @@ impl ConfigRequestProcessor {
|
||||
}
|
||||
}
|
||||
|
||||
pub(super) async fn reload_user_config(
|
||||
config_manager: &ConfigManager,
|
||||
thread_manager: &ThreadManager,
|
||||
) {
|
||||
if let Err(err) = config_manager
|
||||
.load_latest_config(/*fallback_cwd*/ None)
|
||||
.await
|
||||
{
|
||||
tracing::warn!("failed to rebuild user config for runtime refresh: {err}");
|
||||
return;
|
||||
}
|
||||
let thread_ids = thread_manager.list_thread_ids().await;
|
||||
for thread_id in thread_ids {
|
||||
let Ok(thread) = thread_manager.get_thread(thread_id).await else {
|
||||
continue;
|
||||
};
|
||||
let current_config = thread.config().await;
|
||||
let next_config = match config_manager
|
||||
.load_latest_config_for_thread(current_config.as_ref())
|
||||
.await
|
||||
{
|
||||
Ok(config) => config,
|
||||
Err(err) => {
|
||||
tracing::warn!(%thread_id, %err, "failed to reload thread configuration");
|
||||
continue;
|
||||
}
|
||||
};
|
||||
// Keep runtime refresh state off the request dispatcher's stack.
|
||||
Box::pin(thread.refresh_runtime_config(next_config)).await;
|
||||
}
|
||||
}
|
||||
|
||||
fn map_requirements_toml_to_api(requirements: ConfigRequirementsToml) -> ConfigRequirements {
|
||||
let windows_sandbox_private_desktop = requirements
|
||||
.windows
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
use super::apps_processor::APP_READ_MAX_IDS;
|
||||
use super::config_processor::reload_user_config;
|
||||
use super::*;
|
||||
use crate::error_code::internal_error;
|
||||
use crate::error_code::invalid_request;
|
||||
@@ -1514,7 +1515,10 @@ impl PluginRequestProcessor {
|
||||
}
|
||||
};
|
||||
|
||||
self.on_effective_plugins_changed().await;
|
||||
self.clear_plugin_related_caches();
|
||||
reload_user_config(&self.config_manager, &self.thread_manager).await;
|
||||
self.thread_manager.invalidate_mcp_runtimes().await;
|
||||
self.thread_manager.refresh_hook_runtimes().await;
|
||||
|
||||
let plugin_mcp_servers = load_configured_plugin_mcp_servers(
|
||||
result.installed_path.as_path(),
|
||||
|
||||
Reference in new issue
Block a user