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:
parent
655303f2f1
commit
440c244cac
19 changed files with 2397 additions and 327 deletions
30
README.md
30
README.md
|
|
@ -154,7 +154,35 @@ hermes --toolsets "web,terminal"
|
|||
hermes --list-tools
|
||||
```
|
||||
|
||||
**Available toolsets:** `web`, `terminal`, `file`, `browser`, `vision`, `image_gen`, `moa`, `skills`, `tts`, `todo`, `cronjob`, and more.
|
||||
**Available toolsets:** `web`, `terminal`, `file`, `browser`, `vision`, `image_gen`, `moa`, `skills`, `tts`, `todo`, `memory`, `session_search`, `cronjob`, and more.
|
||||
|
||||
### 🧠 Persistent Memory
|
||||
|
||||
Bounded curated memory that persists across sessions:
|
||||
|
||||
- **MEMORY.md** — agent's personal notes (environment facts, conventions, things learned). ~800 token budget.
|
||||
- **USER.md** — user profile (preferences, communication style, expectations). ~500 token budget.
|
||||
|
||||
Both are injected into the system prompt as a frozen snapshot at session start. The agent manages its own memory via the `memory` tool (add/replace/remove/read). Character limits keep memory focused — when full, the agent consolidates or replaces entries.
|
||||
|
||||
Configure in `~/.hermes/config.yaml`:
|
||||
```yaml
|
||||
memory:
|
||||
memory_enabled: true
|
||||
user_profile_enabled: true
|
||||
memory_char_limit: 2200 # ~800 tokens
|
||||
user_char_limit: 1375 # ~500 tokens
|
||||
```
|
||||
|
||||
### 🗄️ Session Store
|
||||
|
||||
All CLI and messaging sessions are stored in a SQLite database (`~/.hermes/state.db`) with full-text search:
|
||||
|
||||
- **Full message history** stored per-session with model config and system prompt snapshots
|
||||
- **FTS5 search** via the `session_search` tool -- search past conversations with Gemini Flash summarization
|
||||
- **Compression-triggered session splitting** -- when context is compressed, a new session is created linked to the parent, giving clean trajectories
|
||||
- **Source tagging** -- each session is tagged with its origin (cli, telegram, discord, etc.)
|
||||
- Batch runner and RL trajectories are NOT stored here (separate systems)
|
||||
|
||||
### 🔊 Text-to-Speech
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue