Auto-memory: call once on exit for --agent --chat, per-turn for single-shot

When running g3 --agent <name> --chat:
- Skip per-turn memory checkpoint calls (too onerous)
- Call memory checkpoint once when exiting (Ctrl-D)

When running g3 --agent <name> (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.
This commit is contained in:
Dhanji R. Prasanna
2026-01-16 13:35:40 +05:30
parent 6068249827
commit 2e6bef4b24

View File

@@ -213,8 +213,11 @@ pub async fn run_interactive<W: UiWriter>(
.await; .await;
// Send auto-memory reminder if enabled and tools were called // 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); debug!("Auto-memory reminder failed: {}", e);
}
} }
} else { } else {
// Single line input // Single line input
@@ -249,8 +252,11 @@ pub async fn run_interactive<W: UiWriter>(
.await; .await;
// Send auto-memory reminder if enabled and tools were called // 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); debug!("Auto-memory reminder failed: {}", e);
}
} }
} }
} }
@@ -285,6 +291,14 @@ pub async fn run_interactive<W: UiWriter>(
// Save session continuation for resume capability // Save session continuation for resume capability
agent.save_session_continuation(None); 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!"); output.print("👋 Goodbye!");
Ok(()) Ok(())
} }