feat: add persistent memory system + SQLite session store

Two-part implementation:

Part A - Curated Bounded Memory:
- New memory tool (tools/memory_tool.py) with MEMORY.md + USER.md stores
- Character-limited (2200/1375 chars), § delimited entries
- Frozen snapshot injected into system prompt at session start
- Model manages pruning via replace/remove with substring matching
- Usage indicator shown in system prompt header

Part B - SQLite Session Store:
- New hermes_state.py with SessionDB class, FTS5 full-text search
- Gateway session.py rewritten to dual-write SQLite + legacy JSONL
- Compression-triggered session splitting with parent_session_id chains
- New session_search tool with Gemini Flash summarization of matched sessions
- CLI session lifecycle (create on launch, close on exit)

Also:
- System prompt now cached per session, only rebuilt on compression
  (fixes prefix cache invalidation from date/time changes every turn)
- Config version bumped to 3, hermes doctor checks for new artifacts
- Disabled in batch_runner and RL environments
This commit is contained in:
teknium1 2026-02-19 00:57:31 -08:00
parent 655303f2f1
commit 440c244cac
19 changed files with 2397 additions and 327 deletions

View file

@ -120,6 +120,19 @@ TOOLSETS = {
"includes": []
},
"memory": {
"description": "Persistent memory across sessions (personal notes + user profile)",
"tools": ["memory"],
"includes": []
},
"session_search": {
"description": "Search and recall past conversations with summarization",
"tools": ["session_search"],
"includes": []
},
# Scenario-specific toolsets
"debugging": {
@ -164,6 +177,10 @@ TOOLSETS = {
"text_to_speech",
# Planning & task management
"todo",
# Persistent memory
"memory",
# Session history search
"session_search",
# Cronjob management (CLI-only)
"schedule_cronjob", "list_cronjobs", "remove_cronjob"
],
@ -198,6 +215,10 @@ TOOLSETS = {
"skills_list", "skill_view",
# Planning & task management
"todo",
# Persistent memory
"memory",
# Session history search
"session_search",
# Cronjob management - let users schedule tasks
"schedule_cronjob", "list_cronjobs", "remove_cronjob",
# Cross-channel messaging
@ -230,6 +251,10 @@ TOOLSETS = {
"skills_list", "skill_view",
# Planning & task management
"todo",
# Persistent memory
"memory",
# Session history search
"session_search",
# Cronjob management - let users schedule tasks
"schedule_cronjob", "list_cronjobs", "remove_cronjob",
# Cross-channel messaging
@ -262,6 +287,10 @@ TOOLSETS = {
"skills_list", "skill_view",
# Planning & task management
"todo",
# Persistent memory
"memory",
# Session history search
"session_search",
# Cronjob management
"schedule_cronjob", "list_cronjobs", "remove_cronjob",
# Cross-channel messaging
@ -294,6 +323,10 @@ TOOLSETS = {
"skills_list", "skill_view",
# Planning & task management
"todo",
# Persistent memory
"memory",
# Session history search
"session_search",
# Cronjob management - let users schedule tasks
"schedule_cronjob", "list_cronjobs", "remove_cronjob",
# Cross-channel messaging