Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion src/cron/scheduler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,8 @@ async fn run_agent_job(
let prompt = job.prompt.clone().unwrap_or_default();

// Recall relevant memories so cron jobs have context awareness.
// Exclude `Conversation` memories to prevent chat context from
// leaking into scheduled executions (see #5415).
let memory_context = match crate::memory::create_memory(
&config.memory,
&config.workspace_dir,
Expand All @@ -289,10 +291,20 @@ async fn run_agent_job(
Ok(entries) if !entries.is_empty() => {
let ctx: String = entries
.iter()
.filter(|e| {
!matches!(
e.category,
crate::memory::traits::MemoryCategory::Conversation
)
})
.map(|e| format!("- {}: {}", e.key, e.content))
.collect::<Vec<_>>()
.join("\n");
format!("[Memory context]\n{ctx}\n\n")
if ctx.is_empty() {
String::new()
} else {
format!("[Memory context]\n{ctx}\n\n")
}
}
_ => String::new(),
},
Expand Down
14 changes: 13 additions & 1 deletion src/daemon/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -434,15 +434,27 @@ async fn run_heartbeat_worker(config: Config) -> Result<()> {
let task_prompt = format!("[Heartbeat Task | {}] {}", task.priority, task.text);

// Recall relevant memories so heartbeat tasks have context awareness.
// Exclude `Conversation` memories to prevent chat context from
// leaking into scheduled executions (see #5415).
let memory_context = if let Some(ref mem) = heartbeat_memory {
match mem.recall(&task.text, 5, None, None, None).await {
Ok(entries) if !entries.is_empty() => {
let ctx: String = entries
.iter()
.filter(|e| {
!matches!(
e.category,
crate::memory::traits::MemoryCategory::Conversation
)
})
.map(|e| format!("- {}: {}", e.key, e.content))
.collect::<Vec<_>>()
.join("\n");
Some(format!("[Memory context]\n{ctx}\n"))
if ctx.is_empty() {
None
} else {
Some(format!("[Memory context]\n{ctx}\n"))
}
}
_ => None,
}
Expand Down
Loading