mirror of
https://github.com/pchuan98/codex.git
synced 2026-07-01 00:31:56 +08:00
feat: config aliases (#18140)
Rename `no_memories_if_mcp_or_web_search` → `disable_on_external_context` with backward compatibility While doing so, we add a key alias system on our layer merging system. What we try to avoid is a case where a company managed config use an old name while the user has a new name in it's local config (which would make the deserialization fail)
This commit is contained in:
committed by
GitHub
Unverified
parent
af7b8d551c
commit
cfc23eee3d
@@ -863,6 +863,10 @@
|
||||
"description": "Model used for memory consolidation.",
|
||||
"type": "string"
|
||||
},
|
||||
"disable_on_external_context": {
|
||||
"description": "When `true`, external context sources mark the thread `memory_mode` as `\"polluted\"`.",
|
||||
"type": "boolean"
|
||||
},
|
||||
"extract_model": {
|
||||
"description": "Model used for thread summarisation.",
|
||||
"type": "string"
|
||||
@@ -900,10 +904,6 @@
|
||||
"format": "int64",
|
||||
"type": "integer"
|
||||
},
|
||||
"no_memories_if_mcp_or_web_search": {
|
||||
"description": "When `true`, web searches and MCP tool calls mark the thread `memory_mode` as `\"polluted\"`.",
|
||||
"type": "boolean"
|
||||
},
|
||||
"use_memories": {
|
||||
"description": "When `false`, skip injecting memory usage instructions into developer prompts.",
|
||||
"type": "boolean"
|
||||
|
||||
@@ -221,7 +221,7 @@ persistence = "none"
|
||||
|
||||
let memories = r#"
|
||||
[memories]
|
||||
no_memories_if_mcp_or_web_search = true
|
||||
disable_on_external_context = true
|
||||
generate_memories = false
|
||||
use_memories = false
|
||||
max_raw_memories_for_consolidation = 512
|
||||
@@ -236,7 +236,7 @@ consolidation_model = "gpt-5"
|
||||
toml::from_str::<ConfigToml>(memories).expect("TOML deserialization should succeed");
|
||||
assert_eq!(
|
||||
Some(MemoriesToml {
|
||||
no_memories_if_mcp_or_web_search: Some(true),
|
||||
disable_on_external_context: Some(true),
|
||||
generate_memories: Some(false),
|
||||
use_memories: Some(false),
|
||||
max_raw_memories_for_consolidation: Some(512),
|
||||
@@ -260,7 +260,7 @@ consolidation_model = "gpt-5"
|
||||
assert_eq!(
|
||||
config.memories,
|
||||
MemoriesConfig {
|
||||
no_memories_if_mcp_or_web_search: true,
|
||||
disable_on_external_context: true,
|
||||
generate_memories: false,
|
||||
use_memories: false,
|
||||
max_raw_memories_for_consolidation: 512,
|
||||
@@ -272,6 +272,18 @@ consolidation_model = "gpt-5"
|
||||
consolidation_model: Some("gpt-5".to_string()),
|
||||
}
|
||||
);
|
||||
|
||||
let legacy_memories_cfg =
|
||||
toml::from_str::<ConfigToml>("[memories]\nno_memories_if_mcp_or_web_search = true\n")
|
||||
.expect("legacy memories TOML should deserialize");
|
||||
assert!(
|
||||
MemoriesConfig::from(
|
||||
legacy_memories_cfg
|
||||
.memories
|
||||
.expect("legacy memories config")
|
||||
)
|
||||
.disable_on_external_context
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
||||
@@ -541,11 +541,7 @@ async fn augment_mcp_tool_request_meta_with_sandbox_state(
|
||||
}
|
||||
|
||||
async fn maybe_mark_thread_memory_mode_polluted(sess: &Session, turn_context: &TurnContext) {
|
||||
if !turn_context
|
||||
.config
|
||||
.memories
|
||||
.no_memories_if_mcp_or_web_search
|
||||
{
|
||||
if !turn_context.config.memories.disable_on_external_context {
|
||||
return;
|
||||
}
|
||||
state_db::mark_thread_memory_mode_polluted(
|
||||
|
||||
@@ -154,10 +154,7 @@ pub(crate) async fn mark_thread_memory_mode_polluted_if_external_context(
|
||||
turn_context: &TurnContext,
|
||||
item: &ResponseItem,
|
||||
) {
|
||||
if !turn_context
|
||||
.config
|
||||
.memories
|
||||
.no_memories_if_mcp_or_web_search
|
||||
if !turn_context.config.memories.disable_on_external_context
|
||||
|| !response_item_may_include_external_context(item)
|
||||
{
|
||||
return;
|
||||
|
||||
@@ -314,7 +314,7 @@ async fn web_search_pollution_moves_selected_thread_into_removed_phase2_inputs()
|
||||
.enable(Feature::MemoryTool)
|
||||
.expect("test config should allow feature update");
|
||||
config.memories.max_raw_memories_for_consolidation = 1;
|
||||
config.memories.no_memories_if_mcp_or_web_search = true;
|
||||
config.memories.disable_on_external_context = true;
|
||||
});
|
||||
let initial = initial_builder.build(&server).await?;
|
||||
mount_sse_once(
|
||||
@@ -386,7 +386,7 @@ async fn web_search_pollution_moves_selected_thread_into_removed_phase2_inputs()
|
||||
.enable(Feature::MemoryTool)
|
||||
.expect("test config should allow feature update");
|
||||
config.memories.max_raw_memories_for_consolidation = 1;
|
||||
config.memories.no_memories_if_mcp_or_web_search = true;
|
||||
config.memories.disable_on_external_context = true;
|
||||
});
|
||||
let resumed = resumed_builder
|
||||
.resume(&server, home.clone(), rollout_path.clone())
|
||||
|
||||
@@ -297,7 +297,7 @@ async fn web_search_marks_thread_memory_mode_polluted_when_configured() -> Resul
|
||||
.features
|
||||
.enable(Feature::Sqlite)
|
||||
.expect("test config should allow feature update");
|
||||
config.memories.no_memories_if_mcp_or_web_search = true;
|
||||
config.memories.disable_on_external_context = true;
|
||||
});
|
||||
let test = builder.build(&server).await?;
|
||||
let db = test.codex.state_db().expect("state db enabled");
|
||||
@@ -355,7 +355,7 @@ async fn mcp_call_marks_thread_memory_mode_polluted_when_configured() -> Result<
|
||||
.features
|
||||
.enable(Feature::Sqlite)
|
||||
.expect("test config should allow feature update");
|
||||
config.memories.no_memories_if_mcp_or_web_search = true;
|
||||
config.memories.disable_on_external_context = true;
|
||||
|
||||
let mut servers = config.mcp_servers.get().clone();
|
||||
servers.insert(
|
||||
|
||||
Reference in New Issue
Block a user