{"title":"نموذج الذاكرة","slug":"memory-model","category":"concepts","summary":"كيف تُنظَّم الذكريات — الفئات، المفاتيح، الوسوم، الأولويات، المصادر، التحقق.","audience":["human","llm"],"tags":["concept","memory","model","structure"],"difficulty":"intermediate","updated":"2026-06-27","word_count":679,"read_minutes":3,"lang":"ar","translated":true,"requested_lang":"ar","content_markdown":"\n# نموذج الذاكرة\n\nنموذج ذاكرة Synapse مصمم لوكلاء LLM — منظّم بما يكفي\nللاستدعاء الموثوق، ومرن بما يكفي لأي مجال.\n\n## تشريح الذاكرة\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| الحقل | النوع | مطلوب | الوصف |\n|-------|------|----------|-------------|\n| `id` | string | تلقائي | معرّف فريد (mem_xxx) |\n| `category` | enum | ✅ | واحدة من 8 فئات |\n| `key` | string | ✅ | مُعرّف ثابت (يُستخدم للتحديثات) |\n| `content` | string | ✅ | محتوى الذاكرة (أي نص) |\n| `tags` | string[] | – | للبحث والتصفية |\n| `priority` | enum | – | low، normal، high، critical (افتراضي: normal) |\n| `source` | enum | تلقائي | user، agent (من خزّنها) |\n| `verified` | bool | تلقائي | هل تحقق منها إنسان؟ |\n| `confidence` | float | – | 0.0 إلى 1.0 (افتراضي: 1.0 للمستخدم، 0.7 للوكيل) |\n| `expires_at` | timestamp | – | متى تُنسى هذه الذاكرة |\n| `mind_id` | string | تلقائي | أي عقل يملكها |\n| `created_at` | timestamp | تلقائي | أول تخزين |\n| `updated_at` | timestamp | تلقائي | آخر تعديل |\n\n## الفئات\n\nثماني فئات تغطي حالات استخدام وكلاء LLM الشائعة:\n\n| الفئة | الغرض | مثال على المحتوى |\n|----------|---------|-----------------|\n| `identity` | من هو المستخدم | \"User is Michael Schäfer, software engineer in Berlin\" |\n| `preference` | تفضيلات المستخدم | \"Prefers concise technical responses\" |\n| `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` | أخطاء سابقة | \"Forgot to bump npm version — CI failed\" |\n| `context` | سياق الجلسة | \"Currently reviewing PR #42\" |\n| `note` | ملاحظات متفرقة | \"Try Redis for caching next sprint\" |\n\n## المفاتيح: مُعرّفات ثابتة\n\nالحقل `key` حاسم — فهو كيف تُحدّث الذكريات دون إنشاء\nمكررات.\n\n```python\n# التخزين الأول\nstore(\"project\", \"project_synapse_status\", \"v1.4.0 deployed\", priority=\"high\")\n\n# التحديث بنفس المفتاح (يستبدل، لا يكرر)\nstore(\"project\", \"project_synapse_status\", \"v1.5.0 deployed\", priority=\"high\")\n```\n\n**قواعد المفتاح:**\n\n- يجب أن يكون فريدًا ضمن (الفئة، العقل)\n- استخدم `snake_case`\n- أضف بادئة الفئة للوضوح: `preference_communication`، `mistake_npm_version`\n- أبقِه ثابتًا — لا تغيّر المفاتيح بعد الإنشاء\n\n## الوسوم: للبحث\n\nتُمكّن الوسوم التصفية والبحث السريع:\n\n```bash\n# إيجاد جميع الذكريات بالوسم \"docker\"\nGET /memory/by-tag?tag=docker\n\n# بحث FTS5 ضمن مجموعة موسومة\nGET /memory/search?q=swarm&tag=docker\n```\n\n**أفضل ممارسات الوسوم:**\n\n- 2-5 وسوم لكل ذاكرة (لا تفرط في الوسم)\n- أحرف صغيرة للاتساق\n- استخدم أسماء المشاريع، المواضيع، التقنيات\n- الوسوم غير حساسة لحالة الأحرف\n\n## مستويات الأولوية\n\n| الأولوية | متى تُستخدم | سلوك الاستدعاء |\n|----------|-------------|-----------------|\n| `critical` | الهوية، القانونية، غير القابلة للتراجع | دائمًا في أعلى الاستدعاء |\n| `high` | المشاريع النشطة، التفضيلات الأساسية | بارز في الاستدعاء |\n| `normal` | معظم الذكريات (افتراضي) | ترتيب استدعاء قياسي |\n| `low` | عابرة، جيد معرفتها | قد تُلخّص |\n\nيُرتّب `/memory/recall` حسب الأولوية (critical أولًا)، ثم حسب الأحدث.\n\n## المصدر: المستخدم مقابل الوكيل\n\nتُوسم الذكريات بـ `source`:\n\n- `user` — خزّنها إنسان (عبر JWT أو واجهة الإنسان)\n- `agent` — خزّنها وكيل LLM (عبر Mind Key)\n\nيؤثر هذا على:\n\n- **التحقق**: ذكريات `user` مُتحقّق منها تلقائيًا، ذكريات `agent` لا\n- **الثقة**: `user` افتراضي 1.0، `agent` 0.7\n- **الاستدعاء**: يعلّم `/memory/recall` الذكريات غير المُتحقّق منها بـ \"(unverified)\"\n\n> [!NOTE]\n> تعامل مع ذكريات المصدر `agent` بقدر مناسب من الشك. قد تكون\n> مستنتجة أو مفترضة بدلًا من ذكرها مباشرة من المستخدم.\n\n## التحقق\n\nتشير علامة `verified` إلى أن إنسانًا أكّد الذاكرة:\n\n- ذكريات `user`: مُتحقّق منها تلقائيًا (`true`)\n- ذكريات `agent`: غير مُتحقّق منها افتراضيًا (`false`)\n\nتحقق من الذكريات عبر:\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 (مصادقة الإنسان)، وليس Mind Key (مصادقة الوكيل). هذا\n> يضمن أن البشر فقط يمكنهم تعليم الذكريات كمُتحقّق منها.\n\n## الثقة\n\nيشير الحقل `confidence` (0.0 إلى 1.0) إلى موثوقية الذاكرة:\n\n- 1.0 — ذُكرت مباشرة من المستخدم\n- 0.7 — مستنتجة بواسطة الوكيل\n- 0.5 — غير مؤكدة، تحتاج تحققًا\n- 0.0 — مشكوك فيها صراحة\n\nعيّن الثقة عند التخزين:\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` للذكريات الحساسة للوقت:\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\nالذكريات المنتهية لا يُرجعها `/memory/recall` (لكنها لا تزال موجودة في DB).\nاستخدم `/memory/expiring?within=7d` لرؤية الذكريات التي تنتهي قريبًا.\n\n## دورة حياة الذاكرة\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## سلوك الاستدعاء\n\nيُرجع `GET /memory/recall` ملخصًا نصيًا عاديًا مُحسّنًا لسياق 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- مُرتّب حسب الأولوية (critical → low)، ثم حسب الأحدث\n- الذكريات غير المُتحقّق منها معلّمة بـ `[unverified]`\n- الوسوم مضمنة للسياق\n- نص عادي (لا حاجة لتحليل JSON)\n\n## الخطوات التالية\n\n- [Memory API](/docs/api/memory)\n- [أفضل ممارسات الذاكرة](/docs/guides/memory-best-practices)\n- [بحث FTS5](/docs/concepts/fts5-search)\n","content_html":"<h1>نموذج الذاكرة</h1>\n<p>نموذج ذاكرة Synapse مصمم لوكلاء LLM — منظّم بما يكفي\nللاستدعاء الموثوق، ومرن بما يكفي لأي مجال.</p>\n<h2>تشريح الذاكرة</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>الحقل</th>\n<th>النوع</th>\n<th>مطلوب</th>\n<th>الوصف</th>\n</tr>\n</thead>\n<tbody><tr>\n<td><code>id</code></td>\n<td>string</td>\n<td>تلقائي</td>\n<td>معرّف فريد (mem_xxx)</td>\n</tr>\n<tr>\n<td><code>category</code></td>\n<td>enum</td>\n<td>✅</td>\n<td>واحدة من 8 فئات</td>\n</tr>\n<tr>\n<td><code>key</code></td>\n<td>string</td>\n<td>✅</td>\n<td>مُعرّف ثابت (يُستخدم للتحديثات)</td>\n</tr>\n<tr>\n<td><code>content</code></td>\n<td>string</td>\n<td>✅</td>\n<td>محتوى الذاكرة (أي نص)</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>تلقائي</td>\n<td>user، agent (من خزّنها)</td>\n</tr>\n<tr>\n<td><code>verified</code></td>\n<td>bool</td>\n<td>تلقائي</td>\n<td>هل تحقق منها إنسان؟</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 للمستخدم، 0.7 للوكيل)</td>\n</tr>\n<tr>\n<td><code>expires_at</code></td>\n<td>timestamp</td>\n<td>–</td>\n<td>متى تُنسى هذه الذاكرة</td>\n</tr>\n<tr>\n<td><code>mind_id</code></td>\n<td>string</td>\n<td>تلقائي</td>\n<td>أي عقل يملكها</td>\n</tr>\n<tr>\n<td><code>created_at</code></td>\n<td>timestamp</td>\n<td>تلقائي</td>\n<td>أول تخزين</td>\n</tr>\n<tr>\n<td><code>updated_at</code></td>\n<td>timestamp</td>\n<td>تلقائي</td>\n<td>آخر تعديل</td>\n</tr>\n</tbody></table>\n<h2>الفئات</h2>\n<p>ثماني فئات تغطي حالات استخدام وكلاء LLM الشائعة:</p>\n<table>\n<thead>\n<tr>\n<th>الفئة</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>حقائق قابلة للتحقق</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>أخطاء سابقة</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>سياق الجلسة</td>\n<td>&quot;Currently reviewing PR #42&quot;</td>\n</tr>\n<tr>\n<td><code>note</code></td>\n<td>ملاحظات متفرقة</td>\n<td>&quot;Try Redis for caching next sprint&quot;</td>\n</tr>\n</tbody></table>\n<h2>المفاتيح: مُعرّفات ثابتة</h2>\n<p>الحقل <code>key</code> حاسم — فهو كيف تُحدّث الذكريات دون إنشاء\nمكررات.</p>\n<pre><code class=\"hljs language-python\"><span class=\"hljs-comment\"># التخزين الأول</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\"># التحديث بنفس المفتاح (يستبدل، لا يكرر)</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>قواعد المفتاح:</strong></p>\n<ul>\n<li>يجب أن يكون فريدًا ضمن (الفئة، العقل)</li>\n<li>استخدم <code>snake_case</code></li>\n<li>أضف بادئة الفئة للوضوح: <code>preference_communication</code>، <code>mistake_npm_version</code></li>\n<li>أبقِه ثابتًا — لا تغيّر المفاتيح بعد الإنشاء</li>\n</ul>\n<h2>الوسوم: للبحث</h2>\n<p>تُمكّن الوسوم التصفية والبحث السريع:</p>\n<pre><code class=\"hljs language-bash\"><span class=\"hljs-comment\"># إيجاد جميع الذكريات بالوسم &quot;docker&quot;</span>\nGET /memory/by-tag?tag=docker\n\n<span class=\"hljs-comment\"># بحث FTS5 ضمن مجموعة موسومة</span>\nGET /memory/search?q=swarm&amp;tag=docker</code></pre><p><strong>أفضل ممارسات الوسوم:</strong></p>\n<ul>\n<li>2-5 وسوم لكل ذاكرة (لا تفرط في الوسم)</li>\n<li>أحرف صغيرة للاتساق</li>\n<li>استخدم أسماء المشاريع، المواضيع، التقنيات</li>\n<li>الوسوم غير حساسة لحالة الأحرف</li>\n</ul>\n<h2>مستويات الأولوية</h2>\n<table>\n<thead>\n<tr>\n<th>الأولوية</th>\n<th>متى تُستخدم</th>\n<th>سلوك الاستدعاء</th>\n</tr>\n</thead>\n<tbody><tr>\n<td><code>critical</code></td>\n<td>الهوية، القانونية، غير القابلة للتراجع</td>\n<td>دائمًا في أعلى الاستدعاء</td>\n</tr>\n<tr>\n<td><code>high</code></td>\n<td>المشاريع النشطة، التفضيلات الأساسية</td>\n<td>بارز في الاستدعاء</td>\n</tr>\n<tr>\n<td><code>normal</code></td>\n<td>معظم الذكريات (افتراضي)</td>\n<td>ترتيب استدعاء قياسي</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> حسب الأولوية (critical أولًا)، ثم حسب الأحدث.</p>\n<h2>المصدر: المستخدم مقابل الوكيل</h2>\n<p>تُوسم الذكريات بـ <code>source</code>:</p>\n<ul>\n<li><code>user</code> — خزّنها إنسان (عبر JWT أو واجهة الإنسان)</li>\n<li><code>agent</code> — خزّنها وكيل LLM (عبر Mind Key)</li>\n</ul>\n<p>يؤثر هذا على:</p>\n<ul>\n<li><strong>التحقق</strong>: ذكريات <code>user</code> مُتحقّق منها تلقائيًا، ذكريات <code>agent</code> لا</li>\n<li><strong>الثقة</strong>: <code>user</code> افتراضي 1.0، <code>agent</code> 0.7</li>\n<li><strong>الاستدعاء</strong>: يعلّم <code>/memory/recall</code> الذكريات غير المُتحقّق منها بـ &quot;(unverified)&quot;</li>\n</ul>\n<div class=\"callout callout-note\">تعامل مع ذكريات المصدر `agent` بقدر مناسب من الشك. قد تكون\nمستنتجة أو مفترضة بدلًا من ذكرها مباشرة من المستخدم.</div><h2>التحقق</h2>\n<p>تشير علامة <code>verified</code> إلى أن إنسانًا أكّد الذاكرة:</p>\n<ul>\n<li>ذكريات <code>user</code>: مُتحقّق منها تلقائيًا (<code>true</code>)</li>\n<li>ذكريات <code>agent</code>: غير مُتحقّق منها افتراضيًا (<code>false</code>)</li>\n</ul>\n<p>تحقق من الذكريات عبر:</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 (مصادقة الإنسان)، وليس Mind Key (مصادقة الوكيل). هذا\nيضمن أن البشر فقط يمكنهم تعليم الذكريات كمُتحقّق منها.</div><h2>الثقة</h2>\n<p>يشير الحقل <code>confidence</code> (0.0 إلى 1.0) إلى موثوقية الذاكرة:</p>\n<ul>\n<li>1.0 — ذُكرت مباشرة من المستخدم</li>\n<li>0.7 — مستنتجة بواسطة الوكيل</li>\n<li>0.5 — غير مؤكدة، تحتاج تحققًا</li>\n<li>0.0 — مشكوك فيها صراحة</li>\n</ul>\n<p>عيّن الثقة عند التخزين:</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> للذكريات الحساسة للوقت:</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>الذكريات المنتهية لا يُرجعها <code>/memory/recall</code> (لكنها لا تزال موجودة في DB).\nاستخدم <code>/memory/expiring?within=7d</code> لرؤية الذكريات التي تنتهي قريبًا.</p>\n<h2>دورة حياة الذاكرة</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>سلوك الاستدعاء</h2>\n<p>يُرجع <code>GET /memory/recall</code> ملخصًا نصيًا عاديًا مُحسّنًا لسياق 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>مُرتّب حسب الأولوية (critical → low)، ثم حسب الأحدث</li>\n<li>الذكريات غير المُتحقّق منها معلّمة بـ <code>[unverified]</code></li>\n<li>الوسوم مضمنة للسياق</li>\n<li>نص عادي (لا حاجة لتحليل 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\">أفضل ممارسات الذاكرة</a></li>\n<li><a href=\"/docs/concepts/fts5-search\">بحث 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"]}