Acquire and cache opt-in executor capability inventories via V2 (#53736)

## What changed

- Add the disabled-by-default `executor_capability_discovery_v2` feature to acquire `capabilities/discoverV2` inventories from supporting remote executors using each selected environment's working directory and sandbox.
- Share snapshots with MCP and world-state contributors and skill providers without activating discovered plugins or publishing discovered skills to the model.
- Cache inventories by environment instance, executor session, working directory, and sandbox. Coalesce concurrent requests, refresh the cache at turn start, retry transient failures, and refresh MCP projections after recovery.
- Resolve the system skills root in the executor and pass it explicitly to capability location discovery.

## Testing

Add coverage for feature gating, unsupported executors, inert inventories, cache reuse and eviction, turn refreshes, failure recovery, executor replacement, and system skill locations.

GitOrigin-RevId: 1bdca28fa7f17622b27e2713ab3dcc0c13426889
This commit is contained in:
Anthony Tafoya
2026-10-13 18:15:50 +00:00
committed by copyberry
parent 4d82d36ccf
commit cf0ed4c600
39 changed files with 1027 additions and 12 deletions
+10
View File
@@ -3923,6 +3923,9 @@ impl Session {
.await;
let ready_selected_capability_roots =
Self::ready_selected_capability_roots(&selected_capability_roots);
let executor_capability_discovery_v2 = self
.executor_capability_discovery_for_step_v2(&turn_context.config, &environments)
.await;
let executor_capability_discovery = self
.executor_capability_discovery_for_step(
&turn_context.config,
@@ -3932,6 +3935,9 @@ impl Session {
.await;
let extension_data =
codex_extension_api::ExtensionData::new(turn_context.sub_id.clone());
if let Some(snapshots) = &executor_capability_discovery_v2 {
extension_data.insert(snapshots.clone());
}
if let Some(messages) = settings
.model_info
.model_messages
@@ -3969,6 +3975,7 @@ impl Session {
&turn_context.originator,
&ready_selected_capability_roots,
executor_capability_discovery.as_deref(),
executor_capability_discovery_v2.as_deref(),
)
.with_session_source(&turn_context.session_source)
.with_selected_environments(&environments.all_selections()),
@@ -3990,6 +3997,7 @@ impl Session {
Ok::<_, CodexErr>((
selected_capability_roots,
executor_capability_discovery,
executor_capability_discovery_v2,
mcp,
tool_router,
extension_data,
@@ -4005,6 +4013,7 @@ impl Session {
let (
selected_capability_roots,
executor_capability_discovery,
executor_capability_discovery_v2,
mcp,
tool_router,
extension_data,
@@ -4024,6 +4033,7 @@ impl Session {
selected_capability_roots,
executor_capability_discovery,
extension_data,
executor_capability_discovery_v2,
mcp,
tool_router,
loaded_agents_md,