aKode: rimossa la memoria nativa di Codex e le funzioni senza codice; meno chiamate al modello

Memoria nativa (memories) rimossa del tutto:
- features: memories, memory_tool, external_agent_memory_import, chronicle
  (alias telepathy) diventano Removed; le chiavi restano accettate e
  memories/memory_tool/[memories] producono un solo avviso senza link
  («La sezione [memories] e la chiave memory_tool non sono più usate da
  aKode: la memoria a lungo termine è il plugin memoria di imeAI.»).
- Tolti i crate memories/read, memories/write ed ext/memories, l'avvio
  della pipeline a ogni turno (app-server), l'estensione, /memories e la
  richiesta di attivazione nella TUI, `akode debug clear-memories`,
  l'importazione delle memorie da altri agenti (memory_import.rs,
  detect/memory.rs; il resto di /import resta).
- core: niente più MemoriesConfig, citazioni delle memorie, metriche e
  marcatura «polluted» dei thread; [memories] (MemoriesToml) resta solo
  come sezione accettata e ignorata.
- state: memories_1.sqlite e memories_v2_1.sqlite non vengono più aperti né
  cancellati; la colonna threads.memory_mode resta, nessuna migrazione.
- Protocollo app-server invariato per compatibilità col daemon:
  memory/reset risponde «non supportato» senza cancellare nulla,
  memory/status non è mai pronto, thread/memory/read non ha riassunto.

Altre rimozioni:
- I 14 flag dell'app desktop di OpenAI senza codice (tool_suggest,
  in_app_*, browser_use*, computer_use, bedrock_setup_wizard,
  workspace_dependencies) e analytics_plan_history: Removed, chiavi
  accettate; analytics_plan_history esce da /experimental.
- Skill: tolto l'esperimento «shadow selection» e i selettori collegati.

Meno chiamate al modello non richieste:
- Titoli dei thread: il primo messaggio dell'utente su una riga, troncato a
  36 caratteri; `[tui] auto_title = true` riattiva i titoli generati.
- `[tui] auto_recap` predefinito false; `goals` spento di default.

Privacy: installation_id e gli id di sessione/thread/finestra (e il blocco
dei metadati del turno che li ripete) vanno in client_metadata e negli
header di compatibilità solo ai provider locali (loopback, IP privati
10/8, 172.16/12, 192.168/16, host .local/.lan).

Domini OpenAI: tolti i link visibili (avviso dei flag deprecati, profili,
bubblewrap), l'attribuzione Codex nei commit (sempre spenta), la
riscrittura dell'URL della documentazione OpenAI via MCP e la
registrazione remota dell'exec-server verso host OpenAI (ora solo
loopback); il riconoscimento delle destinazioni OpenAI confronta i domini
etichetta per etichetta. Il binario non contiene più «openai.com» né
«chatgpt.com».

Test adattati (sicurezza compresa: guardian, ruolo ostile, exec-server
ora più restrittivo); rimossi solo quelli del codice tolto.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
andrea.difonzo
2026-11-15 00:49:41 +01:00
parent 0da982206c
commit 854c7a66c9
269 changed files with 1194 additions and 27290 deletions

View File

@@ -47,11 +47,7 @@ async fn sibling_wake_preserves_worker_permissions(selection: WorkerPermissions)
default_permissions = "startup"
model_instructions_file = {}
[features]
memories = {supports_read_restrictions}
network_proxy = true
[memories]
generate_memories = false
use_memories = {supports_read_restrictions}
[permissions.startup.filesystem]
":workspace_roots" = "read"
{root_read}
@@ -110,7 +106,7 @@ extends = "startup"
.with_managed_config(managed_config)
.with_config(configure);
let initial = builder.build_with_auto_env(&server).await?;
// Start with the loader's profile, including a memory read grant where supported.
// Start with the loader's profile.
let profile = initial.config.permissions.permission_profile().clone();
let mut filesystem = profile.file_system_sandbox_policy();
assert_eq!(
@@ -118,14 +114,6 @@ extends = "startup"
!supports_read_restrictions
);
if supports_read_restrictions {
let memory_root = initial
.config
.codex_home
.join(initial.config.memories.version.directory_name());
assert!(
filesystem
.can_read_local_path_with_cwd(memory_root.as_path(), initial.config.cwd.as_path())
);
filesystem.entries.push(FileSystemSandboxEntry::new(
initial.workspace_path_uri("secrets")?.into(),
FileSystemAccessMode::Deny,

View File

@@ -46,7 +46,7 @@ async fn emits_deprecation_notice_for_legacy_feature_flag() -> anyhow::Result<()
assert_eq!(
details.as_deref(),
Some(
"Enable it with `--enable unified_exec` or `[features].unified_exec` in config.toml. See https://developers.openai.com/codex/config-basic#feature-flags for details."
"Enable it with `--enable unified_exec` or `[features].unified_exec` in config.toml."
),
);

View File

@@ -534,7 +534,6 @@ async fn check_acquisition(enabled: bool, version: &'static str) -> Result<()> {
omit_descriptions: false,
max_context_tokens: config.skill_max_context_tokens,
bundled_skills_enabled: false,
shadow_selection_enabled: false,
},
);
let test = test_codex()

View File

@@ -509,7 +509,6 @@ async fn guardian_reviews_with_offline_primary_executor() -> Result<()> {
omit_descriptions: false,
max_context_tokens: config.skill_max_context_tokens,
bundled_skills_enabled: false,
shadow_selection_enabled: false,
}
});
let test = test_codex()

