mirror of
https://github.com/openai/codex.git
synced 2026-10-28 18:58:46 +00:00
Avoid phase2 agent for empty memory housekeeping
This commit is contained in:
@@ -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_git_utils::GitBaselineChangeStatus;
|
||||
use codex_protocol::ThreadId;
|
||||
use codex_protocol::protocol::AgentStatus;
|
||||
use codex_protocol::protocol::AskForApproval;
|
||||
@@ -152,6 +153,43 @@ pub async fn run(context: Arc<MemoryStartupContext>, config: Arc<Config>) {
|
||||
.await;
|
||||
return;
|
||||
}
|
||||
let rollout_summaries_prefix = format!("{}/", crate::artifacts::ROLLOUT_SUMMARIES_SUBDIR);
|
||||
let extensions_prefix = format!("{}/", crate::artifacts::EXTENSIONS_SUBDIR);
|
||||
if raw_memories.is_empty()
|
||||
&& workspace_diff.changes.iter().all(|change| {
|
||||
change.path == crate::artifacts::RAW_MEMORIES_FILENAME
|
||||
|| change.path.starts_with(&rollout_summaries_prefix)
|
||||
|| (change.status == GitBaselineChangeStatus::Deleted
|
||||
&& change.path.starts_with(&extensions_prefix))
|
||||
})
|
||||
{
|
||||
match reset_memory_workspace_baseline(&root).await {
|
||||
Ok(()) => {
|
||||
job::succeed(
|
||||
context.as_ref(),
|
||||
db.as_ref(),
|
||||
&claim,
|
||||
new_watermark,
|
||||
&raw_memories,
|
||||
"succeeded_empty_input_housekeeping",
|
||||
)
|
||||
.await;
|
||||
}
|
||||
Err(err) => {
|
||||
tracing::error!(
|
||||
"failed resetting memory workspace baseline after empty phase-2 housekeeping: {err}"
|
||||
);
|
||||
job::failed(
|
||||
context.as_ref(),
|
||||
db.as_ref(),
|
||||
&claim,
|
||||
"failed_workspace_commit",
|
||||
)
|
||||
.await;
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
// 7. Persist the diff for the consolidation agent to inspect.
|
||||
if let Err(err) = write_workspace_diff(&root, &workspace_diff).await {
|
||||
|
||||
@@ -221,15 +221,9 @@ async fn memories_startup_phase2_prunes_old_extension_resources_without_stage1_i
|
||||
let test = build_test_codex(&server, home.clone()).await?;
|
||||
trigger_memories_startup(&test).await;
|
||||
|
||||
let request = wait_for_single_request(&phase2).await;
|
||||
let prompt = phase2_prompt_text(&request);
|
||||
assert!(
|
||||
prompt.contains("phase2_workspace_diff.md"),
|
||||
"expected workspace diff file in prompt: {prompt}"
|
||||
);
|
||||
|
||||
wait_for_file_removed(&old_file).await?;
|
||||
wait_for_phase2_workspace_reset(&home.path().join("memories")).await?;
|
||||
assert_eq!(phase2.requests().len(), 0);
|
||||
|
||||
shutdown_test_codex(&test).await?;
|
||||
Ok(())
|
||||
|
||||
Reference in New Issue
Block a user