From 2e6bef4b2481cf2efc53a94e2a3abb6951819c2f Mon Sep 17 00:00:00 2001 From: "Dhanji R. Prasanna" Date: Fri, 16 Jan 2026 13:35:40 +0530 Subject: [PATCH] Auto-memory: call once on exit for --agent --chat, per-turn for single-shot When running g3 --agent --chat: - Skip per-turn memory checkpoint calls (too onerous) - Call memory checkpoint once when exiting (Ctrl-D) When running g3 --agent (single-shot): - Preserve existing behavior: call memory checkpoint after each turn This keeps the auto-memory feature useful without being intrusive in interactive agent sessions. --- crates/g3-cli/src/interactive.rs | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/crates/g3-cli/src/interactive.rs b/crates/g3-cli/src/interactive.rs index f6b7e44..594511a 100644 --- a/crates/g3-cli/src/interactive.rs +++ b/crates/g3-cli/src/interactive.rs @@ -213,8 +213,11 @@ pub async fn run_interactive( .await; // Send auto-memory reminder if enabled and tools were called - if let Err(e) = agent.send_auto_memory_reminder().await { + // Skip per-turn reminders when from_agent_mode - we'll send once on exit + if !from_agent_mode { + if let Err(e) = agent.send_auto_memory_reminder().await { debug!("Auto-memory reminder failed: {}", e); + } } } else { // Single line input @@ -249,8 +252,11 @@ pub async fn run_interactive( .await; // Send auto-memory reminder if enabled and tools were called - if let Err(e) = agent.send_auto_memory_reminder().await { + // Skip per-turn reminders when from_agent_mode - we'll send once on exit + if !from_agent_mode { + if let Err(e) = agent.send_auto_memory_reminder().await { debug!("Auto-memory reminder failed: {}", e); + } } } } @@ -285,6 +291,14 @@ pub async fn run_interactive( // Save session continuation for resume capability agent.save_session_continuation(None); + // Send auto-memory reminder once on exit when in agent+chat mode + // (Per-turn reminders were skipped to avoid being too onerous) + if from_agent_mode { + if let Err(e) = agent.send_auto_memory_reminder().await { + debug!("Auto-memory reminder on exit failed: {}", e); + } + } + output.print("👋 Goodbye!"); Ok(()) }