feat(memory): implement FactStore SQLite persistence
Add `facts` table to schema with columns for id, agent_id, content, category, confidence, source_session, and created_at. Implement store_facts() and get_top_facts() on MemoryStore using upsert-by-id and confidence-desc ordering. Facts extracted from conversations are now durable across sessions. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -71,4 +71,19 @@ CREATE INDEX IF NOT EXISTS idx_kv_agent ON kv_store(agent_id);
|
||||
CREATE INDEX IF NOT EXISTS idx_hand_runs_hand ON hand_runs(hand_name);
|
||||
CREATE INDEX IF NOT EXISTS idx_hand_runs_status ON hand_runs(status);
|
||||
CREATE INDEX IF NOT EXISTS idx_hand_runs_created ON hand_runs(created_at);
|
||||
|
||||
-- Structured facts table (extracted from conversations)
|
||||
CREATE TABLE IF NOT EXISTS facts (
|
||||
id TEXT PRIMARY KEY,
|
||||
agent_id TEXT NOT NULL,
|
||||
content TEXT NOT NULL,
|
||||
category TEXT NOT NULL,
|
||||
confidence REAL NOT NULL,
|
||||
source_session TEXT,
|
||||
created_at INTEGER NOT NULL,
|
||||
FOREIGN KEY (agent_id) REFERENCES agents(id) ON DELETE CASCADE
|
||||
);
|
||||
CREATE INDEX IF NOT EXISTS idx_facts_agent ON facts(agent_id);
|
||||
CREATE INDEX IF NOT EXISTS idx_facts_category ON facts(agent_id, category);
|
||||
CREATE INDEX IF NOT EXISTS idx_facts_confidence ON facts(agent_id, confidence DESC);
|
||||
"#;
|
||||
|
||||
Reference in New Issue
Block a user