From d31fa168eb23bebedc1b5c3d67e0d34e40809132 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Atahan=20Y=C4=B1ld=C4=B1r=C4=B1m?= <111663792+atahanyild@users.noreply.github.com> Date: Mon, 8 Jun 2026 18:54:24 +0300 Subject: [PATCH] mem0-plugin hooks: honor auto_save=false in capture entry points (#5450) --- mem0-plugin/scripts/on_session_start.sh | 4 +++- mem0-plugin/scripts/on_stop.sh | 5 +++++ mem0-plugin/scripts/on_user_prompt.sh | 2 +- 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/mem0-plugin/scripts/on_session_start.sh b/mem0-plugin/scripts/on_session_start.sh index b5732002c..649d89f5d 100755 --- a/mem0-plugin/scripts/on_session_start.sh +++ b/mem0-plugin/scripts/on_session_start.sh @@ -189,7 +189,9 @@ elif [ "$SOURCE" = "resume" ]; then elif [ "$SOURCE" = "compact" ]; then echo "Context compacted. Search mem0 for session_state and decision memories to recover context. Run 2 parallel searches." - printf '%s' "$INPUT" | python3 "$SCRIPT_DIR/capture_compact_summary.py" 2>/dev/null & + if [ "${MEM0_AUTO_SAVE:-true}" != "false" ]; then + printf '%s' "$INPUT" | python3 "$SCRIPT_DIR/capture_compact_summary.py" 2>/dev/null & + fi fi python3 "$SCRIPT_DIR/telemetry.py" session_start --source="$SOURCE" --memory_count="${MEM0_COUNT:-0}" 2>/dev/null & diff --git a/mem0-plugin/scripts/on_stop.sh b/mem0-plugin/scripts/on_stop.sh index dce5e82f1..636270816 100755 --- a/mem0-plugin/scripts/on_stop.sh +++ b/mem0-plugin/scripts/on_stop.sh @@ -32,6 +32,11 @@ fi SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)" . "$SCRIPT_DIR/_identity.sh" 2>/dev/null || true +# Honor auto_save=false in ~/.mem0/settings.json +if [ "${MEM0_AUTO_SAVE:-true}" = "false" ]; then + exit 0 +fi + if [ -z "${MEM0_API_KEY:-}" ]; then exit 0 fi diff --git a/mem0-plugin/scripts/on_user_prompt.sh b/mem0-plugin/scripts/on_user_prompt.sh index 97f2bad9f..a65af96c4 100755 --- a/mem0-plugin/scripts/on_user_prompt.sh +++ b/mem0-plugin/scripts/on_user_prompt.sh @@ -174,7 +174,7 @@ fi # overlapping window ensures the next batch (MSG_COUNT=6) picks up the # exchange that was incomplete in the previous batch. TRANSCRIPT_PATH=$(echo "$INPUT" | jq -r '.transcript_path // ""' 2>/dev/null || echo "") -if [ $((MSG_COUNT % 3)) -eq 0 ] && [ "$MSG_COUNT" -gt 0 ] && [ -n "$TRANSCRIPT_PATH" ]; then +if [ "${MEM0_AUTO_SAVE:-true}" != "false" ] && [ $((MSG_COUNT % 3)) -eq 0 ] && [ "$MSG_COUNT" -gt 0 ] && [ -n "$TRANSCRIPT_PATH" ]; then python3 "$SCRIPT_DIR/auto_capture.py" "$TRANSCRIPT_PATH" 2>/dev/null & fi