Files
codex/codex-rs/models-manager/src/originator.rs
T
Kenny Yi 2326a3f74b Scope model catalogs and caches by thread originator (#56284)
## What changed

Select an originator-specific models manager before resolving thread model metadata. Supported originators send their own `originator` header and use separate in-memory catalogs and disk caches, so each thread receives the corresponding model instructions and tools.

Reuse managers for repeated originators and share the API-key model discovery setting across them. Unsupported originators retain the default manager and catalog.

## Testing

Add coverage for originator headers, concurrent catalog isolation, cache reuse across restarts, shared discovery policy, and the instructions and tools sent in actual turns.

GitOrigin-RevId: ae4aa51c8df2813a72fc8aed8978fd630e467069
2026-10-22 22:44:48 +00:00

34 lines
1006 B
Rust

//! Bounded catalog partitions for callers migrated to CCA. Other callers keep the default catalog.
#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq)]
pub enum ModelCatalogOriginator {
Work,
WorkWeb,
WorkDesktop,
WorkMobile,
Chat,
}
impl ModelCatalogOriginator {
pub fn from_originator(originator: &str) -> Option<Self> {
match originator {
"codex_work_cca" => Some(Self::Work),
"codex_work_web" => Some(Self::WorkWeb),
"codex_work_desktop" => Some(Self::WorkDesktop),
"codex_work_mobile" => Some(Self::WorkMobile),
"chatgpt_cca" => Some(Self::Chat),
_ => None,
}
}
pub fn as_str(self) -> &'static str {
match self {
Self::Work => "codex_work_cca",
Self::WorkWeb => "codex_work_web",
Self::WorkDesktop => "codex_work_desktop",
Self::WorkMobile => "codex_work_mobile",
Self::Chat => "chatgpt_cca",
}
}
}