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,9 +213,12 @@ pub async fn run_interactive<W: UiWriter>(
.await;
// Send auto-memory reminder if enabled and tools were called
// 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
let input = line.trim().to_string();
@@ -249,11 +252,14 @@ pub async fn run_interactive<W: UiWriter>(
.await;
// Send auto-memory reminder if enabled and tools were called
// 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);
}
}
}
}
Err(ReadlineError::Interrupted) => {
// Ctrl-C pressed
if in_multiline {
@@ -285,6 +291,14 @@ pub async fn run_interactive<W: UiWriter>(
// 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(())
}