mirror of
https://github.com/openai/codex.git
synced 2026-11-27 23:50:52 +00:00
Rebind memory consolidation workspace roots (#32197)
## Why The memory consolidation agent changes its working directory to the memory root, but applying its sandbox policy directly to the permissions object can leave workspace roots inherited from the parent configuration. ## What changed Apply the consolidation sandbox policy through `Config` so its workspace roots are synchronized with the memory root. Add a test covering the working directory, workspace roots, and effective legacy sandbox policy. GitOrigin-RevId: dc6e75aef1ffa84a2f66fec6ed3a6fedcf9aa672
This commit is contained in:
@@ -332,8 +332,7 @@ mod agent {
|
||||
exclude_slash_tmp: true,
|
||||
};
|
||||
agent_config
|
||||
.permissions
|
||||
.set_legacy_sandbox_policy(consolidation_sandbox_policy, agent_config.cwd.as_path())
|
||||
.set_legacy_sandbox_policy(consolidation_sandbox_policy)
|
||||
.ok()?;
|
||||
|
||||
agent_config.model = Some(
|
||||
@@ -534,6 +533,10 @@ mod agent {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
#[path = "phase2_workspace_roots_tests.rs"]
|
||||
mod workspace_roots_tests;
|
||||
|
||||
pub(super) fn get_watermark(
|
||||
claimed_watermark: i64,
|
||||
latest_memories: &[codex_state::Stage1Output],
|
||||
|
||||
@@ -0,0 +1,42 @@
|
||||
use super::agent;
|
||||
use crate::memory_root;
|
||||
use codex_model_provider::create_model_provider;
|
||||
use codex_protocol::protocol::SandboxPolicy;
|
||||
use core_test_support::responses::start_mock_server;
|
||||
use core_test_support::test_codex::test_codex;
|
||||
use pretty_assertions::assert_eq;
|
||||
use std::sync::Arc;
|
||||
use tempfile::TempDir;
|
||||
|
||||
#[tokio::test]
|
||||
async fn consolidation_rebinds_workspace_roots_to_memory_root() -> anyhow::Result<()> {
|
||||
let server = start_mock_server().await;
|
||||
let home = Arc::new(TempDir::new()?);
|
||||
let test = test_codex()
|
||||
.with_home(home)
|
||||
.build_with_auto_env(&server)
|
||||
.await?;
|
||||
let provider = create_model_provider(
|
||||
test.config.model_provider.clone(),
|
||||
Some(test.thread_manager.auth_manager()),
|
||||
);
|
||||
|
||||
let agent_config =
|
||||
agent::get_config(&test.config, provider.as_ref()).expect("agent config should be created");
|
||||
let root = memory_root(&test.config.codex_home);
|
||||
|
||||
assert_eq!(agent_config.cwd, root);
|
||||
assert_eq!(agent_config.workspace_roots, vec![root]);
|
||||
assert_eq!(
|
||||
agent_config.legacy_sandbox_policy(),
|
||||
SandboxPolicy::WorkspaceWrite {
|
||||
writable_roots: Vec::new(),
|
||||
network_access: false,
|
||||
exclude_tmpdir_env_var: true,
|
||||
exclude_slash_tmp: true,
|
||||
}
|
||||
);
|
||||
|
||||
test.codex.shutdown_and_wait().await?;
|
||||
Ok(())
|
||||
}
|
||||
Reference in New Issue
Block a user