mirror of
https://github.com/openai/codex.git
synced 2026-10-27 16:02:59 +00:00
Allow injecting the Codex Apps tools cache (#33113)
## What changed - Accept a caller-provided `CodexAppsToolsCache` when constructing a `ThreadManager` and pass it through to the MCP manager. - Add `ConnectorRuntimeManager::new_without_cache()` for an in-memory runtime that neither loads nor persists connector state on disk. - Re-export `CodexAppsToolsCache` from `codex-core` and `codex-core-api` for embedders. ## Testing - Verify that a cache-disabled connector runtime ignores existing disk state and publishes live tools without creating cache files. GitOrigin-RevId: f52f4f27c425a8d84ad0d0987b30a6fc3c14d702
This commit is contained in:
@@ -2338,6 +2338,7 @@ async fn resume_thread_subagent_restores_stored_metadata() {
|
||||
&config,
|
||||
auth_manager.clone(),
|
||||
crate::thread_manager::build_models_manager(&config, auth_manager),
|
||||
crate::CodexAppsToolsCache::default(),
|
||||
SessionSource::Exec,
|
||||
Arc::new(codex_exec_server::EnvironmentManager::default_for_tests()),
|
||||
empty_extension_registry(),
|
||||
|
||||
@@ -65,6 +65,7 @@ pub use network_proxy_loader::MtimeConfigReloader;
|
||||
pub use network_proxy_loader::build_network_proxy_state;
|
||||
pub use network_proxy_loader::build_network_proxy_state_and_reloader;
|
||||
mod original_image_detail;
|
||||
pub use codex_mcp::CodexAppsToolsCache;
|
||||
pub use codex_mcp::SandboxState;
|
||||
mod mcp_openai_file;
|
||||
mod mcp_tool_call;
|
||||
|
||||
@@ -58,6 +58,7 @@ impl McpManager {
|
||||
Self::new_with_extensions(
|
||||
plugins_manager,
|
||||
codex_extension_api::empty_extension_registry(),
|
||||
ConnectorRuntimeManager::default(),
|
||||
)
|
||||
}
|
||||
|
||||
@@ -65,11 +66,12 @@ impl McpManager {
|
||||
pub fn new_with_extensions(
|
||||
plugins_manager: Arc<PluginsManager>,
|
||||
extensions: Arc<ExtensionRegistry<Config>>,
|
||||
codex_apps_tools_cache: ConnectorRuntimeManager<ToolInfo>,
|
||||
) -> Self {
|
||||
Self {
|
||||
plugins_manager,
|
||||
extensions,
|
||||
codex_apps_tools_cache: ConnectorRuntimeManager::default(),
|
||||
codex_apps_tools_cache,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -45,6 +45,7 @@ pub async fn build_prompt_input(
|
||||
&config,
|
||||
Arc::clone(&auth_manager),
|
||||
crate::thread_manager::build_models_manager(&config, Arc::clone(&auth_manager)),
|
||||
crate::CodexAppsToolsCache::default(),
|
||||
SessionSource::Exec,
|
||||
Arc::new(
|
||||
EnvironmentManager::from_codex_home(
|
||||
|
||||
@@ -7734,6 +7734,7 @@ async fn plugin_availability_change_reuses_the_mcp_manager() {
|
||||
session.services.mcp_manager = Arc::new(McpManager::new_with_extensions(
|
||||
Arc::clone(&session.services.plugins_manager),
|
||||
registry,
|
||||
crate::CodexAppsToolsCache::default(),
|
||||
));
|
||||
let session = Arc::new(session);
|
||||
session
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
use crate::CodexAppsToolsCache;
|
||||
use crate::SkillsService;
|
||||
use crate::agent::AgentControl;
|
||||
use crate::attestation::AttestationProvider;
|
||||
@@ -306,6 +307,7 @@ impl ThreadManager {
|
||||
config: &Config,
|
||||
auth_manager: Arc<AuthManager>,
|
||||
models_manager: SharedModelsManager,
|
||||
codex_apps_tools_cache: CodexAppsToolsCache,
|
||||
session_source: SessionSource,
|
||||
environment_manager: Arc<EnvironmentManager>,
|
||||
extensions: Arc<ExtensionRegistry<Config>>,
|
||||
@@ -328,6 +330,7 @@ impl ThreadManager {
|
||||
let mcp_manager = Arc::new(McpManager::new_with_extensions(
|
||||
Arc::clone(&plugins_manager),
|
||||
Arc::clone(&extensions),
|
||||
codex_apps_tools_cache,
|
||||
));
|
||||
let skills_service = Arc::new(SkillsService::new_with_restriction_product(
|
||||
codex_home,
|
||||
|
||||
@@ -602,6 +602,7 @@ async fn start_thread_seeds_extension_data_for_mcp_and_lifecycle_contributors()
|
||||
&config,
|
||||
auth_manager.clone(),
|
||||
build_models_manager(&config, auth_manager),
|
||||
crate::CodexAppsToolsCache::default(),
|
||||
SessionSource::Exec,
|
||||
Arc::new(codex_exec_server::EnvironmentManager::default_for_tests()),
|
||||
Arc::new(extensions.build()),
|
||||
@@ -822,6 +823,7 @@ async fn resume_and_fork_do_not_restore_thread_environments_from_rollout() {
|
||||
&config,
|
||||
auth_manager.clone(),
|
||||
build_models_manager(&config, auth_manager.clone()),
|
||||
crate::CodexAppsToolsCache::default(),
|
||||
SessionSource::Exec,
|
||||
Arc::new(codex_exec_server::EnvironmentManager::default_for_tests()),
|
||||
empty_extension_registry(),
|
||||
@@ -950,6 +952,7 @@ async fn explicit_installation_id_skips_codex_home_file() {
|
||||
&config,
|
||||
auth_manager.clone(),
|
||||
build_models_manager(&config, auth_manager),
|
||||
crate::CodexAppsToolsCache::default(),
|
||||
SessionSource::Exec,
|
||||
Arc::new(codex_exec_server::EnvironmentManager::default_for_tests()),
|
||||
empty_extension_registry(),
|
||||
@@ -992,6 +995,7 @@ async fn resume_active_thread_from_rollout_returns_running_thread() {
|
||||
&config,
|
||||
auth_manager.clone(),
|
||||
build_models_manager(&config, auth_manager.clone()),
|
||||
crate::CodexAppsToolsCache::default(),
|
||||
SessionSource::Exec,
|
||||
Arc::new(codex_exec_server::EnvironmentManager::default_for_tests()),
|
||||
empty_extension_registry(),
|
||||
@@ -1053,6 +1057,7 @@ async fn resume_stopped_thread_from_rollout_spawns_new_thread() {
|
||||
&config,
|
||||
auth_manager.clone(),
|
||||
build_models_manager(&config, auth_manager.clone()),
|
||||
crate::CodexAppsToolsCache::default(),
|
||||
SessionSource::Exec,
|
||||
Arc::new(codex_exec_server::EnvironmentManager::default_for_tests()),
|
||||
empty_extension_registry(),
|
||||
@@ -1121,6 +1126,7 @@ async fn resume_stopped_thread_from_rollout_preserves_thread_source() {
|
||||
&config,
|
||||
auth_manager.clone(),
|
||||
build_models_manager(&config, auth_manager.clone()),
|
||||
crate::CodexAppsToolsCache::default(),
|
||||
SessionSource::Exec,
|
||||
Arc::new(codex_exec_server::EnvironmentManager::default_for_tests()),
|
||||
empty_extension_registry(),
|
||||
@@ -1214,6 +1220,7 @@ async fn subtree_listing_uses_injected_graph_store_without_state_db() {
|
||||
&config,
|
||||
auth_manager.clone(),
|
||||
build_models_manager(&config, auth_manager),
|
||||
crate::CodexAppsToolsCache::default(),
|
||||
SessionSource::Exec,
|
||||
Arc::new(codex_exec_server::EnvironmentManager::default_for_tests()),
|
||||
empty_extension_registry(),
|
||||
@@ -1260,6 +1267,7 @@ async fn rollout_path_resume_and_fork_read_history_through_thread_store() {
|
||||
&config,
|
||||
auth_manager.clone(),
|
||||
build_models_manager(&config, auth_manager.clone()),
|
||||
crate::CodexAppsToolsCache::default(),
|
||||
SessionSource::Exec,
|
||||
Arc::new(codex_exec_server::EnvironmentManager::default_for_tests()),
|
||||
empty_extension_registry(),
|
||||
@@ -1366,6 +1374,7 @@ async fn new_uses_active_provider_for_model_refresh() {
|
||||
&config,
|
||||
auth_manager.clone(),
|
||||
build_models_manager(&config, auth_manager),
|
||||
crate::CodexAppsToolsCache::default(),
|
||||
SessionSource::Exec,
|
||||
Arc::new(codex_exec_server::EnvironmentManager::default_for_tests()),
|
||||
empty_extension_registry(),
|
||||
@@ -1412,6 +1421,7 @@ async fn injected_models_manager_controls_refresh_policy() {
|
||||
&config,
|
||||
auth_manager,
|
||||
models_manager,
|
||||
crate::CodexAppsToolsCache::default(),
|
||||
SessionSource::Custom("test-embedder".to_string()),
|
||||
Arc::new(codex_exec_server::EnvironmentManager::default_for_tests()),
|
||||
empty_extension_registry(),
|
||||
@@ -1661,6 +1671,7 @@ async fn interrupted_fork_snapshot_does_not_synthesize_turn_id_for_legacy_histor
|
||||
&config,
|
||||
auth_manager.clone(),
|
||||
build_models_manager(&config, auth_manager.clone()),
|
||||
crate::CodexAppsToolsCache::default(),
|
||||
SessionSource::Exec,
|
||||
Arc::new(codex_exec_server::EnvironmentManager::default_for_tests()),
|
||||
empty_extension_registry(),
|
||||
@@ -1772,6 +1783,7 @@ async fn interrupted_fork_snapshot_preserves_explicit_turn_id() {
|
||||
&config,
|
||||
auth_manager.clone(),
|
||||
build_models_manager(&config, auth_manager.clone()),
|
||||
crate::CodexAppsToolsCache::default(),
|
||||
SessionSource::Exec,
|
||||
Arc::new(codex_exec_server::EnvironmentManager::default_for_tests()),
|
||||
empty_extension_registry(),
|
||||
@@ -1874,6 +1886,7 @@ async fn interrupted_fork_snapshot_uses_persisted_mid_turn_history_without_live_
|
||||
&config,
|
||||
auth_manager.clone(),
|
||||
build_models_manager(&config, auth_manager.clone()),
|
||||
crate::CodexAppsToolsCache::default(),
|
||||
SessionSource::Exec,
|
||||
Arc::new(codex_exec_server::EnvironmentManager::default_for_tests()),
|
||||
empty_extension_registry(),
|
||||
|
||||
@@ -4281,6 +4281,7 @@ async fn tool_handlers_cascade_close_and_resume_and_keep_explicitly_closed_subtr
|
||||
&config,
|
||||
auth_manager.clone(),
|
||||
crate::thread_manager::build_models_manager(&config, auth_manager),
|
||||
crate::CodexAppsToolsCache::default(),
|
||||
SessionSource::Exec,
|
||||
Arc::new(codex_exec_server::EnvironmentManager::default_for_tests()),
|
||||
empty_extension_registry(),
|
||||
|
||||
@@ -629,6 +629,7 @@ impl TestCodexBuilder {
|
||||
&config,
|
||||
auth_manager.clone(),
|
||||
codex_core::build_models_manager(&config, auth_manager),
|
||||
codex_core::CodexAppsToolsCache::default(),
|
||||
SessionSource::Exec,
|
||||
Arc::clone(&environment_manager),
|
||||
Arc::clone(&self.extensions),
|
||||
|
||||
@@ -1581,6 +1581,7 @@ async fn prefers_apikey_when_config_prefers_apikey_even_with_chatgpt_tokens() {
|
||||
&config,
|
||||
auth_manager.clone(),
|
||||
codex_core::build_models_manager(&config, auth_manager),
|
||||
codex_core::CodexAppsToolsCache::default(),
|
||||
SessionSource::Exec,
|
||||
Arc::new(codex_exec_server::EnvironmentManager::default_for_tests()),
|
||||
empty_extension_registry(),
|
||||
|
||||
Reference in New Issue
Block a user