{"title":"แนวทางปฏิบัติที่ดีที่สุดสำหรับ Memory","slug":"memory-best-practices","category":"guides","summary":"วิธีจัดโครงสร้าง memory เพื่อ recall ที่มีประสิทธิภาพ — category, key, tag, priority","audience":["human","llm"],"tags":["guide","memory","best-practices","patterns"],"difficulty":"intermediate","updated":"2026-06-27","word_count":443,"read_minutes":2,"lang":"th","translated":true,"requested_lang":"th","content_markdown":"\n# แนวทางปฏิบัติที่ดีที่สุดสำหรับ Memory\n\nวิธีที่คุณจัดโครงสร้าง memory กำหนดว่ามันจะมีประโยชน์แค่ไหน คู่มือนี้ครอบคลุมรูปแบบสำหรับจัด category, tag และกำหนด priority ของ memory เพื่อให้ LLM recall ข้อมูลที่ถูกต้องในเวลาที่เหมาะสม\n\n## Category: เลือกอันที่เฉพาะเจาะจงที่สุด\n\n| Category | ใช้สำหรับ | ตัวอย่าง |\n|----------|---------|---------|\n| `identity` | ชื่อผู้ใช้, role, ข้อมูลติดต่อ | `\"user_name\": \"Michael Schäfer\"` |\n| `preference` | สิ่งที่ชอบ/ไม่ชอบ, สไตล์การทำงาน | `\"communication\": \"Prefers concise responses\"` |\n| `fact` | fact ที่ตรวจสอบได้ | `\"office_location\": \"Berlin, Germany\"` |\n| `project` | สถานะโปรเจกต์, การตัดสินใจ | `\"project_synapse\": \"v1.5.0 deployed\"` |\n| `skill` | ทักษะผู้ใช้ | `\"skill_python\": \"Advanced, 10+ years\"` |\n| `mistake` | error ในอดีตที่ต้องหลีกเลี่ยง | `\"mistake_npm_version\": \"Always bump version\"` |\n| `context` | context ที่เกี่ยวข้องกับ session | `\"current_focus\": \"Working on docs system\"` |\n| `note` | note อื่น ๆ | `\"note_idea\": \"Try Redis for caching\"` |\n\n> [!TIP]\n> เมื่อไม่แน่ใจ ใช้ `fact` สำหรับข้อมูลที่ตรวจสอบได้ และ `note` สำหรับทุกอย่างอื่น อย่า categorize มากเกินไป — `fact` ที่ชัดเจนดีกว่า `context` ที่สับสน\n\n## Key: identifier ที่มีความหมาย\n\nฟิลด์ `key` เป็น identifier ของ memory ใช้ key ที่มีความหมายและคงที่:\n\n**Key ที่ดี:**\n- `user_name`\n- `project_synapse_status`\n- `preference_communication_style`\n- `mistake_npm_version_bump`\n\n**Key ที่ไม่ดี:**\n- `mem_001` (ไม่มีความหมาย)\n- `temp` (ไม่บรรยาย)\n- `2026-06-27-note` (วันที่ไม่ช่วย recall)\n\n### หลักการตั้งชื่อ key\n\n- `snake_case` (ตัวพิมพ์เล็กด้วย underscore)\n- นำหน้าด้วย category: `preference_*`, `project_*`, `mistake_*`\n- ใช้คำนามที่บรรยาย ไม่ใช่กริยา\n- ความยาวไม่เกิน 50 ตัวอักษร\n\n## Tag: สำหรับการค้นหาและกรอง\n\nTag เปิดใช้งานการกรองและค้นหาที่รวดเร็ว เพิ่ม 2-5 tag ต่อ memory:\n\n```json\n{\n  \"category\": \"project\",\n  \"key\": \"project_synapse_status\",\n  \"content\": \"Synapse v1.5.0 deployed. Next: v1.6.0 with docs system.\",\n  \"tags\": [\"synapse\", \"deployment\", \"status\", \"v1.5.0\"]\n}\n```\n\n### รูปแบบ tag\n\n- **ชื่อโปรเจกต์**: `synapse`, `synapse-mcp`, `synapse-chat`\n- **หัวข้อ**: `deployment`, `ci`, `database`, `auth`\n- **สถานะ**: `active`, `completed`, `blocked`\n- **ตัวบ่งชี้ priority**: `urgent`, `long-term`\n\n> [!NOTE]\n> tag ไม่ sensitive ต่อตัวพิมพ์เล็ก/ใหญ่ ใช้ตัวพิมพ์เล็กเพื่อความสม่ำเสมอ\n\n## Priority: สมจริง\n\n| Priority | ใช้สำหรับ | % ของ Memory |\n|----------|---------|---------------|\n| `critical` | ตัวตนผู้ใช้, ข้อมูลทางกฎหมาย, การตัดสินใจย้อนกลับไม่ได้ | ~5% |\n| `high` | โปรเจกต์ที่ใช้งาน, ค่ากำหนดสำคัญ | ~20% |\n| `normal` | fact, note, context ส่วนใหญ่ | ~65% |\n| `low` | ชั่วคราว, รู้ไว้ก็ดี | ~10% |\n\n> [!WARNING]\n> อย่าทำเครื่องหมายทุกอย่างเป็น `critical` ถ้าทุกอย่าง critical ก็ไม่มีอะไร critical เลย สงวน `critical` สำหรับสิ่งที่จะก่อให้เกิดอันตรายจริงหากลืม\n\n## เมื่อใดเก็บ vs ไม่เก็บ\n\n### เก็บเสมอ\n\n- ตัวตนผู้ใช้ (ชื่อ, email, role)\n- ค่ากำหนดระยะยาว\n- การตัดสินใจและเหตุผลของโปรเจกต์\n- mistake และบทเรียนในอดีต\n- คำมั่นสัญญาที่ให้กับผู้ใช้\n\n### ไม่เก็บ\n\n- state ชั่วคราว (ใช้ variable แทน)\n- ประวัติการสนทนาแบบ verbatim (ระบบแช็ตจัดการสิ่งนี้)\n- ข้อมูล sensitive (รหัสผ่าน, API key)\n- fact ที่ derive ง่าย (วันที่ปัจจุบัน, เนื้อหาไฟล์)\n- context ชั่วคราว (ใช้ category `context` พร้อม priority ต่ำ)\n\n## การอัปเดต Memory\n\nPOST `/memory` ด้วย `category` + `key` เดิมจะอัปเดต memory ที่มีอยู่:\n\n```python\n# Initial store\nstore(\"project\", \"project_synapse_status\", \"v1.4.0 deployed\", priority=\"high\")\n\n# Later: update with same key\nstore(\"project\", \"project_synapse_status\", \"v1.5.0 deployed. CI green.\", priority=\"high\")\n```\n\n> [!TIP]\n> ใช้ key ที่คงที่เพื่อให้อัปเดตได้โดยไม่สร้างซ้ำ LLM ควร POST ซ้ำ key เดิมเมื่อข้อมูลเปลี่ยน ไม่ใช่สร้าง memory ใหม่\n\n## วงจรชีวิต Memory\n\n```\nCreate → Active → Stale → Archive → Delete\n```\n\n- **Create**: POST /memory พร้อม context เต็ม\n- **Active**: recall บ่อย, อัปเดตตามต้องการ\n- **Stale**: ยังเกี่ยวข้องแต่ไม่ได้ใช้งาน (priority ต่ำกว่า?)\n- **Archive**: ตั้ง priority เป็น `low`, เก็บเพื่ออ้างอิงทางประวัติศาสตร์\n- **Delete**: DELETE /memory/:id เมื่อไม่เกี่ยวข้องอีก\n\n### การทำความสะอาดเป็นคาบ\n\n```python\n# Find memories not updated in 90 days\nold_memories = requests.get(\n    f\"{URL}/memory/search?q=*\",\n    headers={\"Authorization\": f\"Bearer {KEY}\"}\n)\n\nfor mem in old_memories[\"results\"]:\n    if is_stale(mem, days=90):\n        # Either delete or lower priority\n        if is_obsolete(mem):\n            delete_memory(mem[\"id\"])\n        else:\n            update_memory(mem[\"id\"], priority=\"low\")\n```\n\n## รูปแบบ: การสืบทอด Memory\n\nสำหรับ context แบบลำดับชั้น (โปรเจกต์ → โปรเจกต์ย่อย → task):\n\n```python\n# Parent project\nstore(\"project\", \"project_synapse\", \"Main Synapse project\", \n      tags=[\"synapse\", \"parent\"], priority=\"high\")\n\n# Sub-project (tags link to parent)\nstore(\"project\", \"project_synapse_docs\", \"Docs system for Synapse\",\n      tags=[\"synapse\", \"docs\", \"synapse-parent\"], priority=\"high\")\n\n# Specific task (tags link to sub-project)\nstore(\"project\", \"task_docs_loader\", \"Implement docs-loader.ts\",\n      tags=[\"synapse\", \"docs\", \"task\"], priority=\"normal\")\n```\n\nLLM สามารถค้นหา `q=synapse+docs` เพื่อหา memory ที่เกี่ยวข้องทั้งหมด\n\n## รูปแบบ: Decision Log\n\nเก็บการตัดสินใจพร้อมเหตุผลเพื่อให้ LLM ไม่ต้องถกเถียงใหม่:\n\n```python\nstore(\"fact\", \"decision_postgres_over_sqlite\",\n      \"Chose PostgreSQL over SQLite for production. Reason: concurrent writes, \"\n      \"FTS5 native support, better backup story. Date: 2026-06-15. Decided by: Michael.\",\n      tags=[\"decision\", \"database\", \"postgres\", \"sqlite\"],\n      priority=\"high\")\n```\n\n## รูปแบบ: การหลีกเลี่ยง Mistake\n\nเก็บ mistake พร้อมคำแนะนำการหลีกเลี่ยงเฉพาะ:\n\n```python\nstore(\"mistake\", \"mistake_forget_version_bump\",\n      \"Forgot to bump package.json version after changes. npm publish failed. \"\n      \"FIX: Always run `npm version patch` before pushing. \"\n      \"CI fails with 'version already exists' if you forget.\",\n      tags=[\"npm\", \"ci\", \"publish\", \"version\"],\n      priority=\"high\")\n```\n\n## รูปแบบที่ควรหลีกเลี่ยง\n\n> [!WARNING]\n> - **เก็บ log การสนทนา** — ระบบแช็ตจัดการสิ่งนี้\n> - **เก็บไฟล์ทั้งหมด** — ใช้ script store หรือ external storage\n> - **เก็บ state ชั่วคราว** — ใช้ variable\n> - **เก็บ secret** — ใช้ environment variable\n> - **ซ้ำ memory** — ใช้ key ที่คงที่\n> - **tag มากเกินไป** — 2-5 tag ต่อ memory เป็นอุดมคติ\n> - **ทุกอย่างเป็น critical** — สมจริงกับ priority\n\n## ขั้นตอนถัดไป\n\n- [Memory API](/docs/api/memory)\n- [Persistent LLM Agent](/docs/guides/persistent-llm-agent)\n- [Memory Tagging Strategy](/docs/llm-cookbook/memory-tagging-strategy)\n","content_html":"<h1>แนวทางปฏิบัติที่ดีที่สุดสำหรับ Memory</h1>\n<p>วิธีที่คุณจัดโครงสร้าง memory กำหนดว่ามันจะมีประโยชน์แค่ไหน คู่มือนี้ครอบคลุมรูปแบบสำหรับจัด category, tag และกำหนด priority ของ memory เพื่อให้ LLM recall ข้อมูลที่ถูกต้องในเวลาที่เหมาะสม</p>\n<h2>Category: เลือกอันที่เฉพาะเจาะจงที่สุด</h2>\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>ชื่อผู้ใช้, role, ข้อมูลติดต่อ</td>\n<td><code>&quot;user_name&quot;: &quot;Michael Schäfer&quot;</code></td>\n</tr>\n<tr>\n<td><code>preference</code></td>\n<td>สิ่งที่ชอบ/ไม่ชอบ, สไตล์การทำงาน</td>\n<td><code>&quot;communication&quot;: &quot;Prefers concise responses&quot;</code></td>\n</tr>\n<tr>\n<td><code>fact</code></td>\n<td>fact ที่ตรวจสอบได้</td>\n<td><code>&quot;office_location&quot;: &quot;Berlin, Germany&quot;</code></td>\n</tr>\n<tr>\n<td><code>project</code></td>\n<td>สถานะโปรเจกต์, การตัดสินใจ</td>\n<td><code>&quot;project_synapse&quot;: &quot;v1.5.0 deployed&quot;</code></td>\n</tr>\n<tr>\n<td><code>skill</code></td>\n<td>ทักษะผู้ใช้</td>\n<td><code>&quot;skill_python&quot;: &quot;Advanced, 10+ years&quot;</code></td>\n</tr>\n<tr>\n<td><code>mistake</code></td>\n<td>error ในอดีตที่ต้องหลีกเลี่ยง</td>\n<td><code>&quot;mistake_npm_version&quot;: &quot;Always bump version&quot;</code></td>\n</tr>\n<tr>\n<td><code>context</code></td>\n<td>context ที่เกี่ยวข้องกับ session</td>\n<td><code>&quot;current_focus&quot;: &quot;Working on docs system&quot;</code></td>\n</tr>\n<tr>\n<td><code>note</code></td>\n<td>note อื่น ๆ</td>\n<td><code>&quot;note_idea&quot;: &quot;Try Redis for caching&quot;</code></td>\n</tr>\n</tbody></table>\n<div class=\"callout callout-ok\">เมื่อไม่แน่ใจ ใช้ `fact` สำหรับข้อมูลที่ตรวจสอบได้ และ `note` สำหรับทุกอย่างอื่น อย่า categorize มากเกินไป — `fact` ที่ชัดเจนดีกว่า `context` ที่สับสน</div><h2>Key: identifier ที่มีความหมาย</h2>\n<p>ฟิลด์ <code>key</code> เป็น identifier ของ memory ใช้ key ที่มีความหมายและคงที่:</p>\n<p><strong>Key ที่ดี:</strong></p>\n<ul>\n<li><code>user_name</code></li>\n<li><code>project_synapse_status</code></li>\n<li><code>preference_communication_style</code></li>\n<li><code>mistake_npm_version_bump</code></li>\n</ul>\n<p><strong>Key ที่ไม่ดี:</strong></p>\n<ul>\n<li><code>mem_001</code> (ไม่มีความหมาย)</li>\n<li><code>temp</code> (ไม่บรรยาย)</li>\n<li><code>2026-06-27-note</code> (วันที่ไม่ช่วย recall)</li>\n</ul>\n<h3>หลักการตั้งชื่อ key</h3>\n<ul>\n<li><code>snake_case</code> (ตัวพิมพ์เล็กด้วย underscore)</li>\n<li>นำหน้าด้วย category: <code>preference_*</code>, <code>project_*</code>, <code>mistake_*</code></li>\n<li>ใช้คำนามที่บรรยาย ไม่ใช่กริยา</li>\n<li>ความยาวไม่เกิน 50 ตัวอักษร</li>\n</ul>\n<h2>Tag: สำหรับการค้นหาและกรอง</h2>\n<p>Tag เปิดใช้งานการกรองและค้นหาที่รวดเร็ว เพิ่ม 2-5 tag ต่อ memory:</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;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. Next: v1.6.0 with docs system.&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;status&quot;</span><span class=\"hljs-punctuation\">,</span> <span class=\"hljs-string\">&quot;v1.5.0&quot;</span><span class=\"hljs-punctuation\">]</span>\n<span class=\"hljs-punctuation\">}</span></code></pre><h3>รูปแบบ tag</h3>\n<ul>\n<li><strong>ชื่อโปรเจกต์</strong>: <code>synapse</code>, <code>synapse-mcp</code>, <code>synapse-chat</code></li>\n<li><strong>หัวข้อ</strong>: <code>deployment</code>, <code>ci</code>, <code>database</code>, <code>auth</code></li>\n<li><strong>สถานะ</strong>: <code>active</code>, <code>completed</code>, <code>blocked</code></li>\n<li><strong>ตัวบ่งชี้ priority</strong>: <code>urgent</code>, <code>long-term</code></li>\n</ul>\n<div class=\"callout callout-note\">tag ไม่ sensitive ต่อตัวพิมพ์เล็ก/ใหญ่ ใช้ตัวพิมพ์เล็กเพื่อความสม่ำเสมอ</div><h2>Priority: สมจริง</h2>\n<table>\n<thead>\n<tr>\n<th>Priority</th>\n<th>ใช้สำหรับ</th>\n<th>% ของ Memory</th>\n</tr>\n</thead>\n<tbody><tr>\n<td><code>critical</code></td>\n<td>ตัวตนผู้ใช้, ข้อมูลทางกฎหมาย, การตัดสินใจย้อนกลับไม่ได้</td>\n<td>~5%</td>\n</tr>\n<tr>\n<td><code>high</code></td>\n<td>โปรเจกต์ที่ใช้งาน, ค่ากำหนดสำคัญ</td>\n<td>~20%</td>\n</tr>\n<tr>\n<td><code>normal</code></td>\n<td>fact, note, context ส่วนใหญ่</td>\n<td>~65%</td>\n</tr>\n<tr>\n<td><code>low</code></td>\n<td>ชั่วคราว, รู้ไว้ก็ดี</td>\n<td>~10%</td>\n</tr>\n</tbody></table>\n<div class=\"callout callout-warn\">อย่าทำเครื่องหมายทุกอย่างเป็น `critical` ถ้าทุกอย่าง critical ก็ไม่มีอะไร critical เลย สงวน `critical` สำหรับสิ่งที่จะก่อให้เกิดอันตรายจริงหากลืม</div><h2>เมื่อใดเก็บ vs ไม่เก็บ</h2>\n<h3>เก็บเสมอ</h3>\n<ul>\n<li>ตัวตนผู้ใช้ (ชื่อ, email, role)</li>\n<li>ค่ากำหนดระยะยาว</li>\n<li>การตัดสินใจและเหตุผลของโปรเจกต์</li>\n<li>mistake และบทเรียนในอดีต</li>\n<li>คำมั่นสัญญาที่ให้กับผู้ใช้</li>\n</ul>\n<h3>ไม่เก็บ</h3>\n<ul>\n<li>state ชั่วคราว (ใช้ variable แทน)</li>\n<li>ประวัติการสนทนาแบบ verbatim (ระบบแช็ตจัดการสิ่งนี้)</li>\n<li>ข้อมูล sensitive (รหัสผ่าน, API key)</li>\n<li>fact ที่ derive ง่าย (วันที่ปัจจุบัน, เนื้อหาไฟล์)</li>\n<li>context ชั่วคราว (ใช้ category <code>context</code> พร้อม priority ต่ำ)</li>\n</ul>\n<h2>การอัปเดต Memory</h2>\n<p>POST <code>/memory</code> ด้วย <code>category</code> + <code>key</code> เดิมจะอัปเดต memory ที่มีอยู่:</p>\n<pre><code class=\"hljs language-python\"><span class=\"hljs-comment\"># Initial 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\"># Later: update with same key</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. CI green.&quot;</span>, priority=<span class=\"hljs-string\">&quot;high&quot;</span>)</code></pre><div class=\"callout callout-ok\">ใช้ key ที่คงที่เพื่อให้อัปเดตได้โดยไม่สร้างซ้ำ LLM ควร POST ซ้ำ key เดิมเมื่อข้อมูลเปลี่ยน ไม่ใช่สร้าง memory ใหม่</div><h2>วงจรชีวิต Memory</h2>\n<pre><code class=\"hljs language-plaintext\">Create → Active → Stale → Archive → Delete</code></pre><ul>\n<li><strong>Create</strong>: POST /memory พร้อม context เต็ม</li>\n<li><strong>Active</strong>: recall บ่อย, อัปเดตตามต้องการ</li>\n<li><strong>Stale</strong>: ยังเกี่ยวข้องแต่ไม่ได้ใช้งาน (priority ต่ำกว่า?)</li>\n<li><strong>Archive</strong>: ตั้ง priority เป็น <code>low</code>, เก็บเพื่ออ้างอิงทางประวัติศาสตร์</li>\n<li><strong>Delete</strong>: DELETE /memory/:id เมื่อไม่เกี่ยวข้องอีก</li>\n</ul>\n<h3>การทำความสะอาดเป็นคาบ</h3>\n<pre><code class=\"hljs language-python\"><span class=\"hljs-comment\"># Find memories not updated in 90 days</span>\nold_memories = requests.get(\n    <span class=\"hljs-string\">f&quot;<span class=\"hljs-subst\">{URL}</span>/memory/search?q=*&quot;</span>,\n    headers={<span class=\"hljs-string\">&quot;Authorization&quot;</span>: <span class=\"hljs-string\">f&quot;Bearer <span class=\"hljs-subst\">{KEY}</span>&quot;</span>}\n)\n\n<span class=\"hljs-keyword\">for</span> mem <span class=\"hljs-keyword\">in</span> old_memories[<span class=\"hljs-string\">&quot;results&quot;</span>]:\n    <span class=\"hljs-keyword\">if</span> is_stale(mem, days=<span class=\"hljs-number\">90</span>):\n        <span class=\"hljs-comment\"># Either delete or lower priority</span>\n        <span class=\"hljs-keyword\">if</span> is_obsolete(mem):\n            delete_memory(mem[<span class=\"hljs-string\">&quot;id&quot;</span>])\n        <span class=\"hljs-keyword\">else</span>:\n            update_memory(mem[<span class=\"hljs-string\">&quot;id&quot;</span>], priority=<span class=\"hljs-string\">&quot;low&quot;</span>)</code></pre><h2>รูปแบบ: การสืบทอด Memory</h2>\n<p>สำหรับ context แบบลำดับชั้น (โปรเจกต์ → โปรเจกต์ย่อย → task):</p>\n<pre><code class=\"hljs language-python\"><span class=\"hljs-comment\"># Parent project</span>\nstore(<span class=\"hljs-string\">&quot;project&quot;</span>, <span class=\"hljs-string\">&quot;project_synapse&quot;</span>, <span class=\"hljs-string\">&quot;Main Synapse project&quot;</span>, \n      tags=[<span class=\"hljs-string\">&quot;synapse&quot;</span>, <span class=\"hljs-string\">&quot;parent&quot;</span>], priority=<span class=\"hljs-string\">&quot;high&quot;</span>)\n\n<span class=\"hljs-comment\"># Sub-project (tags link to parent)</span>\nstore(<span class=\"hljs-string\">&quot;project&quot;</span>, <span class=\"hljs-string\">&quot;project_synapse_docs&quot;</span>, <span class=\"hljs-string\">&quot;Docs system for Synapse&quot;</span>,\n      tags=[<span class=\"hljs-string\">&quot;synapse&quot;</span>, <span class=\"hljs-string\">&quot;docs&quot;</span>, <span class=\"hljs-string\">&quot;synapse-parent&quot;</span>], priority=<span class=\"hljs-string\">&quot;high&quot;</span>)\n\n<span class=\"hljs-comment\"># Specific task (tags link to sub-project)</span>\nstore(<span class=\"hljs-string\">&quot;project&quot;</span>, <span class=\"hljs-string\">&quot;task_docs_loader&quot;</span>, <span class=\"hljs-string\">&quot;Implement docs-loader.ts&quot;</span>,\n      tags=[<span class=\"hljs-string\">&quot;synapse&quot;</span>, <span class=\"hljs-string\">&quot;docs&quot;</span>, <span class=\"hljs-string\">&quot;task&quot;</span>], priority=<span class=\"hljs-string\">&quot;normal&quot;</span>)</code></pre><p>LLM สามารถค้นหา <code>q=synapse+docs</code> เพื่อหา memory ที่เกี่ยวข้องทั้งหมด</p>\n<h2>รูปแบบ: Decision Log</h2>\n<p>เก็บการตัดสินใจพร้อมเหตุผลเพื่อให้ LLM ไม่ต้องถกเถียงใหม่:</p>\n<pre><code class=\"hljs language-python\">store(<span class=\"hljs-string\">&quot;fact&quot;</span>, <span class=\"hljs-string\">&quot;decision_postgres_over_sqlite&quot;</span>,\n      <span class=\"hljs-string\">&quot;Chose PostgreSQL over SQLite for production. Reason: concurrent writes, &quot;</span>\n      <span class=\"hljs-string\">&quot;FTS5 native support, better backup story. Date: 2026-06-15. Decided by: Michael.&quot;</span>,\n      tags=[<span class=\"hljs-string\">&quot;decision&quot;</span>, <span class=\"hljs-string\">&quot;database&quot;</span>, <span class=\"hljs-string\">&quot;postgres&quot;</span>, <span class=\"hljs-string\">&quot;sqlite&quot;</span>],\n      priority=<span class=\"hljs-string\">&quot;high&quot;</span>)</code></pre><h2>รูปแบบ: การหลีกเลี่ยง Mistake</h2>\n<p>เก็บ mistake พร้อมคำแนะนำการหลีกเลี่ยงเฉพาะ:</p>\n<pre><code class=\"hljs language-python\">store(<span class=\"hljs-string\">&quot;mistake&quot;</span>, <span class=\"hljs-string\">&quot;mistake_forget_version_bump&quot;</span>,\n      <span class=\"hljs-string\">&quot;Forgot to bump package.json version after changes. npm publish failed. &quot;</span>\n      <span class=\"hljs-string\">&quot;FIX: Always run `npm version patch` before pushing. &quot;</span>\n      <span class=\"hljs-string\">&quot;CI fails with &#x27;version already exists&#x27; if you forget.&quot;</span>,\n      tags=[<span class=\"hljs-string\">&quot;npm&quot;</span>, <span class=\"hljs-string\">&quot;ci&quot;</span>, <span class=\"hljs-string\">&quot;publish&quot;</span>, <span class=\"hljs-string\">&quot;version&quot;</span>],\n      priority=<span class=\"hljs-string\">&quot;high&quot;</span>)</code></pre><h2>รูปแบบที่ควรหลีกเลี่ยง</h2>\n<div class=\"callout callout-warn\"></div><h2>ขั้นตอนถัดไป</h2>\n<ul>\n<li><a href=\"/docs/api/memory\">Memory API</a></li>\n<li><a href=\"/docs/guides/persistent-llm-agent\">Persistent LLM Agent</a></li>\n<li><a href=\"/docs/llm-cookbook/memory-tagging-strategy\">Memory Tagging Strategy</a></li>\n</ul>\n","urls":{"html":"/docs/guides/memory-best-practices","text":"/docs/guides/memory-best-practices?format=text","json":"/docs/guides/memory-best-practices?format=json","llm":"/docs/guides/memory-best-practices?format=llm"},"translations_available":["en","zh","hi","es","fr","ar","pt","ru","ja","de","it","ko","nl","pl","tr","sv","vi","th","id","uk"]}