{"title":"โมเดล Memory","slug":"memory-model","category":"concepts","summary":"วิธีที่ memory ถูกจัดโครงสร้าง — category, key, tag, priority, source, การยืนยัน","audience":["human","llm"],"tags":["concept","memory","model","structure"],"difficulty":"intermediate","updated":"2026-06-27","word_count":575,"read_minutes":3,"lang":"th","translated":true,"requested_lang":"th","content_markdown":"\n# โมเดล Memory\n\nโมเดล memory ของ Synapse ออกแบบมาเพื่อ LLM agent — มีโครงสร้างเพียงพอสำหรับ recall ที่เชื่อถือได้ และยืดหยุ่นพอสำหรับโดเมนใด ๆ\n\n## กายวิภาคของ Memory\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## ฟิลด์\n\n| Field | Type | Required | คำอธิบาย |\n|-------|------|----------|-------------|\n| `id` | string | auto | ID ที่ไม่ซ้ำ (mem_xxx) |\n| `category` | enum | ✅ | หนึ่งใน 8 category |\n| `key` | string | ✅ | identifier ที่คงทย (ใช้สำหรับอัปเดต) |\n| `content` | string | ✅ | เนื้อหา memory (text ใด ๆ) |\n| `tags` | string[] | – | สำหรับการค้นหาและกรอง |\n| `priority` | enum | – | low, normal, high, critical (ค่าเริ่มต้น: normal) |\n| `source` | enum | auto | user, agent (ใครเป็นผู้เก็บ) |\n| `verified` | bool | auto | human ยืนยันหรือยัง? |\n| `confidence` | float | – | 0.0 ถึง 1.0 (ค่าเริ่มต้น: 1.0 สำหรับ user, 0.7 สำหรับ agent) |\n| `expires_at` | timestamp | – | เมื่อไรจะลืม memory นี้ |\n| `mind_id` | string | auto | mind ใดเป็นเจ้าของ |\n| `created_at` | timestamp | auto | เก็บครั้งแรก |\n| `updated_at` | timestamp | auto | แก้ไขล่าสุด |\n\n## Category\n\nแปด category ครอบคลุมกรณีใช้งาน LLM agent ทั่วไป:\n\n| Category | วัตถุประสงค์ | เนื้อหาตัวอย่าง |\n|----------|---------|-----------------|\n| `identity` | ผู้ใช้คือใคร | \"User is Michael Schäfer, software engineer in Berlin\" |\n| `preference` | ค่ากำหนดผู้ใช้ | \"Prefers concise technical responses\" |\n| `fact` | fact ที่ตรวจสอบได้ | \"Office is in Berlin, timezone Europe/Berlin\" |\n| `project` | สถานะโปรเจกต์ | \"Synapse v1.5.0 deployed, working on v1.6.0 docs\" |\n| `skill` | ทักษะผู้ใช้ | \"Advanced Python, 10+ years\" |\n| `mistake` | error ในอดีต | \"Forgot to bump npm version — CI failed\" |\n| `context` | context ของ session | \"Currently reviewing PR #42\" |\n| `note` | note อื่น ๆ | \"Try Redis for caching next sprint\" |\n\n## Key: identifier ที่คงที่\n\nฟิลด์ `key` สำคัญมาก — เป็นวิธีที่คุณอัปเดต memory โดยไม่สร้างซ้ำ\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**กฎของ key:**\n\n- ต้องไม่ซ้ำใน (category, mind)\n- ใช้ `snake_case`\n- นำหน้าด้วย category เพื่อความชัดเจน: `preference_communication`, `mistake_npm_version`\n- รักษาให้คงที่ — อย่าเปลี่ยน key หลังสร้าง\n\n## Tag: สำหรับการค้นหา\n\nTag เปิดใช้งานการกรองและค้นหาที่รวดเร็ว:\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**แนวทางปฏิบัติที่ดีที่สุดสำหรับ tag:**\n\n- 2-5 tag ต่อ memory (อย่า tag มากเกินไป)\n- ตัวพิมพ์เล็กเพื่อความสม่ำเสมอ\n- ใช้ชื่อโปรเจกต์, หัวข้อ, เทคโนโลยี\n- tag ไม่ sensitive ต่อตัวพิมพ์เล็ก/ใหญ่\n\n## ระดับ Priority\n\n| Priority | เมื่อใช้ | พฤติกรรม Recall |\n|----------|-------------|-----------------|\n| `critical` | ตัวตน, ทางกฎหมาย, ย้อนกลับไม่ได้ | อยู่บนสุดของ recall เสมอ |\n| `high` | โปรเจกต์ที่ใช้งานอยู่, ค่ากำหนดหลัก | เด่นใน recall |\n| `normal` | memory ส่วนใหญ่ (ค่าเริ่มต้น) | ลำดับ recall มาตรฐาน |\n| `low` | ชั่วคราว, รู้ไว้ก็ดี | อาจถูกสรุป |\n\n`/memory/recall` เรียงตาม priority (critical ก่อน) แล้วตามความใหม่\n\n## Source: User vs Agent\n\nmemory ถูก tag ด้วย `source`:\n\n- `user` — เก็บโดย human (ผ่าน JWT หรือ human UI)\n- `agent` — เก็บโดย LLM agent (ผ่าน Mind Key)\n\nสิ่งนี้มีผลต่อ:\n\n- **การยืนยัน:** memory `user` ถูก verify อัตโนมัติ, memory `agent` ไม่ได้\n- **ความมั่นใจ:** `user` ค่าเริ่มต้น 1.0, `agent` ค่าเริ่มต้น 0.7\n- **Recall:** `/memory/recall` ทำเครื่องหมาย memory ที่ยังไม่ verify ด้วย \"(unverified)\"\n\n> [!NOTE]\n> ปฏิบัติต่อ memory source `agent` ด้วยความสงสัยพอสมควร อาจเป็นการอนุมานหรือสมมติฐาน ไม่ใช่ที่ผู้ใช้ระบุโดยตรง\n\n## การยืนยัน\n\nflag `verified` บ่งชี้ว่า human ได้ยืนยัน memory แล้ว:\n\n- memory `user`: auto-verified (`true`)\n- memory `agent`: ค่าเริ่มต้น unverified (`false`)\n\nยืนยัน memory ผ่าน:\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> การยืนยันต้องใช้ JWT (human auth) ไม่ใช่ Mind Key (agent auth) สิ่งนี้รับประกันว่าเฉพาะ human เท่านั้นที่ทำเครื่องหมาย memory ว่า verified\n\n## ความมั่นใจ\n\nฟิลด์ `confidence` (0.0 ถึง 1.0) บ่งชี้ความน่าเชื่อถือของ memory:\n\n- 1.0 — ระบุโดยตรงโดยผู้ใช้\n- 0.7 — อนุมานโดย agent\n- 0.5 — ไม่แน่นอน ต้องตรวจสอบ\n- 0.0 — สงสัยอย่างชัดเจน\n\nตั้งค่า confidence เมื่อเก็บ:\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## การหมดอายุ\n\nตั้ง `expires_at` สำหรับ memory ที่ sensitive ต่อเวลา:\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\nmemory ที่หมดอายุจะไม่ถูกส่งกลับโดย `/memory/recall` (แต่ยังมีใน DB) ใช้ `/memory/expiring?within=7d` เพื่อดู memory ที่จะหมดอายุเร็ว ๆ นี้\n\n## วงจรชีวิต Memory\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## พฤติกรรม Recall\n\n`GET /memory/recall` ส่งกลับสรุปแบบ plain-text ที่ปรับให้เหมาะกับ LLM context:\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- เรียงตาม priority (critical → low) แล้วตามความใหม่\n- memory ที่ยังไม่ verify ทำเครื่องหมายด้วย `[unverified]`\n- รวม tag เพื่อ context\n- Plain text (ไม่ต้อง parse JSON)\n\n## ขั้นตอนถัดไป\n\n- [Memory API](/docs/api/memory)\n- [Memory Best Practices](/docs/guides/memory-best-practices)\n- [FTS5 Search](/docs/concepts/fts5-search)\n","content_html":"<h1>โมเดล Memory</h1>\n<p>โมเดล memory ของ Synapse ออกแบบมาเพื่อ LLM agent — มีโครงสร้างเพียงพอสำหรับ recall ที่เชื่อถือได้ และยืดหยุ่นพอสำหรับโดเมนใด ๆ</p>\n<h2>กายวิภาคของ Memory</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>ฟิลด์</h2>\n<table>\n<thead>\n<tr>\n<th>Field</th>\n<th>Type</th>\n<th>Required</th>\n<th>คำอธิบาย</th>\n</tr>\n</thead>\n<tbody><tr>\n<td><code>id</code></td>\n<td>string</td>\n<td>auto</td>\n<td>ID ที่ไม่ซ้ำ (mem_xxx)</td>\n</tr>\n<tr>\n<td><code>category</code></td>\n<td>enum</td>\n<td>✅</td>\n<td>หนึ่งใน 8 category</td>\n</tr>\n<tr>\n<td><code>key</code></td>\n<td>string</td>\n<td>✅</td>\n<td>identifier ที่คงทย (ใช้สำหรับอัปเดต)</td>\n</tr>\n<tr>\n<td><code>content</code></td>\n<td>string</td>\n<td>✅</td>\n<td>เนื้อหา memory (text ใด ๆ)</td>\n</tr>\n<tr>\n<td><code>tags</code></td>\n<td>string[]</td>\n<td>–</td>\n<td>สำหรับการค้นหาและกรอง</td>\n</tr>\n<tr>\n<td><code>priority</code></td>\n<td>enum</td>\n<td>–</td>\n<td>low, normal, high, critical (ค่าเริ่มต้น: normal)</td>\n</tr>\n<tr>\n<td><code>source</code></td>\n<td>enum</td>\n<td>auto</td>\n<td>user, agent (ใครเป็นผู้เก็บ)</td>\n</tr>\n<tr>\n<td><code>verified</code></td>\n<td>bool</td>\n<td>auto</td>\n<td>human ยืนยันหรือยัง?</td>\n</tr>\n<tr>\n<td><code>confidence</code></td>\n<td>float</td>\n<td>–</td>\n<td>0.0 ถึง 1.0 (ค่าเริ่มต้น: 1.0 สำหรับ user, 0.7 สำหรับ agent)</td>\n</tr>\n<tr>\n<td><code>expires_at</code></td>\n<td>timestamp</td>\n<td>–</td>\n<td>เมื่อไรจะลืม memory นี้</td>\n</tr>\n<tr>\n<td><code>mind_id</code></td>\n<td>string</td>\n<td>auto</td>\n<td>mind ใดเป็นเจ้าของ</td>\n</tr>\n<tr>\n<td><code>created_at</code></td>\n<td>timestamp</td>\n<td>auto</td>\n<td>เก็บครั้งแรก</td>\n</tr>\n<tr>\n<td><code>updated_at</code></td>\n<td>timestamp</td>\n<td>auto</td>\n<td>แก้ไขล่าสุด</td>\n</tr>\n</tbody></table>\n<h2>Category</h2>\n<p>แปด category ครอบคลุมกรณีใช้งาน LLM agent ทั่วไป:</p>\n<table>\n<thead>\n<tr>\n<th>Category</th>\n<th>วัตถุประสงค์</th>\n<th>เนื้อหาตัวอย่าง</th>\n</tr>\n</thead>\n<tbody><tr>\n<td><code>identity</code></td>\n<td>ผู้ใช้คือใคร</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>ค่ากำหนดผู้ใช้</td>\n<td>&quot;Prefers concise technical responses&quot;</td>\n</tr>\n<tr>\n<td><code>fact</code></td>\n<td>fact ที่ตรวจสอบได้</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>สถานะโปรเจกต์</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>ทักษะผู้ใช้</td>\n<td>&quot;Advanced Python, 10+ years&quot;</td>\n</tr>\n<tr>\n<td><code>mistake</code></td>\n<td>error ในอดีต</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>context ของ session</td>\n<td>&quot;Currently reviewing PR #42&quot;</td>\n</tr>\n<tr>\n<td><code>note</code></td>\n<td>note อื่น ๆ</td>\n<td>&quot;Try Redis for caching next sprint&quot;</td>\n</tr>\n</tbody></table>\n<h2>Key: identifier ที่คงที่</h2>\n<p>ฟิลด์ <code>key</code> สำคัญมาก — เป็นวิธีที่คุณอัปเดต memory โดยไม่สร้างซ้ำ</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>กฎของ key:</strong></p>\n<ul>\n<li>ต้องไม่ซ้ำใน (category, mind)</li>\n<li>ใช้ <code>snake_case</code></li>\n<li>นำหน้าด้วย category เพื่อความชัดเจน: <code>preference_communication</code>, <code>mistake_npm_version</code></li>\n<li>รักษาให้คงที่ — อย่าเปลี่ยน key หลังสร้าง</li>\n</ul>\n<h2>Tag: สำหรับการค้นหา</h2>\n<p>Tag เปิดใช้งานการกรองและค้นหาที่รวดเร็ว:</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>แนวทางปฏิบัติที่ดีที่สุดสำหรับ tag:</strong></p>\n<ul>\n<li>2-5 tag ต่อ memory (อย่า tag มากเกินไป)</li>\n<li>ตัวพิมพ์เล็กเพื่อความสม่ำเสมอ</li>\n<li>ใช้ชื่อโปรเจกต์, หัวข้อ, เทคโนโลยี</li>\n<li>tag ไม่ sensitive ต่อตัวพิมพ์เล็ก/ใหญ่</li>\n</ul>\n<h2>ระดับ Priority</h2>\n<table>\n<thead>\n<tr>\n<th>Priority</th>\n<th>เมื่อใช้</th>\n<th>พฤติกรรม Recall</th>\n</tr>\n</thead>\n<tbody><tr>\n<td><code>critical</code></td>\n<td>ตัวตน, ทางกฎหมาย, ย้อนกลับไม่ได้</td>\n<td>อยู่บนสุดของ recall เสมอ</td>\n</tr>\n<tr>\n<td><code>high</code></td>\n<td>โปรเจกต์ที่ใช้งานอยู่, ค่ากำหนดหลัก</td>\n<td>เด่นใน recall</td>\n</tr>\n<tr>\n<td><code>normal</code></td>\n<td>memory ส่วนใหญ่ (ค่าเริ่มต้น)</td>\n<td>ลำดับ recall มาตรฐาน</td>\n</tr>\n<tr>\n<td><code>low</code></td>\n<td>ชั่วคราว, รู้ไว้ก็ดี</td>\n<td>อาจถูกสรุป</td>\n</tr>\n</tbody></table>\n<p><code>/memory/recall</code> เรียงตาม priority (critical ก่อน) แล้วตามความใหม่</p>\n<h2>Source: User vs Agent</h2>\n<p>memory ถูก tag ด้วย <code>source</code>:</p>\n<ul>\n<li><code>user</code> — เก็บโดย human (ผ่าน JWT หรือ human UI)</li>\n<li><code>agent</code> — เก็บโดย LLM agent (ผ่าน Mind Key)</li>\n</ul>\n<p>สิ่งนี้มีผลต่อ:</p>\n<ul>\n<li><strong>การยืนยัน:</strong> memory <code>user</code> ถูก verify อัตโนมัติ, memory <code>agent</code> ไม่ได้</li>\n<li><strong>ความมั่นใจ:</strong> <code>user</code> ค่าเริ่มต้น 1.0, <code>agent</code> ค่าเริ่มต้น 0.7</li>\n<li><strong>Recall:</strong> <code>/memory/recall</code> ทำเครื่องหมาย memory ที่ยังไม่ verify ด้วย &quot;(unverified)&quot;</li>\n</ul>\n<div class=\"callout callout-note\">ปฏิบัติต่อ memory source `agent` ด้วยความสงสัยพอสมควร อาจเป็นการอนุมานหรือสมมติฐาน ไม่ใช่ที่ผู้ใช้ระบุโดยตรง</div><h2>การยืนยัน</h2>\n<p>flag <code>verified</code> บ่งชี้ว่า human ได้ยืนยัน memory แล้ว:</p>\n<ul>\n<li>memory <code>user</code>: auto-verified (<code>true</code>)</li>\n<li>memory <code>agent</code>: ค่าเริ่มต้น unverified (<code>false</code>)</li>\n</ul>\n<p>ยืนยัน memory ผ่าน:</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\">การยืนยันต้องใช้ JWT (human auth) ไม่ใช่ Mind Key (agent auth) สิ่งนี้รับประกันว่าเฉพาะ human เท่านั้นที่ทำเครื่องหมาย memory ว่า verified</div><h2>ความมั่นใจ</h2>\n<p>ฟิลด์ <code>confidence</code> (0.0 ถึง 1.0) บ่งชี้ความน่าเชื่อถือของ memory:</p>\n<ul>\n<li>1.0 — ระบุโดยตรงโดยผู้ใช้</li>\n<li>0.7 — อนุมานโดย agent</li>\n<li>0.5 — ไม่แน่นอน ต้องตรวจสอบ</li>\n<li>0.0 — สงสัยอย่างชัดเจน</li>\n</ul>\n<p>ตั้งค่า confidence เมื่อเก็บ:</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>การหมดอายุ</h2>\n<p>ตั้ง <code>expires_at</code> สำหรับ memory ที่ sensitive ต่อเวลา:</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>memory ที่หมดอายุจะไม่ถูกส่งกลับโดย <code>/memory/recall</code> (แต่ยังมีใน DB) ใช้ <code>/memory/expiring?within=7d</code> เพื่อดู memory ที่จะหมดอายุเร็ว ๆ นี้</p>\n<h2>วงจรชีวิต Memory</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>พฤติกรรม Recall</h2>\n<p><code>GET /memory/recall</code> ส่งกลับสรุปแบบ plain-text ที่ปรับให้เหมาะกับ LLM context:</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>เรียงตาม priority (critical → low) แล้วตามความใหม่</li>\n<li>memory ที่ยังไม่ verify ทำเครื่องหมายด้วย <code>[unverified]</code></li>\n<li>รวม tag เพื่อ context</li>\n<li>Plain text (ไม่ต้อง parse JSON)</li>\n</ul>\n<h2>ขั้นตอนถัดไป</h2>\n<ul>\n<li><a href=\"/docs/api/memory\">Memory API</a></li>\n<li><a href=\"/docs/guides/memory-best-practices\">Memory Best Practices</a></li>\n<li><a href=\"/docs/concepts/fts5-search\">FTS5 Search</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"]}