Skip to content

feat(memory,core): session summary on shutdown (#1816)#1833

Merged
bug-ops merged 4 commits intomainfrom
feat/issue-1816/session-summary-on-shutdown
Mar 15, 2026
Merged

feat(memory,core): session summary on shutdown (#1816)#1833
bug-ops merged 4 commits intomainfrom
feat/issue-1816/session-summary-on-shutdown

Conversation

@bug-ops
Copy link
Copy Markdown
Owner

@bug-ops bug-ops commented Mar 15, 2026

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 nullable first_message_id/last_message_id (migration 034), then calls store_session_summary() to embed into SESSION_SUMMARIES_COLLECTION so search_session_summaries() can find it; key facts stored with real FK-linked summary ID
  • LLM call wrapped in 5-second timeout; structured output with plain-text fallback; all errors swallowed — shutdown never fails
  • User-turn count guard (Role::User only) prevents trivial sessions from triggering LLM calls
  • New config: memory.shutdown_summary (default true), memory.shutdown_summary_min_messages (default 4), memory.shutdown_summary_max_messages (default 20)
  • --init wizard prompts for the feature toggle; TUI shows Saving session summary... status during shutdown
  • 10 new unit tests covering all guard conditions and the memory layer

Changes

  • crates/zeph-memory/migrations/034_summaries_nullable_message_ids.sql — makes summaries.first_message_id/last_message_id nullable (CREATE+INSERT+DROP+RENAME pattern for SQLite)
  • crates/zeph-memory/src/semantic/cross_session.rshas_session_summary(), store_shutdown_summary()
  • crates/zeph-memory/src/sqlite/summaries.rssave_summary() accepts Option<MessageId> for FK fields
  • crates/zeph-core/src/agent/mod.rsmaybe_store_shutdown_summary(), call_llm_for_session_summary()
  • crates/zeph-core/src/config/types/memory.rs — three new MemoryConfig fields
  • src/init.rs, src/runner.rs — wizard integration, builder wiring
  • docs/src/concepts/memory.md — new section on shutdown summaries
  • CHANGELOG.md[Unreleased] entry

Test plan

  • cargo +nightly fmt --check passes
  • cargo clippy --workspace --features full -- -D warnings passes (zero warnings)
  • cargo nextest run --config-file .github/nextest.toml --workspace --features full --lib --bins — 5800 passed, 12 skipped
  • Integration test (manual): run agent with --config .local/config/testing.toml, send 4+ messages, send SIGINT, verify shutdown summary appears in memory_search results in subsequent session

bug-ops added 2 commits March 15, 2026 16:09
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
@github-actions github-actions bot added documentation Improvements or additions to documentation memory zeph-memory crate (SQLite) rust Rust code changes core zeph-core crate config Configuration file changes enhancement New feature or request size/XL Extra large PR (500+ lines) labels Mar 15, 2026
@bug-ops bug-ops enabled auto-merge (squash) March 15, 2026 15:11
@bug-ops bug-ops merged commit c9c528b into main Mar 15, 2026
19 checks passed
@bug-ops bug-ops deleted the feat/issue-1816/session-summary-on-shutdown branch March 15, 2026 15:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

config Configuration file changes core zeph-core crate documentation Improvements or additions to documentation enhancement New feature or request memory zeph-memory crate (SQLite) rust Rust code changes size/XL Extra large PR (500+ lines)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat(memory): store session summary on shutdown for short sessions without compaction

1 participant