1
0

Add Tier 3: Semantic Memory (vector search)

Completes the three-tier memory architecture:

## Tier 3 — Semantic Search
- Vector embeddings over all vault files
- Similarity-based retrieval
- memory_search tool for agents
- Fallback to hash-based embeddings if transformers unavailable

## Implementation
- src/timmy/semantic_memory.py — Core semantic memory
- Chunking strategy: paragraphs → sentences
- SQLite storage for vectors
- cosine_similarity for ranking

## Integration
- Added memory_search to create_full_toolkit()
- Updated prompts with memory_search examples
- Tool triggers: past conversations, reminders

## Features
- Automatic vault indexing
- Source file tracking (re-indexes on change)
- Similarity scoring
- Context retrieval for queries

## Usage

All 973 tests pass.
This commit is contained in:
Alexander Payne
2026-02-25 18:25:20 -05:00
parent 7838df19b0
commit 16b65b28e8
3 changed files with 396 additions and 94 deletions

View File

@@ -253,7 +253,8 @@ def create_devops_tools(base_dir: str | Path | None = None):
def create_full_toolkit(base_dir: str | Path | None = None):
"""Create a full toolkit with all available tools (for Timmy).
Includes: web search, file read/write, shell commands, python execution
Includes: web search, file read/write, shell commands, python execution,
and memory search for contextual recall.
"""
if not _AGNO_TOOLS_AVAILABLE:
# Return None when tools aren't available (tests)
@@ -279,6 +280,13 @@ def create_full_toolkit(base_dir: str | Path | None = None):
toolkit.register(file_tools.save_file, name="write_file")
toolkit.register(file_tools.list_files, name="list_files")
# Memory search - semantic recall
try:
from timmy.semantic_memory import memory_search
toolkit.register(memory_search, name="memory_search")
except Exception:
logger.debug("Memory search not available")
return toolkit