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:
@@ -213,9 +213,12 @@ 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
|
||||||
|
// 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 {
|
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
|
||||||
let input = line.trim().to_string();
|
let input = line.trim().to_string();
|
||||||
@@ -249,11 +252,14 @@ 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
|
||||||
|
// 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 {
|
if let Err(e) = agent.send_auto_memory_reminder().await {
|
||||||
debug!("Auto-memory reminder failed: {}", e);
|
debug!("Auto-memory reminder failed: {}", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
Err(ReadlineError::Interrupted) => {
|
Err(ReadlineError::Interrupted) => {
|
||||||
// Ctrl-C pressed
|
// Ctrl-C pressed
|
||||||
if in_multiline {
|
if in_multiline {
|
||||||
@@ -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(())
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user