feat: use provider defaults for memory models (#27129)

## Why

Memory startup used hardcoded OpenAI model slugs for extraction and
consolidation. That works for the default OpenAI-compatible path, but
provider-specific backends can require different model identifiers. In
particular, Amazon Bedrock should use its Bedrock model ID for these
background memory requests instead of the OpenAI `gpt-5.4-mini` /
`gpt-5.4` slugs.

## What Changed

- Added provider-owned preferred memory model methods alongside
`approval_review_preferred_model`.
- Updated memory extraction and consolidation to resolve their default
model through the active `ModelProvider`.
- Added Amazon Bedrock overrides so both memory stages use
`openai.gpt-5.4` through Bedrock’s provider-specific model ID.
- Kept explicit `memories.extract_model` and
`memories.consolidation_model` config overrides taking precedence.
- Added startup coverage for default OpenAI and Bedrock memory model
selection.

#closes #26288
This commit is contained in:
Celia Chen
2026-06-09 23:49:09 +00:00
committed by GitHub
parent fb8f1ea0d5
commit 51fc4b0559
9 changed files with 413 additions and 13 deletions
+54
View File
@@ -13,6 +13,9 @@ use codex_login::AuthManager;
use codex_login::CodexAuth;
use codex_login::auth_env_telemetry::collect_auth_env_telemetry;
use codex_login::default_client::originator;
use codex_model_provider::ModelProvider;
use codex_model_provider::SharedModelProvider;
use codex_model_provider::create_model_provider;
use codex_otel::SessionTelemetry;
use codex_otel::TelemetryAuthMode;
use codex_protocol::SessionId;
@@ -68,6 +71,7 @@ pub(crate) struct MemoryStartupContext {
thread: Arc<CodexThread>,
thread_manager: Arc<ThreadManager>,
auth_manager: Arc<AuthManager>,
provider: SharedModelProvider,
session_telemetry: SessionTelemetry,
}
@@ -79,6 +83,51 @@ impl MemoryStartupContext {
thread: Arc<CodexThread>,
config: &Config,
source: SessionSource,
) -> Self {
let provider = create_model_provider(
config.model_provider.clone(),
Some(Arc::clone(&auth_manager)),
);
Self::new_with_provider(
thread_manager,
auth_manager,
thread_id,
thread,
config,
source,
provider,
)
}
#[cfg(test)]
pub(crate) fn new_for_testing(
thread_manager: Arc<ThreadManager>,
auth_manager: Arc<AuthManager>,
thread_id: ThreadId,
thread: Arc<CodexThread>,
config: &Config,
source: SessionSource,
provider: SharedModelProvider,
) -> Self {
Self::new_with_provider(
thread_manager,
auth_manager,
thread_id,
thread,
config,
source,
provider,
)
}
fn new_with_provider(
thread_manager: Arc<ThreadManager>,
auth_manager: Arc<AuthManager>,
thread_id: ThreadId,
thread: Arc<CodexThread>,
config: &Config,
source: SessionSource,
provider: SharedModelProvider,
) -> Self {
let auth = auth_manager.auth_cached();
let auth = auth.as_ref();
@@ -109,6 +158,7 @@ impl MemoryStartupContext {
thread,
thread_manager,
auth_manager,
provider,
session_telemetry,
}
}
@@ -121,6 +171,10 @@ impl MemoryStartupContext {
self.thread.state_db()
}
pub(crate) fn provider(&self) -> &dyn ModelProvider {
self.provider.as_ref()
}
pub(crate) fn counter(&self, name: &str, inc: i64, tags: &[(&str, &str)]) {
self.session_telemetry.counter(name, inc, tags);
}