mirror of
https://github.com/openai/codex.git
synced 2026-11-03 16:23:51 +00:00
Initialize execution environments with the final HTTP policy (#34995)
## Why The TUI must inspect the default execution environment before loading its final configuration. Initializing the environment manager at that point can give startup services the bootstrap HTTP policy instead of the effective policy after managed requirements are applied. ## What changed - Split environment discovery from manager construction so callers can inspect the default environment without starting remote connections. - Build the environment manager after final configuration loading and pass its resolved `HttpClientFactory` through all construction paths. - Add shared test support for managers that use the legacy default HTTP policy. ## Testing - Cover connection-free environment discovery and explicit HTTP policy propagation. - Verify TUI startup services use the final managed `respect_system_proxy` value. GitOrigin-RevId: 928fa31e6b4bcfbe1a121cade2f351427fdfa0f4
This commit is contained in:
1 parent
c769a05340
commit
265cd2e100
31 files changed
+582
-131
No files matched your search
@@ -31,7 +31,7 @@ use codex_connectors::ConnectorRuntimeContext;
|
||||
use codex_connectors::ConnectorRuntimeContextKey;
|
||||
use codex_connectors::ConnectorRuntimeFetchSource;
|
||||
use codex_connectors::ConnectorRuntimeManager;
|
||||
use codex_exec_server::EnvironmentManager;
|
||||
use codex_exec_server_test_support::environment_manager_without_environments;
|
||||
use codex_login::CodexAuth;
|
||||
use codex_protocol::ToolName;
|
||||
use codex_protocol::mcp::McpServerInfo;
|
||||
@@ -1344,7 +1344,7 @@ async fn hard_refresh_keeps_binding_override_local_when_shared_cache_loses_race(
|
||||
#[tokio::test(start_paused = true)]
|
||||
async fn tool_catalog_cache_sanitizes_tools_and_tracks_environment_generation() {
|
||||
let cache = McpToolCatalogCache::default();
|
||||
let environment_manager = Arc::new(EnvironmentManager::without_environments());
|
||||
let environment_manager = Arc::new(environment_manager_without_environments());
|
||||
let replace_environment = |url: &str| {
|
||||
environment_manager
|
||||
.upsert_environment(
|
||||
@@ -1416,7 +1416,7 @@ async fn tool_catalog_cache_sanitizes_tools_and_tracks_environment_generation()
|
||||
fn tool_catalog_cache_bypasses_remote_sourced_environment_variables() {
|
||||
let cache = McpToolCatalogCache::default();
|
||||
let runtime_context = McpRuntimeContext::new(
|
||||
Arc::new(EnvironmentManager::without_environments()),
|
||||
Arc::new(environment_manager_without_environments()),
|
||||
PathBuf::from("/tmp"),
|
||||
);
|
||||
let config: McpServerConfig = serde_json::from_value(serde_json::json!({
|
||||
@@ -2292,7 +2292,7 @@ async fn no_local_runtime_fails_local_stdio_but_keeps_local_http_server() {
|
||||
tx_event: None,
|
||||
startup_cancellation_token: cancel_token.clone(),
|
||||
runtime_context: McpRuntimeContext::new(
|
||||
Arc::new(EnvironmentManager::without_environments()),
|
||||
Arc::new(environment_manager_without_environments()),
|
||||
PathBuf::from("/tmp"),
|
||||
),
|
||||
codex_apps_tools_cache: ConnectorRuntimeManager::<ToolInfo>::default(),
|
||||
@@ -2533,7 +2533,7 @@ fn reusable_server_config(url: &str) -> McpServerConfig {
|
||||
|
||||
fn reusable_server_runtime_context() -> McpRuntimeContext {
|
||||
McpRuntimeContext::new(
|
||||
Arc::new(EnvironmentManager::without_environments()),
|
||||
Arc::new(environment_manager_without_environments()),
|
||||
PathBuf::from("/tmp"),
|
||||
)
|
||||
}
|
||||
|
||||
@@ -354,6 +354,7 @@ mod tests {
|
||||
use codex_config::McpServerConfig;
|
||||
use codex_config::McpServerTransportConfig;
|
||||
use codex_exec_server::EnvironmentManager;
|
||||
use codex_exec_server_test_support::environment_manager_without_environments;
|
||||
use codex_utils_path_uri::LegacyAppPathString;
|
||||
use pretty_assertions::assert_eq;
|
||||
use serde_json::Value;
|
||||
@@ -475,7 +476,7 @@ mod tests {
|
||||
#[test]
|
||||
fn local_stdio_requires_local_stdio_availability() {
|
||||
let runtime_context = McpRuntimeContext::new(
|
||||
Arc::new(EnvironmentManager::without_environments()),
|
||||
Arc::new(environment_manager_without_environments()),
|
||||
PathBuf::from("/tmp"),
|
||||
);
|
||||
|
||||
@@ -494,7 +495,7 @@ mod tests {
|
||||
#[test]
|
||||
fn local_http_does_not_require_local_stdio_availability() {
|
||||
let runtime_context = McpRuntimeContext::new(
|
||||
Arc::new(EnvironmentManager::without_environments()),
|
||||
Arc::new(environment_manager_without_environments()),
|
||||
PathBuf::from("/tmp"),
|
||||
);
|
||||
|
||||
@@ -510,7 +511,7 @@ mod tests {
|
||||
#[test]
|
||||
fn unknown_explicit_environment_is_rejected() {
|
||||
let runtime_context = McpRuntimeContext::new(
|
||||
Arc::new(EnvironmentManager::without_environments()),
|
||||
Arc::new(environment_manager_without_environments()),
|
||||
PathBuf::from("/tmp"),
|
||||
);
|
||||
|
||||
|
||||
Reference in new issue
Block a user