View File

@@ -797,61 +797,6 @@ async fn mcp_tool_hook_timeout_includes_cached_server_startup() -> Result<()> {
Ok(())
}
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
async fn mcp_tool_hook_marks_thread_memory_mode_polluted_when_configured() -> Result<()> {
skip_if_no_network!(Ok(()));
let server = start_mock_server().await;
mount_sse_once(
&server,
sse(vec![
ev_response_created("resp-1"),
ev_assistant_message("msg-1", "hook context received"),
ev_completed("resp-1"),
]),
)
.await;
let rmcp_test_server_bin = stdio_server_bin()?;
let test = test_codex()
.with_pre_build_hook(|home| {
write_mcp_tool_hook(
home,
"UserPromptSubmit",
/*matcher*/ None,
RMCP_SERVER,
r#"{"hookSpecificOutput":{"hookEventName":"UserPromptSubmit","additionalContext":"external MCP context"}}"#,
)
.expect("write MCP prompt hook fixture");
})
.with_config(move |config| {
enable_hooks_and_rmcp_server(
config,
rmcp_test_server_bin,
AppToolApproval::Prompt,
/*prefix_mcp_tool_names*/ true,
);
config
.features
.enable(Feature::Sqlite)
.expect("test config should allow feature update");
config.memories.disable_on_external_context = true;
})
.build(&server)
.await?;
wait_for_mcp_server(&test.codex, RMCP_SERVER).await?;
let db = test.codex.state_db().expect("state db enabled");
let thread_id = test.session_configured.thread_id;
test.submit_turn("review checkout.rs").await?;
assert_eq!(
db.get_thread_memory_mode(thread_id).await?,
Some("polluted".to_string())
);
Ok(())
}
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
async fn mcp_tool_hook_blocks_model_tool_without_recursive_hooks_or_approval() -> Result<()> {
skip_if_no_network!(Ok(()));

View File

@@ -92,7 +92,6 @@ fn skills_extensions() -> Arc<ExtensionRegistry<Config>> {
omit_descriptions: false,
max_context_tokens: config.skill_max_context_tokens,
bundled_skills_enabled: config.bundled_skills_enabled(),
shadow_selection_enabled: config.features.enabled(Feature::SkillSearch),
});
Arc::new(extensions.build())
}

View File

@@ -77,7 +77,6 @@ fn skills_extensions() -> Arc<ExtensionRegistry<Config>> {
omit_descriptions: false,
max_context_tokens: config.skill_max_context_tokens,
bundled_skills_enabled: config.bundled_skills_enabled(),
shadow_selection_enabled: config.features.enabled(Feature::SkillSearch),
});
Arc::new(extensions.build())
}

View File

@@ -79,7 +79,6 @@ async fn required_environment_skill_gates_inference(availability: Availability)
omit_descriptions: false,
max_context_tokens: None,
bundled_skills_enabled: false,
shadow_selection_enabled: false,
},
);
let server = start_mock_server().await;

View File

@@ -2342,7 +2342,6 @@ async fn local_stdio_server_uses_runtime_fallback_cwd_when_config_omits_cwd() ->
omit_descriptions: false,
max_context_tokens: config.skill_max_context_tokens,
bundled_skills_enabled: config.bundled_skills_enabled(),
shadow_selection_enabled: config.features.enabled(Feature::SkillSearch),
}
});
let mut fixture = test_codex()

