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 authored and GitHub committed 2026-06-09 23:49:09 +00:00
1 parent fb8f1ea0d5
commit 51fc4b0559
9 files changed
+413 -13

No files matched your search

+4 -3
View File
@@ -16,6 +16,7 @@ use crate::workspace::write_workspace_diff;
use codex_config::Constrained;
use codex_core::config::Config;
use codex_features::Feature;
use codex_model_provider::ModelProvider;
use codex_protocol::ThreadId;
use codex_protocol::protocol::AgentStatus;
use codex_protocol::protocol::AskForApproval;
@@ -76,7 +77,7 @@ pub async fn run(context: Arc<MemoryStartupContext>, config: Arc<Config>) {
}
// 3. Build the locked-down config used by the consolidation agent.
let Some(agent_config) = agent::get_config(config.as_ref()) else {
let Some(agent_config) = agent::get_config(config.as_ref(), context.provider()) else {
// If we can't get the config, we can't consolidate.
tracing::error!("failed to get agent config");
job::failed(
@@ -297,7 +298,7 @@ mod agent {
use super::*;
use tracing::warn;
pub(super) fn get_config(config: &Config) -> Option<Config> {
pub(super) fn get_config(config: &Config, provider: &dyn ModelProvider) -> Option<Config> {
let root = memory_root(&config.codex_home);
let mut agent_config = config.clone();
@@ -339,7 +340,7 @@ mod agent {
.memories
.consolidation_model
.clone()
.unwrap_or(crate::stage_two::MODEL.to_string()),
.unwrap_or_else(|| provider.memory_consolidation_preferred_model().to_string()),
);
agent_config.model_reasoning_effort = Some(crate::stage_two::REASONING_EFFORT);