{"title":"Mô hình bộ nhớ","slug":"memory-model","category":"concepts","summary":"Cách bộ nhớ được cấu trúc — danh mục, key, tag, mức ưu tiên, nguồn, xác minh.","audience":["human","llm"],"tags":["concept","memory","model","structure"],"difficulty":"intermediate","updated":"2026-06-27","word_count":939,"read_minutes":5,"lang":"vi","translated":true,"requested_lang":"vi","content_markdown":"\n# Mô hình bộ nhớ\n\nMô hình bộ nhớ của Synapse được thiết kế cho LLM agent — đủ cấu trúc để thu hồi\ntin cậy, đủ linh hoạt cho bất kỳ lĩnh vực nào.\n\n## Giải phẫu bộ nhớ\n\n```json\n{\n  \"id\": \"mem_abc123\",\n  \"category\": \"project\",\n  \"key\": \"project_synapse_status\",\n  \"content\": \"Synapse v1.5.0 deployed on vps1. CI green.\",\n  \"tags\": [\"synapse\", \"deployment\", \"v1.5.0\"],\n  \"priority\": \"high\",\n  \"source\": \"agent\",\n  \"verified\": false,\n  \"confidence\": 0.85,\n  \"expires_at\": null,\n  \"mind_id\": \"m_xyz789\",\n  \"created_at\": \"2026-06-27T...\",\n  \"updated_at\": \"2026-06-27T...\"\n}\n```\n\n## Trường\n\n| Trường | Loại | Bắt buộc | Mô tả |\n|-------|------|----------|-------------|\n| `id` | string | tự động | ID duy nhất (mem_xxx) |\n| `category` | enum | ✅ | Một trong 8 danh mục |\n| `key` | string | ✅ | Định danh ổn định (dùng để cập nhật) |\n| `content` | string | ✅ | Nội dung bộ nhớ (bất kỳ văn bản nào) |\n| `tags` | string[] | – | Để tìm kiếm và lọc |\n| `priority` | enum | – | low, normal, high, critical (mặc định: normal) |\n| `source` | enum | tự động | user, agent (ai lưu) |\n| `verified` | bool | tự động | Con người đã xác minh chưa? |\n| `confidence` | float | – | 0.0 đến 1.0 (mặc định: 1.0 cho user, 0.7 cho agent) |\n| `expires_at` | timestamp | – | Khi nào quên bộ nhớ này |\n| `mind_id` | string | tự động | Mind nào sở hữu cái này |\n| `created_at` | timestamp | tự động | Lần đầu lưu |\n| `updated_at` | timestamp | tự động | Lần sửa cuối |\n\n## Danh mục\n\nTám danh mục bao phủ các trường hợp sử dụng LLM agent phổ biến:\n\n| Danh mục | Mục đích | Nội dung ví dụ |\n|----------|---------|-----------------|\n| `identity` | Người dùng là ai | \"User is Michael Schäfer, software engineer in Berlin\" |\n| `preference` | Sở thích người dùng | \"Prefers concise technical responses\" |\n| `fact` | Sự kiện có thể kiểm chứng | \"Office is in Berlin, timezone Europe/Berlin\" |\n| `project` | Trạng thái dự án | \"Synapse v1.5.0 deployed, working on v1.6.0 docs\" |\n| `skill` | Kỹ năng người dùng | \"Advanced Python, 10+ years\" |\n| `mistake` | Lỗi trong quá khứ | \"Forgot to bump npm version — CI failed\" |\n| `context` | Ngữ cảnh phiên | \"Currently reviewing PR #42\" |\n| `note` | Ghi chú linh tinh | \"Try Redis for caching next sprint\" |\n\n## Key: Định danh ổn định\n\nTrường `key` rất quan trọng — đó là cách bạn cập nhật bộ nhớ mà không tạo bản\ntrùng lặp.\n\n```python\n# First store\nstore(\"project\", \"project_synapse_status\", \"v1.4.0 deployed\", priority=\"high\")\n\n# Update with same key (overwrites, doesn't duplicate)\nstore(\"project\", \"project_synapse_status\", \"v1.5.0 deployed\", priority=\"high\")\n```\n\n**Quy tắc key:**\n\n- Phải duy nhất trong (category, mind)\n- Sử dụng `snake_case`\n- Tiền tố với danh mục để rõ ràng: `preference_communication`, `mistake_npm_version`\n- Giữ ổn định — không thay đổi key sau khi tạo\n\n## Tag: Dành cho tìm kiếm\n\nTag cho phép lọc và tìm kiếm nhanh:\n\n```bash\n# Find all memories with tag \"docker\"\nGET /memory/by-tag?tag=docker\n\n# FTS5 search within tagged subset\nGET /memory/search?q=swarm&tag=docker\n```\n\n**Thực hành tốt nhất về tag:**\n\n- 2-5 tag mỗi bộ nhớ (không gắn tag quá mức)\n- Chữ thường để nhất quán\n- Sử dụng tên dự án, chủ đề, công nghệ\n- Tag không phân biệt chữ hoa chữ thường\n\n## Mức ưu tiên\n\n| Ưu tiên | Khi nào sử dụng | Hành vi thu hồi |\n|----------|-------------|-----------------|\n| `critical` | Nhận dạng, pháp lý, không thể đảo ngược | Luôn ở đầu thu hồi |\n| `high` | Dự án đang hoạt động, sở thích chính | Nổi bật trong thu hồi |\n| `normal` | Hầu hết bộ nhớ (mặc định) | Thứ tự thu hồi chuẩn |\n| `low` | Tạm thời, tốt nếu biết | Có thể được tóm tắt |\n\n`/memory/recall` sắp xếp theo ưu tiên (critical trước), sau đó theo gần đây.\n\n## Nguồn: User so với Agent\n\nBộ nhớ được gắn `source`:\n\n- `user` — được lưu bởi con người (qua JWT hoặc giao diện con người)\n- `agent` — được lưu bởi LLM agent (qua Mind Key)\n\nĐiều này ảnh hưởng:\n\n- **Xác minh**: bộ nhớ `user` được tự động xác minh, bộ nhớ `agent` thì không\n- **Độ tin cậy**: `user` mặc định 1.0, `agent` 0.7\n- **Thu hồi**: `/memory/recall` đánh dấu bộ nhớ chưa xác minh với \"(unverified)\"\n\n> [!NOTE]\n> Hãy đối xử với bộ nhớ nguồn `agent` với sự hoài nghi phù hợp. Chúng có thể\n> được suy luận hoặc giả định thay vì được người dùng phát biểu trực tiếp.\n\n## Xác minh\n\nCờ `verified` cho biết con người đã xác nhận bộ nhớ:\n\n- Bộ nhớ `user`: tự động xác minh (`true`)\n- Bộ nhớ `agent`: mặc định chưa xác minh (`false`)\n\nXác minh bộ nhớ qua:\n\n```bash\ncurl -X POST https://synapse.schaefer.zone/memory/mem_001/verify \\\n  -H \"Authorization: Bearer YOUR_JWT\"\n```\n\n> [!NOTE]\n> Xác minh yêu cầu JWT (xác thực con người), không phải Mind Key (xác thực\n> agent). Điều này đảm bảo chỉ con người có thể đánh dấu bộ nhớ là đã xác minh.\n\n## Độ tin cậy\n\nTrường `confidence` (0.0 đến 1.0) cho biết bộ nhớ đáng tin cậy đến đâu:\n\n- 1.0 — được người dùng phát biểu trực tiếp\n- 0.7 — được agent suy luận\n- 0.5 — không chắc chắn, cần xác minh\n- 0.0 — bị nghi ngờ rõ ràng\n\nĐặt độ tin cậy khi lưu:\n\n```json\n{\n  \"category\": \"preference\",\n  \"key\": \"prefers_dark_mode\",\n  \"content\": \"User seems to prefer dark mode (based on their IDE screenshots)\",\n  \"confidence\": 0.5,\n  \"source\": \"agent\"\n}\n```\n\n## Hết hạn\n\nĐặt `expires_at` cho bộ nhớ nhạy cảm với thời gian:\n\n```json\n{\n  \"category\": \"context\",\n  \"key\": \"current_meeting_topic\",\n  \"content\": \"Discussing Q3 roadmap\",\n  \"expires_at\": \"2026-06-28T00:00:00Z\"\n}\n```\n\nBộ nhớ hết hạn không được `/memory/recall` trả về (nhưng vẫn tồn tại trong DB).\nSử dụng `/memory/expiring?within=7d` để xem bộ nhớ sắp hết hạn.\n\n## Vòng đời bộ nhớ\n\n```\n                  ┌─────────────────┐\n                  │     Create      │\n                  │  POST /memory   │\n                  └────────┬────────┘\n                           │\n                           ▼\n                  ┌─────────────────┐\n                  │     Active      │ ◀──── PUT /memory/:id (update)\n                  │  (in recall)    │\n                  └────────┬────────┘\n                           │\n              ┌────────────┼────────────┐\n              │            │            │\n              ▼            ▼            ▼\n        ┌──────────┐ ┌──────────┐ ┌──────────┐\n        │ Expired  │ │ Verified │ │ Deleted  │\n        │ (in DB)  │ │ (flag)   │ │ (gone)   │\n        └──────────┘ └──────────┘ └──────────┘\n```\n\n## Hành vi thu hồi\n\n`GET /memory/recall` trả về tóm tắt văn bản thuần được tối ưu cho ngữ cảnh LLM:\n\n```\nMind: Michael's Mind\nMemories: 12 total (10 verified, 2 unverified)\n\n[001] identity (CRITICAL) [verified]\n  user_name\n  Michael Schäfer\n  Tags: person, identity\n\n[002] preference (HIGH) [verified]\n  communication_style\n  Prefers concise technical responses\n  Tags: communication\n\n[003] project (HIGH) [unverified]\n  synapse_status\n  v1.5.0 deployed, working on v1.6.0 docs\n  Tags: synapse, deployment\n\n...\n```\n\n- Sắp xếp theo ưu tiên (critical → low), sau đó theo gần đây\n- Bộ nhớ chưa xác minh được đánh dấu `[unverified]`\n- Tag được bao gồm cho ngữ cảnh\n- Văn bản thuần (không cần phân tích JSON)\n\n## Bước tiếp theo\n\n- [Memory API](/docs/api/memory)\n- [Thực hành tốt nhất về bộ nhớ](/docs/guides/memory-best-practices)\n- [Tìm kiếm FTS5](/docs/concepts/fts5-search)\n","content_html":"<h1>Mô hình bộ nhớ</h1>\n<p>Mô hình bộ nhớ của Synapse được thiết kế cho LLM agent — đủ cấu trúc để thu hồi\ntin cậy, đủ linh hoạt cho bất kỳ lĩnh vực nào.</p>\n<h2>Giải phẫu bộ nhớ</h2>\n<pre><code class=\"hljs language-json\"><span class=\"hljs-punctuation\">{</span>\n  <span class=\"hljs-attr\">&quot;id&quot;</span><span class=\"hljs-punctuation\">:</span> <span class=\"hljs-string\">&quot;mem_abc123&quot;</span><span class=\"hljs-punctuation\">,</span>\n  <span class=\"hljs-attr\">&quot;category&quot;</span><span class=\"hljs-punctuation\">:</span> <span class=\"hljs-string\">&quot;project&quot;</span><span class=\"hljs-punctuation\">,</span>\n  <span class=\"hljs-attr\">&quot;key&quot;</span><span class=\"hljs-punctuation\">:</span> <span class=\"hljs-string\">&quot;project_synapse_status&quot;</span><span class=\"hljs-punctuation\">,</span>\n  <span class=\"hljs-attr\">&quot;content&quot;</span><span class=\"hljs-punctuation\">:</span> <span class=\"hljs-string\">&quot;Synapse v1.5.0 deployed on vps1. CI green.&quot;</span><span class=\"hljs-punctuation\">,</span>\n  <span class=\"hljs-attr\">&quot;tags&quot;</span><span class=\"hljs-punctuation\">:</span> <span class=\"hljs-punctuation\">[</span><span class=\"hljs-string\">&quot;synapse&quot;</span><span class=\"hljs-punctuation\">,</span> <span class=\"hljs-string\">&quot;deployment&quot;</span><span class=\"hljs-punctuation\">,</span> <span class=\"hljs-string\">&quot;v1.5.0&quot;</span><span class=\"hljs-punctuation\">]</span><span class=\"hljs-punctuation\">,</span>\n  <span class=\"hljs-attr\">&quot;priority&quot;</span><span class=\"hljs-punctuation\">:</span> <span class=\"hljs-string\">&quot;high&quot;</span><span class=\"hljs-punctuation\">,</span>\n  <span class=\"hljs-attr\">&quot;source&quot;</span><span class=\"hljs-punctuation\">:</span> <span class=\"hljs-string\">&quot;agent&quot;</span><span class=\"hljs-punctuation\">,</span>\n  <span class=\"hljs-attr\">&quot;verified&quot;</span><span class=\"hljs-punctuation\">:</span> <span class=\"hljs-literal\"><span class=\"hljs-keyword\">false</span></span><span class=\"hljs-punctuation\">,</span>\n  <span class=\"hljs-attr\">&quot;confidence&quot;</span><span class=\"hljs-punctuation\">:</span> <span class=\"hljs-number\">0.85</span><span class=\"hljs-punctuation\">,</span>\n  <span class=\"hljs-attr\">&quot;expires_at&quot;</span><span class=\"hljs-punctuation\">:</span> <span class=\"hljs-literal\"><span class=\"hljs-keyword\">null</span></span><span class=\"hljs-punctuation\">,</span>\n  <span class=\"hljs-attr\">&quot;mind_id&quot;</span><span class=\"hljs-punctuation\">:</span> <span class=\"hljs-string\">&quot;m_xyz789&quot;</span><span class=\"hljs-punctuation\">,</span>\n  <span class=\"hljs-attr\">&quot;created_at&quot;</span><span class=\"hljs-punctuation\">:</span> <span class=\"hljs-string\">&quot;2026-06-27T...&quot;</span><span class=\"hljs-punctuation\">,</span>\n  <span class=\"hljs-attr\">&quot;updated_at&quot;</span><span class=\"hljs-punctuation\">:</span> <span class=\"hljs-string\">&quot;2026-06-27T...&quot;</span>\n<span class=\"hljs-punctuation\">}</span></code></pre><h2>Trường</h2>\n<table>\n<thead>\n<tr>\n<th>Trường</th>\n<th>Loại</th>\n<th>Bắt buộc</th>\n<th>Mô tả</th>\n</tr>\n</thead>\n<tbody><tr>\n<td><code>id</code></td>\n<td>string</td>\n<td>tự động</td>\n<td>ID duy nhất (mem_xxx)</td>\n</tr>\n<tr>\n<td><code>category</code></td>\n<td>enum</td>\n<td>✅</td>\n<td>Một trong 8 danh mục</td>\n</tr>\n<tr>\n<td><code>key</code></td>\n<td>string</td>\n<td>✅</td>\n<td>Định danh ổn định (dùng để cập nhật)</td>\n</tr>\n<tr>\n<td><code>content</code></td>\n<td>string</td>\n<td>✅</td>\n<td>Nội dung bộ nhớ (bất kỳ văn bản nào)</td>\n</tr>\n<tr>\n<td><code>tags</code></td>\n<td>string[]</td>\n<td>–</td>\n<td>Để tìm kiếm và lọc</td>\n</tr>\n<tr>\n<td><code>priority</code></td>\n<td>enum</td>\n<td>–</td>\n<td>low, normal, high, critical (mặc định: normal)</td>\n</tr>\n<tr>\n<td><code>source</code></td>\n<td>enum</td>\n<td>tự động</td>\n<td>user, agent (ai lưu)</td>\n</tr>\n<tr>\n<td><code>verified</code></td>\n<td>bool</td>\n<td>tự động</td>\n<td>Con người đã xác minh chưa?</td>\n</tr>\n<tr>\n<td><code>confidence</code></td>\n<td>float</td>\n<td>–</td>\n<td>0.0 đến 1.0 (mặc định: 1.0 cho user, 0.7 cho agent)</td>\n</tr>\n<tr>\n<td><code>expires_at</code></td>\n<td>timestamp</td>\n<td>–</td>\n<td>Khi nào quên bộ nhớ này</td>\n</tr>\n<tr>\n<td><code>mind_id</code></td>\n<td>string</td>\n<td>tự động</td>\n<td>Mind nào sở hữu cái này</td>\n</tr>\n<tr>\n<td><code>created_at</code></td>\n<td>timestamp</td>\n<td>tự động</td>\n<td>Lần đầu lưu</td>\n</tr>\n<tr>\n<td><code>updated_at</code></td>\n<td>timestamp</td>\n<td>tự động</td>\n<td>Lần sửa cuối</td>\n</tr>\n</tbody></table>\n<h2>Danh mục</h2>\n<p>Tám danh mục bao phủ các trường hợp sử dụng LLM agent phổ biến:</p>\n<table>\n<thead>\n<tr>\n<th>Danh mục</th>\n<th>Mục đích</th>\n<th>Nội dung ví dụ</th>\n</tr>\n</thead>\n<tbody><tr>\n<td><code>identity</code></td>\n<td>Người dùng là ai</td>\n<td>&quot;User is Michael Schäfer, software engineer in Berlin&quot;</td>\n</tr>\n<tr>\n<td><code>preference</code></td>\n<td>Sở thích người dùng</td>\n<td>&quot;Prefers concise technical responses&quot;</td>\n</tr>\n<tr>\n<td><code>fact</code></td>\n<td>Sự kiện có thể kiểm chứng</td>\n<td>&quot;Office is in Berlin, timezone Europe/Berlin&quot;</td>\n</tr>\n<tr>\n<td><code>project</code></td>\n<td>Trạng thái dự án</td>\n<td>&quot;Synapse v1.5.0 deployed, working on v1.6.0 docs&quot;</td>\n</tr>\n<tr>\n<td><code>skill</code></td>\n<td>Kỹ năng người dùng</td>\n<td>&quot;Advanced Python, 10+ years&quot;</td>\n</tr>\n<tr>\n<td><code>mistake</code></td>\n<td>Lỗi trong quá khứ</td>\n<td>&quot;Forgot to bump npm version — CI failed&quot;</td>\n</tr>\n<tr>\n<td><code>context</code></td>\n<td>Ngữ cảnh phiên</td>\n<td>&quot;Currently reviewing PR #42&quot;</td>\n</tr>\n<tr>\n<td><code>note</code></td>\n<td>Ghi chú linh tinh</td>\n<td>&quot;Try Redis for caching next sprint&quot;</td>\n</tr>\n</tbody></table>\n<h2>Key: Định danh ổn định</h2>\n<p>Trường <code>key</code> rất quan trọng — đó là cách bạn cập nhật bộ nhớ mà không tạo bản\ntrùng lặp.</p>\n<pre><code class=\"hljs language-python\"><span class=\"hljs-comment\"># First store</span>\nstore(<span class=\"hljs-string\">&quot;project&quot;</span>, <span class=\"hljs-string\">&quot;project_synapse_status&quot;</span>, <span class=\"hljs-string\">&quot;v1.4.0 deployed&quot;</span>, priority=<span class=\"hljs-string\">&quot;high&quot;</span>)\n\n<span class=\"hljs-comment\"># Update with same key (overwrites, doesn&#x27;t duplicate)</span>\nstore(<span class=\"hljs-string\">&quot;project&quot;</span>, <span class=\"hljs-string\">&quot;project_synapse_status&quot;</span>, <span class=\"hljs-string\">&quot;v1.5.0 deployed&quot;</span>, priority=<span class=\"hljs-string\">&quot;high&quot;</span>)</code></pre><p><strong>Quy tắc key:</strong></p>\n<ul>\n<li>Phải duy nhất trong (category, mind)</li>\n<li>Sử dụng <code>snake_case</code></li>\n<li>Tiền tố với danh mục để rõ ràng: <code>preference_communication</code>, <code>mistake_npm_version</code></li>\n<li>Giữ ổn định — không thay đổi key sau khi tạo</li>\n</ul>\n<h2>Tag: Dành cho tìm kiếm</h2>\n<p>Tag cho phép lọc và tìm kiếm nhanh:</p>\n<pre><code class=\"hljs language-bash\"><span class=\"hljs-comment\"># Find all memories with tag &quot;docker&quot;</span>\nGET /memory/by-tag?tag=docker\n\n<span class=\"hljs-comment\"># FTS5 search within tagged subset</span>\nGET /memory/search?q=swarm&amp;tag=docker</code></pre><p><strong>Thực hành tốt nhất về tag:</strong></p>\n<ul>\n<li>2-5 tag mỗi bộ nhớ (không gắn tag quá mức)</li>\n<li>Chữ thường để nhất quán</li>\n<li>Sử dụng tên dự án, chủ đề, công nghệ</li>\n<li>Tag không phân biệt chữ hoa chữ thường</li>\n</ul>\n<h2>Mức ưu tiên</h2>\n<table>\n<thead>\n<tr>\n<th>Ưu tiên</th>\n<th>Khi nào sử dụng</th>\n<th>Hành vi thu hồi</th>\n</tr>\n</thead>\n<tbody><tr>\n<td><code>critical</code></td>\n<td>Nhận dạng, pháp lý, không thể đảo ngược</td>\n<td>Luôn ở đầu thu hồi</td>\n</tr>\n<tr>\n<td><code>high</code></td>\n<td>Dự án đang hoạt động, sở thích chính</td>\n<td>Nổi bật trong thu hồi</td>\n</tr>\n<tr>\n<td><code>normal</code></td>\n<td>Hầu hết bộ nhớ (mặc định)</td>\n<td>Thứ tự thu hồi chuẩn</td>\n</tr>\n<tr>\n<td><code>low</code></td>\n<td>Tạm thời, tốt nếu biết</td>\n<td>Có thể được tóm tắt</td>\n</tr>\n</tbody></table>\n<p><code>/memory/recall</code> sắp xếp theo ưu tiên (critical trước), sau đó theo gần đây.</p>\n<h2>Nguồn: User so với Agent</h2>\n<p>Bộ nhớ được gắn <code>source</code>:</p>\n<ul>\n<li><code>user</code> — được lưu bởi con người (qua JWT hoặc giao diện con người)</li>\n<li><code>agent</code> — được lưu bởi LLM agent (qua Mind Key)</li>\n</ul>\n<p>Điều này ảnh hưởng:</p>\n<ul>\n<li><strong>Xác minh</strong>: bộ nhớ <code>user</code> được tự động xác minh, bộ nhớ <code>agent</code> thì không</li>\n<li><strong>Độ tin cậy</strong>: <code>user</code> mặc định 1.0, <code>agent</code> 0.7</li>\n<li><strong>Thu hồi</strong>: <code>/memory/recall</code> đánh dấu bộ nhớ chưa xác minh với &quot;(unverified)&quot;</li>\n</ul>\n<div class=\"callout callout-note\">Hãy đối xử với bộ nhớ nguồn `agent` với sự hoài nghi phù hợp. Chúng có thể\nđược suy luận hoặc giả định thay vì được người dùng phát biểu trực tiếp.</div><h2>Xác minh</h2>\n<p>Cờ <code>verified</code> cho biết con người đã xác nhận bộ nhớ:</p>\n<ul>\n<li>Bộ nhớ <code>user</code>: tự động xác minh (<code>true</code>)</li>\n<li>Bộ nhớ <code>agent</code>: mặc định chưa xác minh (<code>false</code>)</li>\n</ul>\n<p>Xác minh bộ nhớ qua:</p>\n<pre><code class=\"hljs language-bash\">curl -X POST https://synapse.schaefer.zone/memory/mem_001/verify \\\n  -H <span class=\"hljs-string\">&quot;Authorization: Bearer YOUR_JWT&quot;</span></code></pre><div class=\"callout callout-note\">Xác minh yêu cầu JWT (xác thực con người), không phải Mind Key (xác thực\nagent). Điều này đảm bảo chỉ con người có thể đánh dấu bộ nhớ là đã xác minh.</div><h2>Độ tin cậy</h2>\n<p>Trường <code>confidence</code> (0.0 đến 1.0) cho biết bộ nhớ đáng tin cậy đến đâu:</p>\n<ul>\n<li>1.0 — được người dùng phát biểu trực tiếp</li>\n<li>0.7 — được agent suy luận</li>\n<li>0.5 — không chắc chắn, cần xác minh</li>\n<li>0.0 — bị nghi ngờ rõ ràng</li>\n</ul>\n<p>Đặt độ tin cậy khi lưu:</p>\n<pre><code class=\"hljs language-json\"><span class=\"hljs-punctuation\">{</span>\n  <span class=\"hljs-attr\">&quot;category&quot;</span><span class=\"hljs-punctuation\">:</span> <span class=\"hljs-string\">&quot;preference&quot;</span><span class=\"hljs-punctuation\">,</span>\n  <span class=\"hljs-attr\">&quot;key&quot;</span><span class=\"hljs-punctuation\">:</span> <span class=\"hljs-string\">&quot;prefers_dark_mode&quot;</span><span class=\"hljs-punctuation\">,</span>\n  <span class=\"hljs-attr\">&quot;content&quot;</span><span class=\"hljs-punctuation\">:</span> <span class=\"hljs-string\">&quot;User seems to prefer dark mode (based on their IDE screenshots)&quot;</span><span class=\"hljs-punctuation\">,</span>\n  <span class=\"hljs-attr\">&quot;confidence&quot;</span><span class=\"hljs-punctuation\">:</span> <span class=\"hljs-number\">0.5</span><span class=\"hljs-punctuation\">,</span>\n  <span class=\"hljs-attr\">&quot;source&quot;</span><span class=\"hljs-punctuation\">:</span> <span class=\"hljs-string\">&quot;agent&quot;</span>\n<span class=\"hljs-punctuation\">}</span></code></pre><h2>Hết hạn</h2>\n<p>Đặt <code>expires_at</code> cho bộ nhớ nhạy cảm với thời gian:</p>\n<pre><code class=\"hljs language-json\"><span class=\"hljs-punctuation\">{</span>\n  <span class=\"hljs-attr\">&quot;category&quot;</span><span class=\"hljs-punctuation\">:</span> <span class=\"hljs-string\">&quot;context&quot;</span><span class=\"hljs-punctuation\">,</span>\n  <span class=\"hljs-attr\">&quot;key&quot;</span><span class=\"hljs-punctuation\">:</span> <span class=\"hljs-string\">&quot;current_meeting_topic&quot;</span><span class=\"hljs-punctuation\">,</span>\n  <span class=\"hljs-attr\">&quot;content&quot;</span><span class=\"hljs-punctuation\">:</span> <span class=\"hljs-string\">&quot;Discussing Q3 roadmap&quot;</span><span class=\"hljs-punctuation\">,</span>\n  <span class=\"hljs-attr\">&quot;expires_at&quot;</span><span class=\"hljs-punctuation\">:</span> <span class=\"hljs-string\">&quot;2026-06-28T00:00:00Z&quot;</span>\n<span class=\"hljs-punctuation\">}</span></code></pre><p>Bộ nhớ hết hạn không được <code>/memory/recall</code> trả về (nhưng vẫn tồn tại trong DB).\nSử dụng <code>/memory/expiring?within=7d</code> để xem bộ nhớ sắp hết hạn.</p>\n<h2>Vòng đời bộ nhớ</h2>\n<pre><code class=\"hljs language-plaintext\">                  ┌─────────────────┐\n                  │     Create      │\n                  │  POST /memory   │\n                  └────────┬────────┘\n                           │\n                           ▼\n                  ┌─────────────────┐\n                  │     Active      │ ◀──── PUT /memory/:id (update)\n                  │  (in recall)    │\n                  └────────┬────────┘\n                           │\n              ┌────────────┼────────────┐\n              │            │            │\n              ▼            ▼            ▼\n        ┌──────────┐ ┌──────────┐ ┌──────────┐\n        │ Expired  │ │ Verified │ │ Deleted  │\n        │ (in DB)  │ │ (flag)   │ │ (gone)   │\n        └──────────┘ └──────────┘ └──────────┘</code></pre><h2>Hành vi thu hồi</h2>\n<p><code>GET /memory/recall</code> trả về tóm tắt văn bản thuần được tối ưu cho ngữ cảnh LLM:</p>\n<pre><code class=\"hljs language-plaintext\">Mind: Michael&#x27;s Mind\nMemories: 12 total (10 verified, 2 unverified)\n\n[001] identity (CRITICAL) [verified]\n  user_name\n  Michael Schäfer\n  Tags: person, identity\n\n[002] preference (HIGH) [verified]\n  communication_style\n  Prefers concise technical responses\n  Tags: communication\n\n[003] project (HIGH) [unverified]\n  synapse_status\n  v1.5.0 deployed, working on v1.6.0 docs\n  Tags: synapse, deployment\n\n...</code></pre><ul>\n<li>Sắp xếp theo ưu tiên (critical → low), sau đó theo gần đây</li>\n<li>Bộ nhớ chưa xác minh được đánh dấu <code>[unverified]</code></li>\n<li>Tag được bao gồm cho ngữ cảnh</li>\n<li>Văn bản thuần (không cần phân tích JSON)</li>\n</ul>\n<h2>Bước tiếp theo</h2>\n<ul>\n<li><a href=\"/docs/api/memory\">Memory API</a></li>\n<li><a href=\"/docs/guides/memory-best-practices\">Thực hành tốt nhất về bộ nhớ</a></li>\n<li><a href=\"/docs/concepts/fts5-search\">Tìm kiếm FTS5</a></li>\n</ul>\n","urls":{"html":"/docs/concepts/memory-model","text":"/docs/concepts/memory-model?format=text","json":"/docs/concepts/memory-model?format=json","llm":"/docs/concepts/memory-model?format=llm"},"translations_available":["en","zh","hi","es","fr","ar","pt","ru","ja","de","it","ko","nl","pl","tr","sv","vi","th","id","uk"]}