mirror of
https://github.com/openai/codex.git
synced 2026-09-07 15:40:00 +00:00
## What changed - Make `McpRuntime` own the published MCP configuration, connections, elicitation routing, and selected capability roots for a thread. - Capture immutable MCP bindings for model steps and tool calls so in-flight work keeps a consistent connection set and approval authority while refreshed state is published atomically. - Mark MCP state dirty when relevant configuration, plugins, environments, authentication, or elicitation capabilities change, then rebuild it before the next sampling request or out-of-band MCP operation. - Separate config reloads from server invalidation: `ReloadMcpConfig` applies resolved MCP inputs, while `RefreshMcpServers` requests reinitialization from the thread's latest state. ## Testing - Cover refreshed state visibility for existing turns, stable step bindings, current approval authority, cancelled refresh retries, resource-client reconciliation, and Apps recovery between sampling requests. GitOrigin-RevId: 59eabb1aa8dc083426bd18ef4d3630508f376401
29 lines
1.4 KiB
Rust
29 lines
1.4 KiB
Rust
use std::sync::Arc;
|
|
|
|
use crate::agents_md::LoadedAgentsMd;
|
|
use crate::environment_selection::TurnEnvironmentSnapshot;
|
|
use crate::session::turn_context::TurnContext;
|
|
use crate::tools::router::ToolRouter;
|
|
use codex_exec_server::ExecutorCapabilityDiscoverySnapshot;
|
|
use codex_exec_server::ResolvedSelectedCapabilityRoot;
|
|
use codex_mcp::McpBinding;
|
|
use codex_mcp::ToolInfo;
|
|
|
|
/// Request-scoped state that may change between model sampling requests.
|
|
pub(crate) struct StepContext {
|
|
pub(crate) turn: Arc<TurnContext>,
|
|
pub(crate) environments: TurnEnvironmentSnapshot,
|
|
/// Capability roots bound to ready environments in this exact step.
|
|
pub(crate) selected_capability_roots: Vec<ResolvedSelectedCapabilityRoot>,
|
|
/// Executor-materialized capability files shared by MCP and skills in this exact step.
|
|
pub(crate) executor_capability_discovery: Option<Arc<ExecutorCapabilityDiscoverySnapshot>>,
|
|
/// The exact MCP connections, configuration, and catalog captured for this step.
|
|
pub(crate) mcp: Arc<McpBinding>,
|
|
/// The fixed MCP tool list used for this exact sampling request.
|
|
pub(crate) mcp_tools: Vec<ToolInfo>,
|
|
/// The finalized tool plan advertised and executed for this exact sampling request.
|
|
pub(crate) tool_router: Arc<ToolRouter>,
|
|
/// The canonical AGENTS.md value observed with this environment snapshot.
|
|
pub(crate) loaded_agents_md: Option<Arc<LoadedAgentsMd>>,
|
|
}
|