View File

@@ -252,7 +252,6 @@ fn skills_extensions() -> Arc<ExtensionRegistry<Config>> {
.enabled(akode_features::Feature::OmitSkillDescriptions),
max_context_tokens: config.skill_max_context_tokens,
bundled_skills_enabled: config.bundled_skills_enabled(),
shadow_selection_enabled: config.features.enabled(Feature::SkillSearch),
});
Arc::new(extensions.build())
}
@@ -1393,7 +1392,6 @@ async fn astra_omits_disabled_executor_and_plugin_skills_from_model_context(
.enabled(akode_features::Feature::OmitSkillDescriptions),
max_context_tokens: config.skill_max_context_tokens,
bundled_skills_enabled: false,
shadow_selection_enabled: false,
},
);
let mock = mount_sse_sequence(

View File

@@ -60,7 +60,6 @@ async fn skill_catalog_deltas_survive_resume_and_rebuild_after_compaction() -> R
omit_descriptions: config.features.enabled(Feature::OmitSkillDescriptions),
max_context_tokens: config.skill_max_context_tokens,
bundled_skills_enabled: false,
shadow_selection_enabled: false,
catalog_deltas_enabled: config.features.enabled(Feature::SkillCatalogDeltas),
},
);

View File

@@ -329,7 +329,6 @@ async fn user_turn_selects_symlinked_skill_by_advertised_discovery_path() -> Res
omit_descriptions: false,
max_context_tokens: config.skill_max_context_tokens,
bundled_skills_enabled: false,
shadow_selection_enabled: false,
});
let mut builder = test_codex()
.with_extensions(Arc::new(extensions.build()))

View File

@@ -350,7 +350,6 @@ fn catalog_extensions(
omit_descriptions: false,
max_context_tokens: config.skill_max_context_tokens,
bundled_skills_enabled: false,
shadow_selection_enabled: false,
}
});
(Arc::new(extensions.build()), event_rx)
@@ -620,7 +619,6 @@ async fn capability_sections_render_in_order_with_host_repo_and_plugin_skills(
omit_descriptions: false,
max_context_tokens: config.skill_max_context_tokens,
bundled_skills_enabled: config.bundled_skills_enabled(),
shadow_selection_enabled: config.features.enabled(Feature::SkillSearch),
});
let mut builder = test_codex()
.with_home(Arc::clone(&codex_home))
@@ -833,7 +831,6 @@ async fn repository_skill_cache_cannot_read_inaccessible_files(
catalog_deltas_enabled: config.features.enabled(Feature::SkillCatalogDeltas),
omit_descriptions: false,
bundled_skills_enabled: false,
shadow_selection_enabled: false,
});
let builder = test_codex()
.with_extensions(Arc::new(extensions.build()))
@@ -1557,7 +1554,6 @@ async fn opted_in_executor_provider_skips_host_discovery_but_injects_discovered_
omit_descriptions: false,
max_context_tokens: config.skill_max_context_tokens,
bundled_skills_enabled: false,
shadow_selection_enabled: false,
},
);
let mut builder = test_codex()
@@ -1784,7 +1780,6 @@ async fn executor_only_provider_preserves_structured_repo_skill_without_discover
omit_descriptions: false,
max_context_tokens: config.skill_max_context_tokens,
bundled_skills_enabled: false,
shadow_selection_enabled: false,
},
);
let mut builder = test_codex()
@@ -1931,7 +1926,6 @@ async fn executor_skill_tool_reads_references_under_current_permissions(
omit_descriptions: false,
max_context_tokens: config.skill_max_context_tokens,
bundled_skills_enabled: false,
shadow_selection_enabled: false,
},
);
let mut builder = test_codex()
@@ -2362,7 +2356,6 @@ async fn explicit_executor_skill_prompt_rejects_oversized_resource() -> Result<(
omit_descriptions: false,
max_context_tokens: config.skill_max_context_tokens,
bundled_skills_enabled: false,
shadow_selection_enabled: false,
},
);
let mut builder = test_codex()
@@ -2575,7 +2568,6 @@ async fn production_turn_aliases_executor_and_host_catalogs() -> Result<()> {
omit_descriptions: false,
max_context_tokens: config.skill_max_context_tokens,
bundled_skills_enabled: false,
shadow_selection_enabled: false,
},
);
let mut builder = test_codex()
@@ -2696,7 +2688,6 @@ async fn assert_catalog_model_switch(max_context_tokens: Option<usize>) -> Resul
omit_descriptions: false,
max_context_tokens: config.skill_max_context_tokens,
bundled_skills_enabled: false,
shadow_selection_enabled: false,
},
);
let mut builder = test_codex()
@@ -3134,7 +3125,6 @@ async fn production_turn_uses_provider_host_catalog_and_core_snapshot_injection(
omit_descriptions: false,
max_context_tokens: config.skill_max_context_tokens,
bundled_skills_enabled: false,
shadow_selection_enabled: false,
},
);
let mut builder = mcp_server_builder(apps_server.base_url)
@@ -3245,7 +3235,6 @@ async fn production_turn_suppresses_only_the_superseded_host_skill_prompt() -> R
omit_descriptions: false,
max_context_tokens: config.skill_max_context_tokens,
bundled_skills_enabled: false,
shadow_selection_enabled: false,
},
);
let mut builder = test_codex()
@@ -3671,7 +3660,6 @@ async fn production_turn_fairly_shortens_extension_catalog_descriptions() -> Res
omit_descriptions: false,
max_context_tokens: config.skill_max_context_tokens,
bundled_skills_enabled: false,
shadow_selection_enabled: false,
},
);
let mut builder = test_codex()

