← 返回
未分类

SQLite Memory 本地记忆

Lightweight local SQLite memory system for OpenClaw agents. Store and retrieve user preferences, decisions, project updates, and corrections without API costs. Use when (1) the user wants to persist memory across sessions without external APIs, (2) recording user preferences or corrections, (3) tracking project state and decisions, (4) searching past conversations for context. Alternative to graph-memory or vector-based systems — zero fees, zero configuration, pure local SQLite.
Lightweight local SQLite memory system for OpenClaw agents. Store and retrieve user preferences, decisions, project updates, and corrections without API costs. Use when (1) the user wants to persist memory across sessions without external APIs, (2) recording user preferences or corrections, (3) tracking project state and decisions, (4) searching past conversations for context. Alternative to graph-memory or vector-based systems — zero fees, zero configuration, pure local SQLite.
user_8c3b8185
未分类 community v1.0.0 1 版本 100000 Key: 无需
★ 0
Stars
📥 128
下载
💾 5
安装
1
版本
#latest

概述

SQLite Memory

Zero-cost local memory system using SQLite. No API keys, no cloud calls, no vector embeddings. Just fast, reliable local storage.

Quick Start

from sqlite_memory import store_preference, store_decision, search_memory, get_memory_stats

# Store a preference
store_preference("User dislikes overly apologetic language", importance=1.0)

# Store a project decision
store_decision("Using pygame.mouse for head motion simulation", importance=0.9)

# Search memories
results = search_memory("sensitivity")
# Returns: [{id, category, content, importance, created_at}, ...]

# Get stats
stats = get_memory_stats()
# Returns: {total_memories, categories, db_path}

When to Use

ScenarioFunction
--------------------
User corrects youstore_correction()
User expresses preferencestore_preference()
Important decision madestore_decision()
Project milestone reachedstore_project_update()
Need to recall past contextsearch_memory()

Memory Categories

  • preference — User likes/dislikes, style preferences (importance: 0.7-1.0)
  • decision — Technical choices, design decisions (importance: 0.8-0.9)
  • fact — General facts about user or project (importance: 0.5-0.7)
  • project — Project-specific updates, milestones (importance: 0.7-0.9)
  • correction — Explicit corrections from user (importance: 1.0)

API Reference

Storage Functions

store_preference(content: str, importance: float = 0.8) -> int
store_decision(content: str, context: dict = None, importance: float = 0.9) -> int
store_fact(content: str, importance: float = 0.6) -> int
store_project_update(project: str, content: str, importance: float = 0.7) -> int
store_correction(content: str, importance: float = 1.0) -> int

Retrieval Functions

search_memory(query: str, category: str = None, limit: int = 10) -> List[dict]
get_memory_stats() -> dict

Architecture

workspace/
└── memory.db              # SQLite database
    ├── memories           # Main memory table
    │   ├── id             # Auto-increment
    │   ├── category       # preference/decision/fact/project/correction
    │   ├── content        # The actual memory text
    │   ├── context        # Optional JSON metadata
    │   ├── importance     # 0.0-1.0, affects sort order
    │   ├── created_at     # Timestamp
    │   └── access_count   # Usage tracking
    └── sessions           # Session tracking (optional)

Comparison with Other Systems

Featuresqlite-memorygraph-memoryelite-longterm-memory
-----------------------------------------------------------
CostFreeAPI feesAPI fees (OpenAI)
SetupZero configNeeds API keysNeeds LanceDB + OpenAI
SpeedInstant (local)Network callsVector search
ComplexitySimpleComplex (graph + LLM)Complex (6 layers)
Best forQuick recall, preferencesDeep knowledge graphsEnterprise agents

Limitations

  • Text search only — No semantic/vector search (use graph-memory if needed)
  • Single user — No multi-user isolation
  • No auto-extraction — Must manually call store functions (unlike Mem0)

Migration Path

If you outgrow sqlite-memory:

  1. Need vector search? → graph-memory with Ollama (local embedding)
  2. Need auto-extraction? → Mem0 + OpenAI API
  3. Need cross-device sync? → elite-longterm-memory + SuperMemory cloud

Resources

  • scripts/sqlite_memory.py — Core memory module, import and use directly
  • references/usage.md — Detailed usage examples and patterns

版本历史

共 1 个版本

  • v1.0.0 Initial release 当前
    2026-04-23 23:20 安全 安全

安全检测

腾讯云安全 (Keen)

安全,无风险
查看报告

腾讯云安全 (Sanbu)

安全,无风险
查看报告

🔗 相关推荐

ai-agent

Agent Browser

rez0
用于 AI 代理的浏览器自动化 CLI。当用户需要与网站交互(包括浏览页面、填写表单、点击按钮、截图等)时使用。
★ 850 📥 330,120
ai-agent

Skill Vetter

spclaudehome
AI智能体技能安全预审工具。安装ClawdHub、GitHub等来源技能前,检查风险信号、权限范围及可疑模式。
★ 1,244 📥 271,895
ai-agent

Self-Improving + Proactive Agent

ivangdavila
自我反思+自我批评+自我学习+自组织记忆。智能体评估自身工作、发现错误并持续改进。
★ 1,421 📥 326,017