Allow injecting the models manager into ThreadManager (#32911)

## Why

Embedding callers need to control whether model catalogs are persisted to disk.

## What changed

- Accept a shared models manager when constructing `ThreadManager` instead of always creating a cached manager internally.
- Add provider APIs for creating uncached model managers. OpenAI-compatible providers fetch on each `OnlineIfUncached` refresh without reading or writing `models_cache.json`.
- Keep existing app server, MCP server, sample, and test callers on the standard cached manager.

## Testing

- Verify an uncached manager fetches on every refresh.
- Verify an injected uncached manager controls thread refresh behavior and does not create `models_cache.json`.

GitOrigin-RevId: 8bb646054ecec4ccb865b2bf56249384916ea9db
This commit is contained in:
richardopenai
2026-07-14 01:01:37 +00:00
committed by copyberry
parent c39520f3d1
commit 80c6cd3014
17 changed files with 224 additions and 21 deletions

View File

@@ -55,6 +55,7 @@ use codex_core_api::UriBasedFileOpener;
use codex_core_api::UserInput;
use codex_core_api::WebSearchMode;
use codex_core_api::arg0_dispatch_or_else;
use codex_core_api::build_models_manager;
use codex_core_api::built_in_model_providers;
use codex_core_api::find_codex_home;
use codex_core_api::init_state_db;
@@ -132,7 +133,8 @@ async fn run_main(arg0_paths: Arg0DispatchPaths) -> anyhow::Result<()> {
});
let thread_manager = ThreadManager::new(
&config,
auth_manager,
Arc::clone(&auth_manager),
build_models_manager(&config, auth_manager),
SessionSource::Exec,
environment_manager,
Arc::new(extensions.build()),