View File

@@ -8,14 +8,14 @@ Scenario: An injected agent message that interrupts sampling is included in the
-- request 1 (request) --
00:message/developer:
You are aKode, a coding agent that runs in the user's terminal on their own machine, powered by a locall...de, commands, identifiers and file paths as they are. [hash=8d33e416df2f88da]
Your name is aKode. If asked who you are or who made you, say you are aKode, a private coding agent runn...server; never claim to be another product or company. [hash=abefb7da60b0007a]
You can read the workspace, run shell commands, edit files with `apply_patch`, keep a plan with `update_...actions run in a sandbox or need the user's approval. [hash=f98f685055e9a5e0]
# How you work
## Act, don't announce
<OMITTED 77 LINES; ~1165 TOKENS; hash=70eadf354b1ed25d>
<OMITTED 78 LINES; ~1166 TOKENS; hash=c5c832bfcc169857>
- Search with `rg` (text) and `rg --files` (files); fall back to `grep`/`find` if `rg` is missing.
- Read files in reasonable chunks; don't use scripts just to print large parts of a file.
- Prefer non-interactive commands and set timeouts for anything that might hang.
@@ -35,14 +35,14 @@ Scenario: An injected agent message that interrupts sampling is included in the
-- request 2 (request) --
00:message/developer:
You are aKode, a coding agent that runs in the user's terminal on their own machine, powered by a locall...de, commands, identifiers and file paths as they are. [hash=8d33e416df2f88da]
Your name is aKode. If asked who you are or who made you, say you are aKode, a private coding agent runn...server; never claim to be another product or company. [hash=abefb7da60b0007a]
You can read the workspace, run shell commands, edit files with `apply_patch`, keep a plan with `update_...actions run in a sandbox or need the user's approval. [hash=f98f685055e9a5e0]
# How you work
## Act, don't announce
<OMITTED 77 LINES; ~1165 TOKENS; hash=70eadf354b1ed25d>
<OMITTED 78 LINES; ~1166 TOKENS; hash=c5c832bfcc169857>
- Search with `rg` (text) and `rg --files` (files); fall back to `grep`/`find` if `rg` is missing.
- Read files in reasonable chunks; don't use scripts just to print large parts of a file.
- Prefer non-interactive commands and set timeouts for anything that might hang.
@@ -65,14 +65,14 @@ Scenario: An injected agent message that interrupts sampling is included in the
-- request 3 (request) --
00:message/developer:
You are aKode, a coding agent that runs in the user's terminal on their own machine, powered by a locall...de, commands, identifiers and file paths as they are. [hash=8d33e416df2f88da]
Your name is aKode. If asked who you are or who made you, say you are aKode, a private coding agent runn...server; never claim to be another product or company. [hash=abefb7da60b0007a]
You can read the workspace, run shell commands, edit files with `apply_patch`, keep a plan with `update_...actions run in a sandbox or need the user's approval. [hash=f98f685055e9a5e0]
# How you work
## Act, don't announce
<OMITTED 77 LINES; ~1165 TOKENS; hash=70eadf354b1ed25d>
<OMITTED 78 LINES; ~1166 TOKENS; hash=c5c832bfcc169857>
- Search with `rg` (text) and `rg --files` (files); fall back to `grep`/`find` if `rg` is missing.
- Read files in reasonable chunks; don't use scripts just to print large parts of a file.
- Prefer non-interactive commands and set timeouts for anything that might hang.

View File

@@ -15,13 +15,13 @@ Settings:
stream: true
text: {"verbosity":"low"}
tool_choice: "auto"
tools (7; hash=0dea9012dd51867e):
tools (7; hash=4be6331020d8f43a):
- function/exec_command: Runs a command in a PTY, returning output or a session ID for ongoing interaction.; args=[cmd, justification, login, max_output_tokens, prefix_rule, sandbox_permissions, shell, tty, workdir, yield_time_ms]; hash=c04108e51a8548c5
- function/write_stdin: Writes characters to an existing unified exec session and returns recent output.; args=[chars, max_output_tokens, session_id, yield_time_ms]; hash=7fb62d8a3e2df4e2
- function/request_user_input: Request user input for one to three short questions and wait for the response. This tool is only ...; args=[questions]; hash=64a729b25c424fc6
- custom/apply_patch: The `apply_patch` tool can be used to edit files. This is a FREEFORM tool, so do not wrap the pat...; hash=dea9f12b0111a4ba
- function/view_image: View a local image file from the filesystem when visual inspection is needed. Use this for images...; args=[path]; hash=1908de9c0be7118a
- namespace/web: Tools in the web namespace.; hash=c60e4db83b9fd6b0
- namespace/web: Tools in the web namespace.; hash=dd6e98ab1f4ddce6
- function/run
- tool_search: # Tool discovery Searches over deferred tool metadata with BM25 and exposes matching tools for t...; args=[limit, query]; hash=b573ed69c0b0e6c7
-- request 1 (turn) --

View File

@@ -1,63 +1,38 @@
use akode_config::types::McpServerConfig;
use akode_config::types::McpServerTransportConfig;
use akode_core::StartThreadOptions;
use akode_core::TurnInputRequest;
use akode_core::config::Config;
use akode_extension_api::ExtensionRegistryBuilder;
use akode_features::Feature;
use akode_history::RolloutItem;
use akode_history::RolloutLine;
use akode_login::CodexAuth;
use akode_protocol::ThreadId;
use akode_protocol::config_types::CollaborationMode;
use akode_protocol::config_types::ModeKind;
use akode_protocol::config_types::Settings;
use akode_protocol::config_types::WebSearchMode;
use akode_protocol::dynamic_tools::DynamicToolFunctionSpec;
use akode_protocol::dynamic_tools::DynamicToolNamespaceSpec;
use akode_protocol::dynamic_tools::DynamicToolNamespaceTool;
use akode_protocol::dynamic_tools::DynamicToolSpec;
use akode_protocol::models::PermissionProfile;
use akode_protocol::protocol::AskForApproval;
use akode_protocol::protocol::EventMsg;
use akode_protocol::protocol::Op;
use akode_protocol::protocol::SessionMeta;
use akode_protocol::protocol::SessionMetaLine;
use akode_protocol::protocol::SessionSource;
use akode_protocol::protocol::ThreadSettingsOverrides;
use akode_protocol::protocol::UserMessageEvent;
use akode_protocol::user_input::UserInput;
use akode_thread_store::ThreadMetadataPatch;
use akode_web_search_extension::install as install_web_search_extension;
use anyhow::Result;
use core_test_support::responses;
use core_test_support::responses::ev_completed;
use core_test_support::responses::ev_function_call;
use core_test_support::responses::ev_response_created;
use core_test_support::responses::ev_web_search_call_done;
use core_test_support::responses::mount_sse_once;
use core_test_support::responses::mount_sse_sequence;
use core_test_support::responses::start_mock_server;
use core_test_support::skip_if_no_network;
use core_test_support::stdio_server_bin;
use core_test_support::test_codex::local_requests;
use core_test_support::test_codex::test_codex;
use core_test_support::test_codex::turn_permission_fields;
use core_test_support::wait_for_event;
use core_test_support::wait_for_event_match;
use core_test_support::wait_for_mcp_server;
use pretty_assertions::assert_eq;
use serde_json::json;
use std::collections::HashMap;
use std::fs;
use std::sync::Arc;
use tokio::time::Duration;
use tracing_subscriber::prelude::*;
use uuid::Uuid;
use wiremock::Mock;
use wiremock::ResponseTemplate;
use wiremock::matchers::method;
use wiremock::matchers::path;
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
async fn new_thread_is_recorded_in_state_db() -> Result<()> {
@@ -571,258 +546,6 @@ async fn user_messages_persist_in_state_db() -> Result<()> {
Ok(())
}
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
async fn web_search_marks_thread_memory_mode_polluted_when_configured() -> Result<()> {
let server = start_mock_server().await;
mount_sse_sequence(
&server,
vec![responses::sse(vec![
ev_response_created("resp-1"),
ev_web_search_call_done("ws-1", "completed", "weather seattle"),
ev_completed("resp-1"),
])],
)
.await;
let mut builder = test_codex().with_config(|config| {
config
.features
.enable(Feature::Sqlite)
.expect("test config should allow feature update");
config.memories.disable_on_external_context = true;
});
let test = builder.build(&server).await?;
let db = test.codex.state_db().expect("state db enabled");
let thread_id = test.session_configured.thread_id;
test.submit_turn("search the web").await?;
let mut memory_mode = None;
for _ in 0..100 {
memory_mode = db.get_thread_memory_mode(thread_id).await?;
if memory_mode.as_deref() == Some("polluted") {
break;
}
tokio::time::sleep(Duration::from_millis(25)).await;
}
assert_eq!(memory_mode.as_deref(), Some("polluted"));
Ok(())
}
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
async fn standalone_web_search_marks_thread_memory_mode_polluted_when_configured() -> Result<()> {
skip_if_no_network!(Ok(()));
let server = start_mock_server().await;
Mock::given(method("POST"))
.and(path("/v1/alpha/search"))
.respond_with(ResponseTemplate::new(200).set_body_json(json!({
"output": "Search result",
})))
.expect(1)
.mount(&server)
.await;
mount_sse_sequence(
&server,
vec![
responses::sse(vec![
ev_response_created("resp-1"),
responses::ev_function_call_with_namespace(
"web-run-1",
"web",
"run",
&json!({
"search_query": [{"q": "standalone web search"}],
})
.to_string(),
),
ev_completed("resp-1"),
]),
responses::sse(vec![
responses::ev_assistant_message("msg-1", "done"),
ev_completed("resp-2"),
]),
],
)
.await;
let auth = CodexAuth::from_api_key("dummy");
let auth_manager = akode_core::test_support::auth_manager_from_auth(auth.clone());
let mut extension_builder = ExtensionRegistryBuilder::<Config>::new();
install_web_search_extension(&mut extension_builder, auth_manager);
let mut builder = test_codex()
.with_auth(auth)
.with_extensions(Arc::new(extension_builder.build()))
.with_config(|config| {
config
.features
.enable(Feature::Sqlite)
.expect("test config should allow feature update");
config
.features
.enable(Feature::StandaloneWebSearch)
.expect("standalone web search should be enabled");
config.memories.disable_on_external_context = true;
config
.web_search_mode
.set(WebSearchMode::Live)
.expect("web search mode should be accepted");
});
let test = builder.build(&server).await?;
let db = test.codex.state_db().expect("state db enabled");
let thread_id = test.session_configured.thread_id;
test.submit_turn("search the web").await?;
let mut memory_mode = None;
for _ in 0..100 {
memory_mode = db.get_thread_memory_mode(thread_id).await?;
if memory_mode.as_deref() == Some("polluted") {
break;
}
tokio::time::sleep(Duration::from_millis(25)).await;
}
assert_eq!(memory_mode.as_deref(), Some("polluted"));
Ok(())
}
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
async fn mcp_call_marks_thread_memory_mode_polluted_when_configured() -> Result<()> {
skip_if_no_network!(Ok(()));
let server = start_mock_server().await;
let call_id = "call-123";
let server_name = "rmcp";
let namespace = format!("mcp__{server_name}");
mount_sse_once(
&server,
responses::sse(vec![
ev_response_created("resp-1"),
responses::ev_function_call_with_namespace(
call_id,
&namespace,
"echo",
"{\"message\":\"ping\"}",
),
ev_completed("resp-1"),
]),
)
.await;
mount_sse_once(
&server,
responses::sse(vec![
responses::ev_assistant_message("msg-1", "rmcp echo tool completed."),
ev_completed("resp-2"),
]),
)
.await;
let rmcp_test_server_bin = stdio_server_bin()?;
let mut builder = test_codex().with_config(move |config| {
config
.features
.enable(Feature::Sqlite)
.expect("test config should allow feature update");
config.memories.disable_on_external_context = true;
let mut servers = config.mcp_servers.get().clone();
servers.insert(
server_name.to_string(),
McpServerConfig {
pollutes_memory: true,
project_header: None,
auth: Default::default(),
transport: McpServerTransportConfig::Stdio {
command: rmcp_test_server_bin,
args: Vec::new(),
env: Some(HashMap::from([(
"MCP_TEST_VALUE".to_string(),
"propagated-env".to_string(),
)])),
env_vars: Vec::new(),
cwd: None,
},
environment_id: "local".to_string(),
enabled: true,
required: false,
startup_readiness: Default::default(),
supports_parallel_tool_calls: false,
tool_input_schema_max_bytes: None,
omit_tools_from: None,
disabled_reason: None,
startup_timeout_sec: Some(Duration::from_secs(10)),
tool_timeout_sec: None,
default_tools_approval_mode: None,
enabled_tools: None,
disabled_tools: None,
scopes: None,
oauth: None,
oauth_resource: None,
tools: HashMap::new(),
},
);
config
.mcp_servers
.set(servers)
.expect("test mcp servers should accept any configuration");
});
let test = builder.build(&server).await?;
wait_for_mcp_server(&test.codex, server_name).await?;
let db = test.codex.state_db().expect("state db enabled");
let thread_id = test.session_configured.thread_id;
let cwd = test.config.cwd.clone();
let (sandbox_policy, permission_profile) =
turn_permission_fields(PermissionProfile::read_only(), cwd.as_path());
test.codex
.start_or_steer_turn(
TurnInputRequest::user_input(vec![UserInput::Text {
text: "call the rmcp echo tool".to_string(),
text_elements: Vec::new(),
}])
.with_thread_settings(ThreadSettingsOverrides {
environments: Some(local_requests(cwd)),
approval_policy: Some(AskForApproval::Never),
sandbox_policy: Some(sandbox_policy),
permission_profile,
collaboration_mode: Some(CollaborationMode {
mode: ModeKind::Default,
settings: Settings {
model: test.session_configured.model.clone(),
reasoning_effort: None,
developer_instructions: None,
},
}),
..Default::default()
}),
)
.await?;
wait_for_event(&test.codex, |event| {
matches!(event, EventMsg::McpToolCallEnd(_))
})
.await;
wait_for_event_match(&test.codex, |event| match event {
EventMsg::Error(err) => Some(Err(anyhow::anyhow!(err.message.clone()))),
EventMsg::TurnComplete(_) => Some(Ok(())),
_ => None,
})
.await?;
let mut memory_mode = None;
for _ in 0..100 {
memory_mode = db.get_thread_memory_mode(thread_id).await?;
if memory_mode.as_deref() == Some("polluted") {
break;
}
tokio::time::sleep(Duration::from_millis(25)).await;
}
assert_eq!(memory_mode.as_deref(), Some("polluted"));
Ok(())
}
#[tokio::test(flavor = "current_thread")]
async fn tool_call_logs_include_thread_id() -> Result<()> {
let server = start_mock_server().await;

View File

@@ -3341,7 +3341,6 @@ async fn skill_instructions_in_parent_and_spawned_child(include_instructions: bo
omit_descriptions: false,
max_context_tokens: config.skill_max_context_tokens,
bundled_skills_enabled: false,
shadow_selection_enabled: false,
});
let builder = test_codex()
.with_extensions(Arc::new(extensions.build()))

View File

@@ -1625,7 +1625,6 @@ async fn new_context_tool_skips_auto_compact_fallback() -> Result<()> {
omit_descriptions: false,
max_context_tokens: config.skill_max_context_tokens,
bundled_skills_enabled: config.bundled_skills_enabled(),
shadow_selection_enabled: config.features.enabled(Feature::SkillSearch),
});
let test = test_codex()
.with_extensions(Arc::new(extensions.build()))