Preserve model catalogs when starting child agents (#60049)

## Why

Child startup can lose remote model capabilities such as `tool_search` when the selected catalog is uninitialized or disk data is older than the parent's in-memory snapshot.

## What changed

- Initialize the final provider, auth, and originator catalog before resolving a child's startup model, then read it from memory.
- Preserve loaded catalogs, including empty responses and updates that failed to persist, without overwriting concurrent refreshes.
- Reuse catalogs across retry and WebSocket transport overrides while retaining routing and header distinctions.

## Testing

Add regression coverage for child tool search with warm, cold, and disabled caches; failed cache writes; concurrent refreshes; empty catalogs; and Guardian reviewer catalog reuse.

GitOrigin-RevId: 01d995a65b623cc7d6f26e2dc9b6e8cf380de782
This commit is contained in:
evanz-oai
2026-11-07 03:16:52 +00:00
committed by copyberry
parent 358e464528
commit 44ccf39457
15 changed files with 682 additions and 80 deletions
+4 -5
View File
@@ -605,15 +605,14 @@ impl Session {
session_source: &SessionSource,
allow_provider_model_fallback: bool,
) -> CodexResult<(String, CatalogModel)> {
// Child catalogs are initialized by their selector. Reading only memory here
// preserves the loaded snapshot shared with the parent.
let refresh_strategy = if session_source.is_non_root_agent() {
RefreshStrategy::Offline
RefreshStrategy::InMemory
} else {
RefreshStrategy::OnlineIfUncached
};
if config.features.enabled(Feature::RuntimeAgentInstances)
|| config.model.is_none()
|| refresh_strategy != RefreshStrategy::Offline
{
if !session_source.is_non_root_agent() {
let _ = models_manager
.list_models(refresh_strategy, config.http_client_factory())
.await;
@@ -360,6 +360,10 @@ impl GatedModelsManager {
}
impl ModelsManager for GatedModelsManager {
fn ensure_initialized(&self, factory: HttpClientFactory) -> ModelsManagerFuture<'_, ()> {
self.inner.ensure_initialized(factory)
}
fn model_catalog_with_origins(
&self,
strategy: RefreshStrategy,