Conquer your AI with personality, not a rulebook. ไปฅๅพทๆ AIใ
An engram is the trace a memory leaves in the brain. This project does the same for AI โ memory that persists across sessions, stays organized, and cleans up after itself.
English
You've had this experience: you spend 20 minutes explaining your project setup, coding style, or preferences to an AI assistant. It does exactly what you want. Next morning, new session โ it knows nothing. You start over.
So you try the workaround: write it all down in a markdown file. .cursor/rules, AGENTS.md, a system prompt doc โ whatever your tool calls it. It works at first. But then:
- The file keeps growing. Every time the AI gets something wrong, you add another rule.
- Old instructions conflict with new ones, and you have to go back and reconcile.
- You realize you're spending more time maintaining the AI's memory than doing actual work.
- You have multiple projects, multiple agents โ and now multiple files to keep in sync.
You've become a full-time memory manager for your AI. That's backwards.
The deeper problem isn't just "AI forgets." It's that the burden of remembering falls entirely on you. You're manually doing what memory should do automatically: deciding what matters, updating when things change, and throwing out what's stale.
Engram flips this. Instead of you maintaining files for the AI, the AI maintains its own memory โ structured, scoped, and self-cleaning. It decides what to keep, compresses old information, and forgets what's no longer relevant. You just use it.
Today: You write rules.md โ AI reads it โ you update rules.md โ repeat forever
Engram: AI remembers on its own โ compresses over time โ you never maintain a file again
You don't manually save bookmarks for every webpage you visit. Your brain decides what's worth remembering. Engram works the same way โ the AI decides what to store, when to recall, and what to ignore. You just use it naturally; memory happens in the background.
Returning 50 old memories into every conversation doesn't help โ it wastes tokens and confuses the model. Engram keeps memory lean: duplicates are merged, old logs get summarized into compact knowledge, and stale entries fade away automatically. The result is a small, high-quality set of memories that actually improve responses.
Not all memories are equal. Your preferences ("always use TypeScript"), lessons learned ("that API has a 5-second timeout"), and key decisions ("we're using PostgreSQL") should never be forgotten. But yesterday's deployment log? That can fade โ after being distilled into lasting knowledge first.
Engram exposes 5 tools via the MCP protocol. Any MCP-compatible client (Cursor, Claude Desktop, custom agents) can call them:
| Parameter | Type | Required | Description |
|---|---|---|---|
content |
string | yes | The memory text |
scope |
string | yes | global, group:xxx, dm, agent:xxx |
mem_type |
string | no | preference, fact, procedure, lesson, decision, task_log, knowledge |
source |
string | no | user_direct, agent_output, tool_result, inferred (default: agent_output) |
trust |
string | no | high, medium, low (default: medium) |
context |
string | no | Additional context for retrieval |
agent |
string | no | Caller identity for permission check |
Returns: {"results": [...]} on success, {"queued": true, "write_id": "..."} if Mem0 is down (auto-replayed later), {"error": "..."} on permission/safety violation.
Guards: permission check โ never_store regex โ scope validation โ write (or queue).
| Parameter | Type | Required | Description |
|---|---|---|---|
query |
string | yes | Natural language search query |
scope |
string | no | Target scope (default: global). Use cross:group_id for cross-scope |
mem_type |
string | no | Filter by memory type |
trust_min |
string | no | Minimum trust level: high, medium, low |
limit |
int | no | Max results (default: 5) |
agent |
string | no | Caller identity |
How dual-query works: When scope is group:xxx, Engram runs two parallel searches (group + global), then interleaves results by relevance. You always get the best of both local and global context in one call.
Returns: Array of memory objects with content, metadata (scope, trust, mem_type, source, agent, access_count), sorted by relevance then trust.
| Parameter | Type | Required | Description |
|---|---|---|---|
user_id |
string | no | User filter (default: default) |
scope |
string | no | Scope filter |
agent |
string | no | Caller identity |
Returns: {"total": N, "results": [...]} โ all active (non-archived) memories matching the filter.
| Parameter | Type | Required | Description |
|---|---|---|---|
agent |
string | no | Caller identity |
Returns: Full system health including:
mem0_ready/qdrant_readyโ backend statustotal_memories/active_memories/archived_memoriesby_scopeโ count per scopeby_typeโ count per memory typeby_trustโ count per trust levelwrite_queue_sizeโ pending offline writesembedding_model/config_version/schema_version
| Parameter | Type | Required | Description |
|---|---|---|---|
mode |
string | no | report_only (default: daily). daily/weekly are placeholders โ run via CLI |
agent |
string | no | Caller identity (needs main/devops permission) |
Note: The MCP tool generates reports. Actual maintenance (Opus re-extraction, dedup, consolidation, decay) runs via python src/maintenance.py scheduled through cron.
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ L1: Agent Layer โ
โ โ
โ โโโโโโโโโโโโ โโโโโโโโโโโโ โโโโโโโโโโโโ โโโโโโโโโโโโ โ
โ โ Main โ โ Worker โ โ Worker โ โ DevOps โ โ
โ โ Agent โ โ Agent A โ โ Agent B โ โ Agent โ โ
โ โ โ โ โ โ โ โ โ โ
โ โ r: all โ โ r: โ โ โ r: โ โ โ r: all โ โ
โ โ w: globalโ โ w: self โ โ w: self โ โ w: all โ โ
โ โ group โ โ โ โ โ โ โ โ
โ โ dm โ โ โ โ โ โ โ โ
โ โโโโโโฌโโโโโโ โโโโโโฌโโโโโโ โโโโโโฌโโโโโโ โโโโโโฌโโโโโโ โ
โ โ โ โ โ โ
โโโโโโโโโผโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโ
โ โ โ โ
โโโโโโโโโโโโโโโโดโโโโโโโฌโโโโโโโโดโโโโโโโโโโโโโโโ
โ MCP (stdio)
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ L2: Engram MCP Server โผ โ
โ โ
โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ
โ โ 5 MCP Tools โ โ
โ โ mem0_add ยท mem0_search ยท mem0_get_all โ โ
โ โ mem0_status ยท mem0_maintenance โ โ
โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ
โ โ โ
โ โโโโโโโโโโโโโโโ โโโโโโโโโโโดโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโ โ
โ โ Permission โ โ Write Pipeline โ โ never_store โ โ
โ โ Enforcer โ โ โ โ Regex Guard โ โ
โ โ โ โ infer=False โ โ โ โ
โ โ per-agent โ โ (embedding only, โ โ blocks keys, โ โ
โ โ read/write โ โ no LLM call) โ โ passwords, โ โ
โ โ scope rules โ โ โ โ tokens โ โ
โ โโโโโโโโโโโโโโโ โ on failure: โ โโโโโโโโโโโโโโโโโโ โ
โ โ โ write_queue โ โ
โ โ (auto-replay) โ โ
โ โโโโโโโโโโฌโโโโโโโโโโโโ โ
โ โ โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ
โโโโโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโโโ
โ โ โ
โผ โผ โผ
โโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโโโโโโ
โ Mem0 SDK โ โ Qdrant โ โ Maintenance CLI โ
โ โ โ Server โ โ โ
โ embedding + โ โ โ โ Daily (3 AM): โ
โ vector writeโ โ persistent โ โ ยท Opus re-extract โ
โ โ โ vector โ โ ยท Vector dedup โ
โ primary: โ โ storage โ โ โ
โ Gemini โ โ โ โ Weekly (Sun 4 AM): โ
โ fallback: โ โ payload โ โ ยท Conflict detect โ
โ OpenAI API โ โ metadata โ โ ยท Consolidation โ
โ โ โ filtering โ โ ยท Bjork decay โ
โโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโโโโโโ
Agent calls mem0_add("User prefers dark mode", scope="global", mem_type="preference")
โ
โโ Permission check: does this agent have write access to "global"?
โโ never_store check: does content match any sensitive pattern?
โโ Scope validation: is this a writable scope?
โ
โผ
Mem0.add(content, metadata={scope, trust, mem_type, source, agent, ...}, infer=False)
โ
โโ Success โ return result
โโ Failure โ append to write_queue.jsonl โ auto-replay on next successful call
Agent calls mem0_search("user preferences", scope="group:team_alpha")
โ
โโ Permission check: can this agent read "group:team_alpha"?
โ
โผ
Two parallel searches:
โโ Search 1: scope="group:team_alpha", archived=false
โโ Search 2: scope="global", archived=false
โ
โผ
Interleave by relevance โ trust_min filter โ limit โ bump access_count (async)
โ
โผ
Return: [{content, metadata: {scope, trust, mem_type, ...}}, ...]
| Type | Decay | Lifespan | Purpose |
|---|---|---|---|
preference |
Never | Permanent | "User prefers dark mode" |
fact |
Never | Permanent | "Project uses PostgreSQL 16" |
lesson |
Never | Permanent | "Don't use recursive CTE for this table" |
decision |
Never | Permanent | "We chose React over Vue for the dashboard" |
knowledge |
Never | Permanent | Consolidated from task_logs |
procedure |
90-day half-life | Months | "Deploy command: kubectl apply -f ..." |
task_log |
30-day half-life | Weeks | "Deployed v2.3 to staging" โ consolidates before decay |
โโโโโโโโโโโ
โ Cron โ
โโโโโโฌโโโโโ
โ
โโโโโโโโโโโโผโโโโโโโโโโโ
โผ โผ
โโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโ
โ Daily (3 AM) โ โ Weekly (Sun 4) โ
โ โ โ โ
โ 1. Opus re- โ โ 1. Everything โ
โ extract โ โ from daily โ
โ today's โ โ โ
โ memories โ โ 2. Conflict โ
โ โ โ detection โ
โ 2. Vector โ โ (same-scope โ
โ dedup โ โ fact vs โ
โ (โฅ0.92 โ โ fact) โ
โ cosine) โ โ โ
โ โ โ 3. Consolidate โ
โ 3. Report โ โ (N task_log โ
โ โ โ โ 1 โ
โโโโโโโโโโโโโโโโโโ โ knowledge) โ
โ โ
โ 4. Bjork decay โ
โ importance โ
โ < 0.10 โ โ
โ archive โ
โ โ
โ 5. Report โ
โโโโโโโโโโโโโโโโโโ
Bjork decay formula:
effective_age = age_days / (1 + min(ln(1 + access_count), 3.0))
importance = e^(-ln(2)/half_life ร effective_age)
Frequently accessed memories decay slower. When importance < 0.10, the memory is archived.
git clone https://github.com/lofder/Engram.git
cd Engram./setup.shThis creates config.yaml and .env from templates. You'll be asked to choose Docker or Local mode.
Edit .env:
GOOGLE_API_KEY=your-google-api-key-here # For Gemini embeddings
LLM_API_KEY=your-llm-api-key-here # For Mem0 inference + maintenanceGOOGLE_API_KEY is used for gemini-embedding-001 embeddings โ get one at Google AI Studio.
LLM_API_KEY (or OPENAI_API_KEY) is used by Mem0 for memory operations and by maintenance for re-extraction.
Docker mode (Qdrant included):
docker compose up -dLocal mode (manage Qdrant yourself):
docker run -d -p 6333:6333 qdrant/qdrant # or install Qdrant binary
python src/server.py# Docker mode
docker compose logs engram | tail -5
# Should show: "engram: initialized OK"
# Local mode โ server.py outputs to stderr:
# "engram: initialized OK"Cursor โ add to .cursor/mcp.json:
{
"mcpServers": {
"engram": {
"command": "python",
"args": ["/absolute/path/to/Engram/src/server.py"],
"env": {
"GOOGLE_API_KEY": "your-key",
"LLM_API_KEY": "your-llm-key",
"NO_PROXY": "localhost,127.0.0.1"
}
}
}
}Claude Desktop โ add to claude_desktop_config.json:
{
"mcpServers": {
"engram": {
"command": "python",
"args": ["/absolute/path/to/Engram/src/server.py"],
"env": {
"GOOGLE_API_KEY": "your-key",
"LLM_API_KEY": "your-llm-key"
}
}
}
}crontab -e15 2 * * * /path/to/Engram/scripts/mem0-backup.sh
0 3 * * * /path/to/Engram/scripts/run-maintenance.sh daily
0 4 * * 0 /path/to/Engram/scripts/run-maintenance.sh weeklyYour agent learns your style once, remembers it forever:
You: "I prefer concise responses, no bullet points, always include code examples"
Agent: (calls mem0_add with scope="global", mem_type="preference", trust="high")
--- next day, new session ---
Agent: (calls mem0_search("response style preferences", scope="global"))
โ gets back: "User prefers concise responses, no bullet points, always include code examples"
โ applies this to all future responses automatically
A main agent coordinates workers, each with their own memory namespace:
Main Agent: writes to global, group:team, dm
โโโ Writer: writes to agent:writer only (procedures, task_logs)
โโโ Analyst: writes to agent:analyst only
โโโ Browser: writes to agent:browser only
Main can search all scopes. Workers can only see their own memories.
No cross-contamination.
Your agent needs info from another group without switching context:
Agent: (calls mem0_search("shipping API docs", scope="cross:team_backend"))
โ searches team_backend's memories + global context
โ returns relevant results from both, interleaved by relevance
When Mem0 or the embedding API goes down:
Agent: (calls mem0_add(...))
โ Mem0 unreachable
โ Engram queues the write to write_queue.jsonl
โ Returns: {"queued": true, "write_id": "abc-123", "reason": "Mem0 unavailable"}
โ On next successful mem0_add, queued writes are auto-replayed
Key sections in config.yaml:
# Agent permissions โ who can read/write where
agents:
main:
read: [global, "group:*", dm, "agent:*", all, "cross:*"]
write: [global, "group:*", dm]
worker:
read: []
write: ["agent:worker"]
allowed_types: [procedure, task_log]
# Memory types โ each has its own decay and conflict strategy
memory_types:
preference: {decay: never, conflict: update_latest}
fact: {decay: never, conflict: verify_source}
task_log: {decay: half_life_30d, conflict: no_dedup}
# Embedding โ primary + fallback
embedding:
primary:
provider: gemini
model: models/gemini-embedding-001
dimensions: 3072
fallback:
provider: openai
model: gemini-embedding-001
base_url: https://your-proxy.example.com/v1
# Qdrant connection
qdrant:
host: localhost # or "qdrant" in docker-compose
port: 6333
collection: memories
# Credential safety โ these patterns are never stored
never_store_patterns:
- 'sk-[A-Za-z0-9]{20,}'
- 'password\s*[:=]\s*\S+'
- '-----BEGIN\s+(RSA\s+)?PRIVATE'See docs/configuration.md for the full reference.
- Changelog โ Version history and migration notes
- Architecture v2 โ Full architecture with design goals analysis
- Design Document (ไธญๆ) โ 9-chapter system design
- Usage Guide โ Integration guide
- Development Guide โ How to extend
- Configuration Reference โ All config.yaml options
| Paper | Key Insight | Our Application |
|---|---|---|
| Hindsight (2512.12818) | 4-network memory, 91.4% accuracy | 7 memory type classification |
| MAPLE (2602.13258) | HOT/COLD path separation | Daytime infer=False + nightly Opus |
| FadeMem (2601.18642) | Importance-based decay, -45% storage | Bjork-enhanced decay formula |
| OWASP ASI06 (2026) | Memory poisoning risk 40%โ80% | trust + never_store + scope isolation |
| Bjork (1992) | Storage-retrieval strength theory | access_count suppresses decay |
| TierMem (2602.17913) | Provenance tracking reduces token | Structured metadata per memory |
MIT โ See LICENSE
Issues and PRs welcome. Please read docs/development.md first.
ไธญๆ
ไฝ ไธๅฎๆ่ฟ่ฟๆ ท็ไฝ้ช๏ผ่ฑไบ 20 ๅ้่ท AI ๅฉๆ่งฃ้ไฝ ็้กน็ฎ็ปๆใ็ผ็ ้ฃๆ ผใไธชไบบๅๅฅฝใๅฎๅนฒๅพๆผไบฎใ็ฌฌไบๅคฉ๏ผๆฐไผ่ฏโโๅฎไปไน้ฝไธ่ฎฐๅพไบใไฝ ๅช่ฝไปๅคดๅๆฅใ
ไบๆฏไฝ ๆณไบไธชๅๆณ๏ผๅไธช md ๆไปถใ.cursor/rulesใAGENTS.mdใ็ณป็ป prompt ๆๆกฃโโๅซไปไน้ฝ่กใไธๅผๅงๆบๅฅฝ็จใไฝๆ
ขๆ
ขๅฐ๏ผ
- ๆไปถ่ถๅ่ถ้ฟใๆฏๆฌก AI ๆ้ไปไน๏ผไฝ ๅฐฑๅ ไธๆก่งๅใ
- ๆงๆไปคๅๆฐๆไปคๆๆถ๏ผไฝ ๅพๅๅปๆๅจ็้กบใ
- ไฝ ๅ็ฐ่ชๅทฑ่ฑๅจ็ปดๆค AI ็่ฎฐๅฟไธ็ๆถ้ดๆฏๅนฒๆญฃไบ่ฟๅคใ
- ไฝ ๆๅคไธช้กน็ฎใๅคไธช Agentโโ็ฐๅจ่ฟๅพๅๆญฅๅคไธชๆไปถใ
ไฝ ๅๆไบ AI ็ๅ จ่่ฎฐๅฟ็ฎก็ๅใ่ฟๅฎๅ จๆๅไบใ
ๆดๆทฑๅฑ็้ฎ้ขไธๅชๆฏ"AI ไผๅฟ"๏ผ่ๆฏ่ฎฐๅฟ็่ดๆ ๅ จๅๅจไฝ ่บซไธใ ไฝ ๅจๆๅจๅ่ฎฐๅฟ็ณป็ป่ฏฅ่ชๅจๅ็ไบ๏ผๅคๆญไปไน้่ฆใๅๅๆถๆดๆฐใ่ฟๆถไบๅฐฑๆธ ๆใ
Engram ๆ่ฟไปถไบ็ฟป่ฝฌ่ฟๆฅใไธๆฏไฝ ๆฟ AI ็ปดๆคๆไปถ๏ผ่ๆฏ AI ่ชๅทฑ็ปดๆค่ชๅทฑ็่ฎฐๅฟโโ็ปๆๅ็ใๅๅ็ใ่ฝ่ชๆๆธ ็็ใๅฎ่ชๅทฑๅคๆญไปไน่ฏฅ็๏ผ่ชๅจๅ็ผฉๆงไฟกๆฏ๏ผ่ชๅจๆทกๅบไธๅ็ธๅ ณ็ๅ ๅฎนใไฝ ๅช็ฎก็จใ
็ฐๅจ: ไฝ ๅ rules.md โ AI ่ฏปๅฎ โ ไฝ ๆดๆฐ rules.md โ ๆ ้ๅพช็ฏ
Engram: AI ่ชๅทฑ่ฎฐไฝ โ ้ๆถ้ดๅ็ผฉ โ ไฝ ๅไนไธ็จ็ปดๆคๆไปถไบ
ไฝ ไธไผๆๅจ็ปๆฏไธชๆๅผ่ฟ็็ฝ้กตๅญไนฆ็ญพ๏ผไฝ ็ๅคง่ไผ่ชๅทฑๅคๆญไปไนๅผๅพ่ฎฐไฝใEngram ๅ็โโAI ่ชๅทฑๅณๅฎๅญไปไนใไฝๆถๅๅฟใๅฟฝ็ฅไปไนใไฝ ๅช็ฎกๆญฃๅธธไฝฟ็จ๏ผ่ฎฐๅฟๅจๅๅฐ่ช็ถๅ็ใ
ๆฏๆฌกๅฏน่ฏๅก่ฟๅป 50 ๆกๆง่ฎฐๅฟๅนถๆฒกๆๅธฎๅฉโโๅชไผๆตช่ดน token ๅๅนฒๆฐๆจกๅใEngram ่ฎฉ่ฎฐๅฟไฟๆ็ฒพ็ฎ๏ผ้ๅค็ๅๅนถใๆงๆฅๅฟๆต็ผฉๆ็ฎๆด็็ฅ่ฏใ่ฟๆถ็ๆก็ฎ่ชๅจๆทกๅบใๆ็ป็ปๆๆฏไธ็ปๅฐ่้ซ่ดจ้็่ฎฐๅฟ๏ผ็ๆญฃ่ฝๆนๅๅๅค่ดจ้ใ
ไธๆฏๆๆ่ฎฐๅฟ้ฝๅ็ญ้่ฆใไฝ ็ๅๅฅฝ๏ผ"ๆฐธ่ฟ็จ TypeScript"๏ผใๅญฆๅฐ็ๆ่ฎญ๏ผ"้ฃไธช API ๆ 5 ็ง่ถ ๆถ"๏ผใๅ ณ้ฎๅณ็ญ๏ผ"ๆไปฌ็จ PostgreSQL"๏ผโโ่ฟไบๆฐธ่ฟไธ่ฏฅ่ขซๅฟ่ฎฐใไฝๆจๅคฉ็้จ็ฝฒๆฅๅฟ๏ผๅฎๅฏไปฅๆ ขๆ ขๆทกๅบโโๅจ่ขซๆ็ผๆๆไน ็ฅ่ฏไนๅใ
Engram ้่ฟ MCP ๅ่ฎฎๆด้ฒ 5 ไธชๅทฅๅ ทใไปปไฝ MCP ๅ ผๅฎนๅฎขๆท็ซฏ๏ผCursorใClaude Desktopใ่ชๅฎไน Agent๏ผ้ฝๅฏไปฅ่ฐ็จ๏ผ
| ๅๆฐ | ็ฑปๅ | ๅฟ ๅกซ | ่ฏดๆ |
|---|---|---|---|
content |
string | ๆฏ | ่ฎฐๅฟๅ ๅฎน |
scope |
string | ๆฏ | globalใgroup:xxxใdmใagent:xxx |
mem_type |
string | ๅฆ | preferenceใfactใprocedureใlessonใdecisionใtask_logใknowledge |
source |
string | ๅฆ | user_directใagent_outputใtool_resultใinferred๏ผ้ป่ฎค๏ผagent_output๏ผ |
trust |
string | ๅฆ | highใmediumใlow๏ผ้ป่ฎค๏ผmedium๏ผ |
context |
string | ๅฆ | ่พ ๅฉๆฃ็ดข็้ๅ ไธไธๆ |
agent |
string | ๅฆ | ่ฐ็จ่ ่บซไปฝ๏ผ็จไบๆ้ๆ ก้ช |
่ฟๅ๏ผๆๅ {"results": [...]}๏ผMem0 ไธๅฏ็จๆถ {"queued": true, "write_id": "..."}๏ผๅ็ปญ่ชๅจ้ๆพ๏ผ๏ผๆ้/ๅฎๅ
จ่ฟ่ง {"error": "..."}ใ
| ๅๆฐ | ็ฑปๅ | ๅฟ ๅกซ | ่ฏดๆ |
|---|---|---|---|
query |
string | ๆฏ | ่ช็ถ่ฏญ่จๆ็ดข |
scope |
string | ๅฆ | ็ฎๆ scope๏ผ้ป่ฎค๏ผglobal๏ผใ็จ cross:group_id ่ทจๅๆ็ดข |
mem_type |
string | ๅฆ | ๆ่ฎฐๅฟ็ฑปๅ่ฟๆปค |
trust_min |
string | ๅฆ | ๆไฝไฟกไปป็ญ็บง๏ผhighใmediumใlow |
limit |
int | ๅฆ | ๆๅคง่ฟๅๆฐ๏ผ้ป่ฎค๏ผ5๏ผ |
agent |
string | ๅฆ | ่ฐ็จ่ ่บซไปฝ |
ๅ่ทฏๅๅนถ๏ผๅฝ scope ๆฏ group:xxx ๆถ๏ผEngram ๅนถ่กๆ็ดข๏ผgroup + global๏ผ๏ผๆ็ธๅ
ณๆงไบค้ๅๅนถใไธๆฌก่ฐ็จๅๆถ่ทๅพๆฌๅฐๅๅ
จๅฑๆไฝณ็ปๆใ
| ๅๆฐ | ็ฑปๅ | ๅฟ ๅกซ | ่ฏดๆ |
|---|---|---|---|
user_id |
string | ๅฆ | ็จๆท่ฟๆปค๏ผ้ป่ฎค๏ผdefault๏ผ |
scope |
string | ๅฆ | scope ่ฟๆปค |
agent |
string | ๅฆ | ่ฐ็จ่ ่บซไปฝ |
่ฟๅๅฎๆด็ณป็ป็ถๆ๏ผๅ็ซฏๅฐฑ็ปชๆงใ่ฎฐๅฟๆปๆฐ/ๆดป่ทๆฐ/ๅฝๆกฃๆฐใๆ scope/็ฑปๅ/ไฟกไปป็ญ็บง็ๅๅธใๅๅ ฅ้ๅๅคงๅฐใembedding ๆจกๅ็ๆฌใ
MCP ๅทฅๅ
ทๆไพๆฅๅๆฅ็ใๅฎ้
็ปดๆค๏ผOpus ้ๆๅใๅป้ใๅทฉๅบใ่กฐๅ๏ผ้่ฟ python src/maintenance.py ็ฑ cron ่ฐๅบฆๆง่กใ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ L1: Agent ๅฑ โ
โ โ
โ โโโโโโโโโโโโ โโโโโโโโโโโโ โโโโโโโโโโโโ โโโโโโโโโโโโ โ
โ โ Main โ โ Worker A โ โ Worker B โ โ DevOps โ โ
โ โ Agent โ โ โ โ โ โ Agent โ โ
โ โ โ โ โ โ โ โ โ โ
โ โ ่ฏป: ๅ
จๅ โ โ ่ฏป: โ โ โ ่ฏป: โ โ โ ่ฏป: ๅ
จๅ โ โ
โ โ ๅ: globalโ โ ๅ: self โ โ ๅ: self โ โ ๅ: ๅ
จๅ โ โ
โ โ group โ โ โ โ โ โ โ โ
โ โ dm โ โ โ โ โ โ โ โ
โ โโโโโโฌโโโโโโ โโโโโโฌโโโโโโ โโโโโโฌโโโโโโ โโโโโโฌโโโโโโ โ
โโโโโโโโโผโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโ
โโโโโโโโโโโโโโโโดโโโโโโโฌโโโโโโโโดโโโโโโโโโโโโโโโ
โ MCP (stdio)
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ L2: Engram MCP Server โผ โ
โ โ
โ 5 ไธชๅทฅๅ
ท ยท ๆ้ๅฎๅซ ยท never_store ๆญฃๅ ยท ๅๅ
ฅ้ๅ้็บง โ
โ โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ
โโโโโโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโโโโ
โผ โผ โผ
โโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโโโโโโ
โ Mem0 SDK โ โ Qdrant โ โ ็ปดๆค CLI (cron) โ
โ infer=False โ โ ๅ้ๆไน
ๅ โ โ โ
โ ไธป: Gemini โ โ โ โ ๆฏๆฅ: Opus + ๅป้ โ
โ ๅค: OpenAI โ โ โ โ ๆฏๅจ: +ๅฒ็ช+ๅทฉๅบ+่กฐๅ โ
โโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโโโโโโ
| ็ฑปๅ | ่กฐๅ | ๅฏฟๅฝ | ไธพไพ |
|---|---|---|---|
preference |
ๆฐธไธ | ๆฐธไน | "็จๆทๅๆฌข็ฎ็บฆ้ฃๆ ผ" |
fact |
ๆฐธไธ | ๆฐธไน | "้กน็ฎไฝฟ็จ PostgreSQL 16" |
lesson |
ๆฐธไธ | ๆฐธไน | "่ฟไธช่กจไธ่ฆ็จ้ๅฝ CTE" |
decision |
ๆฐธไธ | ๆฐธไน | "Dashboard ้ไบ React ่้ Vue" |
knowledge |
ๆฐธไธ | ๆฐธไน | ไป task_log ๅทฉๅบ่ๆฅ |
procedure |
90 ๅคฉๅ่กฐๆ | ๆฐๆ | "้จ็ฝฒๅฝไปค๏ผkubectl apply -f ..." |
task_log |
30 ๅคฉๅ่กฐๆ | ๆฐๅจ | "้จ็ฝฒไบ v2.3 ๅฐ staging" โ ่ฟๆๅๅทฉๅบ |
effective_age = age_days / (1 + min(ln(1 + access_count), 3.0))
importance = e^(-ln(2)/ๅ่กฐๆ ร effective_age)
่ขซๆฃ็ดข่ถๅค็่ฎฐๅฟ่กฐๅ่ถๆ
ขใๅฝ importance < 0.10 ๆถ่ชๅจๅฝๆกฃใ
git clone https://github.com/lofder/Engram.git
cd Engram./setup.sh่ชๅจ็ๆ config.yaml ๅ .env๏ผไบคไบ้ๆฉ Docker ๆๆฌๅฐๆจกๅผใ
็ผ่พ .env๏ผ
GOOGLE_API_KEY=ไฝ ็-google-api-key # ็จไบ Gemini embedding
LLM_API_KEY=ไฝ ็-llm-api-key # ็จไบ Mem0 ๆจ็ + ็ปดๆคGOOGLE_API_KEY ็จไบ gemini-embedding-001 ๅ้ๅ๏ผๅจ Google AI Studio ่ทๅใ
LLM_API_KEY๏ผๆ OPENAI_API_KEY๏ผ็จไบ Mem0 ็่ฎฐๅฟๆไฝๅ็ปดๆค่ๆฌ็้ๆๅใ
Docker ๆจกๅผ๏ผๅซ Qdrant๏ผ๏ผ
docker compose up -dๆฌๅฐๆจกๅผ๏ผ
docker run -d -p 6333:6333 qdrant/qdrant
python src/server.py# ็ๅฐ "engram: initialized OK" ๅณๆๅ
docker compose logs engram | tail -5Cursor โ ๆทปๅ ๅฐ .cursor/mcp.json๏ผ
{
"mcpServers": {
"engram": {
"command": "python",
"args": ["/absolute/path/to/Engram/src/server.py"],
"env": {
"GOOGLE_API_KEY": "your-key",
"LLM_API_KEY": "your-llm-key",
"NO_PROXY": "localhost,127.0.0.1"
}
}
}
}15 2 * * * /path/to/Engram/scripts/mem0-backup.sh
0 3 * * * /path/to/Engram/scripts/run-maintenance.sh daily
0 4 * * 0 /path/to/Engram/scripts/run-maintenance.sh weeklyAgent ๅญฆไธๆฌก๏ผๆฐธ่ฟ่ฎฐไฝ๏ผ
ไฝ : "ๆๅๆฌข็ฎๆด็ๅๅค๏ผไธ่ฆๅ่กจ๏ผไธๅฎ่ฆๅธฆไปฃ็ ็คบไพ"
Agent: (่ฐ็จ mem0_add, scope="global", mem_type="preference", trust="high")
--- ็ฌฌไบๅคฉ๏ผๆฐไผ่ฏ ---
Agent: (่ฐ็จ mem0_search("ๅๅค้ฃๆ ผๅๅฅฝ", scope="global"))
โ ่ฟๅ: "็จๆทๅๆฌข็ฎๆดๅๅค๏ผไธ่ฆๅ่กจ๏ผไธๅฎ่ฆๅธฆไปฃ็ ็คบไพ"
โ ่ชๅจๅบ็จๅฐๆๆๅ็ปญๅๅค
Main Agent ๅ่ฐ Worker๏ผๅๆ็ฌ็ซ่ฎฐๅฟ็ฉบ้ด๏ผ
Main Agent: ๅ global, group:team, dm
โโโ Writer: ๅชๅ agent:writer๏ผprocedure, task_log๏ผ
โโโ Analyst: ๅชๅ agent:analyst
โโโ Browser: ๅชๅ agent:browser
Main ๅฏๆ็ดขๆๆ scopeใWorker ๅช็ๅฐ่ชๅทฑ็่ฎฐๅฟใ้ถไบคๅๆฑกๆใ
Agent: (่ฐ็จ mem0_search("็ฉๆตAPIๆๆกฃ", scope="cross:team_backend"))
โ ๅๆถๆ็ดข team_backend ็่ฎฐๅฟ + global ไธไธๆ
โ ๆ็ธๅ
ณๆงไบค้่ฟๅไธค่พน็็ปๆ
Mem0 ๆ embedding API ๆไบ๏ผ
Agent: (่ฐ็จ mem0_add(...))
โ Mem0 ไธๅฏ่พพ
โ Engram ๆๅๅ
ฅๆๅ
ฅ write_queue.jsonl
โ ่ฟๅ: {"queued": true, "write_id": "abc-123"}
โ ไธๆฌกๆๅๅๅ
ฅๆถ่ชๅจ้ๆพ้ๅ
config.yaml ๆ ธๅฟๆฎต่ฝ๏ผ
# Agent ๆ้ โ ่ฐๅฏไปฅๅจๅช้่ฏปๅ
agents:
main:
read: [global, "group:*", dm, "agent:*", all, "cross:*"]
write: [global, "group:*", dm]
worker:
read: []
write: ["agent:worker"]
allowed_types: [procedure, task_log]
# ่ฎฐๅฟ็ฑปๅ โ ๅๆ็ฌ็ซ็่กฐๅๅๅฒ็ช็ญ็ฅ
memory_types:
preference: {decay: never, conflict: update_latest}
fact: {decay: never, conflict: verify_source}
task_log: {decay: half_life_30d, conflict: no_dedup}
# ๅฎๅ
จ โ ๅน้
่ฟไบๆญฃๅ็ๅ
ๅฎนๆฐธ่ฟไธไผ่ขซๅญๅจ
never_store_patterns:
- 'sk-[A-Za-z0-9]{20,}'
- 'password\s*[:=]\s*\S+'ๅฎๆด้ ็ฝฎๅ่่ง docs/configuration.mdใ
- ๆดๆฐๆฅๅฟ โ ็ๆฌๅๅฒๅ่ฟ็งป่ฏดๆ
- ๆถๆ่ฏฆ่งฃ (v2) โ ๅฎๆดๆถๆ๏ผๅซไธไธช่ฎพ่ฎก็ฎๆ ๅๆ
- ่ฎพ่ฎกๆๆกฃ โ 9 ็ซ ็ณป็ป่ฎพ่ฎก
- ไฝฟ็จๆๅ โ ้ๆๆๅ
- ๅผๅๆๅ โ ๅฆไฝๆฉๅฑ
- ้ ็ฝฎๅ่ โ config.yaml ๅฎๆด้้กน
| ่ฎบๆ | ๆ ธๅฟๆดๅฏ | ๆฌ้กน็ฎ็ๅบ็จ |
|---|---|---|
| Hindsight (2512.12818) | 4 ็ฝ็ป่ฎฐๅฟ๏ผ91.4% ๅ็กฎ็ | 7 ็ง่ฎฐๅฟ็ฑปๅๅ็ฑป |
| MAPLE (2602.13258) | HOT/COLD ่ทฏๅพๅ็ฆป | ็ฝๅคฉ infer=False + ๅค้ด Opus |
| FadeMem (2601.18642) | ๅบไบ้่ฆๆง็่กฐๅ๏ผ-45% ๅญๅจ | Bjork ๅขๅผบ่กฐๅๅ ฌๅผ |
| OWASP ASI06 (2026) | ่ฎฐๅฟๆๆฏ้ฃ้ฉ 40%โ80% | trust + never_store + scope ้็ฆป |
| Bjork (1992) | ๅญๅจ-ๆฃ็ดขๅผบๅบฆ็่ฎบ | access_count ๆๅถ่กฐๅ |
| TierMem (2602.17913) | ๆฅๆบ่ฟฝ่ธชๅๅฐ token | ๆฏๆก่ฎฐๅฟ็็ปๆๅๅ ๆฐๆฎ |
MIT โ ่ง LICENSE
ๆฌข่ฟๆ Issue ๅ PRใ่ฏทๅ ้ ่ฏป docs/development.mdใ