feat(memory,core): session summary on shutdown (#1816)#1833
Merged
Conversation
When no hard compaction fired during a session, Agent::shutdown() now generates a lightweight LLM summary and stores it to the vector store for cross-session recall. - SemanticMemory::has_session_summary() checks SQLite as the primary guard (resilient to failed Qdrant writes) - SemanticMemory::store_shutdown_summary() persists to SQLite and SESSION_SUMMARIES_COLLECTION via store_session_summary() so search_session_summaries() can find it; key facts stored with real FK-linked summary_id - Migration 034 makes summaries.first_message_id / last_message_id nullable: NULL = session-level summary without specific message range - LLM call wrapped in 5-second timeout (structured + plain fallback); all errors swallowed so shutdown never fails - New MemoryConfig fields: shutdown_summary (default true), shutdown_summary_min_messages (default 4, user turns only), shutdown_summary_max_messages (default 20) - --init wizard prompts for the feature toggle - TUI status indicator shown during summarization - 10 new unit tests covering guards and memory layer methods
…on-summary-on-shutdown
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
When no hard compaction fired during a session,
Agent::shutdown()now generates a lightweight LLM summary and stores it to the vector store for cross-session recall. Short or interrupted sessions that never triggered chunked compaction were previously invisible to cross-session memory retrieval.SemanticMemory::has_session_summary()— SQLite-based primary guard (resilient to failed Qdrant writes)SemanticMemory::store_shutdown_summary()— persists to SQLite with nullablefirst_message_id/last_message_id(migration 034), then callsstore_session_summary()to embed intoSESSION_SUMMARIES_COLLECTIONsosearch_session_summaries()can find it; key facts stored with real FK-linked summary IDmemory.shutdown_summary(defaulttrue),memory.shutdown_summary_min_messages(default4),memory.shutdown_summary_max_messages(default20)--initwizard prompts for the feature toggle; TUI showsSaving session summary...status during shutdownChanges
crates/zeph-memory/migrations/034_summaries_nullable_message_ids.sql— makessummaries.first_message_id/last_message_idnullable (CREATE+INSERT+DROP+RENAME pattern for SQLite)crates/zeph-memory/src/semantic/cross_session.rs—has_session_summary(),store_shutdown_summary()crates/zeph-memory/src/sqlite/summaries.rs—save_summary()acceptsOption<MessageId>for FK fieldscrates/zeph-core/src/agent/mod.rs—maybe_store_shutdown_summary(),call_llm_for_session_summary()crates/zeph-core/src/config/types/memory.rs— three newMemoryConfigfieldssrc/init.rs,src/runner.rs— wizard integration, builder wiringdocs/src/concepts/memory.md— new section on shutdown summariesCHANGELOG.md—[Unreleased]entryTest plan
cargo +nightly fmt --checkpassescargo clippy --workspace --features full -- -D warningspasses (zero warnings)cargo nextest run --config-file .github/nextest.toml --workspace --features full --lib --bins— 5800 passed, 12 skipped--config .local/config/testing.toml, send 4+ messages, send SIGINT, verify shutdown summary appears inmemory_searchresults in subsequent session