{"title":"Stratégie de tagging mémoire","slug":"memory-tagging-strategy","category":"llm-cookbook","summary":"Comment tagger les mémoires pour une recherche et un filtrage efficaces — le système de tagging qui passe à l'échelle.","audience":["llm"],"tags":["cookbook","tagging","memory","strategy"],"difficulty":"intermediate","updated":"2026-06-27","word_count":432,"read_minutes":2,"lang":"fr","translated":true,"requested_lang":"fr","content_markdown":"\n# Stratégie de tagging mémoire\n\nLes tags sont le secret d'une récupération de mémoire qui passe à l'échelle. Ce guide\nmontre comment tagger les mémoires pour que les bonnes reviennent au bon moment.\n\n## Pourquoi les tags comptent\n\nSans tags, vous avez une recherche en texte intégral plate. Avec les tags, vous avez\nune navigation structurée :\n\n```bash\n# Sans tags : tout chercher\nGET /memory/search?q=docker\n\n# Avec tags : filtrer par projet + technologie\nGET /memory/search?q=deployment&tag=synapse&tag=docker\n```\n\nLes tags permettent :\n\n- **Filtrage rapide** — `GET /memory/by-tag?tag=production`\n- **Recherche scopée** — `?q=auth&tag=project-x`\n- **Regroupement** — trouver toutes les mémoires « mistake » d'un projet\n- **Référencement croisé** — les mémoires partageant des tags sont liées\n\n## Schéma de tagging\n\n### Tags de projet\n\nUtilisez les noms de projet comme tags :\n\n```\nsynapse, synapse-mcp, synapse-chat, synapse-sdk\n```\n\n### Tags de technologie\n\nUtilisez les noms de technologie :\n\n```\ndocker, kubernetes, postgres, fastify, react, typescript\n```\n\n### Tags de sujet\n\nUtilisez les catégories de sujet :\n\n```\ndeployment, ci-cd, auth, database, frontend, backend, security\n```\n\n### Tags de statut\n\nUtilisez les indicateurs de statut :\n\n```\nactive, completed, blocked, deprecated\n```\n\n### Tags de type\n\nUtilisez les indicateurs de type :\n\n```\ndecision, mistake, pattern, reference, todo\n```\n\n## Règles de tagging\n\n### Règle 1 : 2-5 tags par mémoire\n\nTrop peu de tags = mauvaise découvrabilité. Trop = du bruit.\n\n```json\n// Bien : 3 tags pertinents\n{ \"tags\": [\"synapse\", \"deployment\", \"docker\"] }\n\n// Mal : 1 tag (trop étroit)\n{ \"tags\": [\"synapse\"] }\n\n// Mal : 10 tags (bruit)\n{ \"tags\": [\"synapse\", \"deployment\", \"docker\", \"vps1\", \"2026\", \"june\", \"ssh\", \"git\", \"main\", \"production\"] }\n```\n\n### Règle 2 : minuscules, avec tirets\n\n```\n✅ ci-cd, api-key, mind-key\n❌ CI-CD, APIKey, MindKey\n```\n\n### Règle 3 : utiliser un vocabulaire cohérent\n\nÉtablissez un vocabulaire de tagging et tenez-vous-y :\n\n```\n# Vocabulaire de projet\nsynapse, synapse-mcp, synapse-chat\n\n# PAS : synapse_project, synapseProject, SYNAPSE\n```\n\n### Règle 4 : tagger avec intention de recherche\n\nDemandez : « Comment vais-je rechercher cette mémoire ? »\n\n```json\n// Stockage d'une décision de déploiement\n{\n  \"content\": \"Decided to use Docker Swarm for Synapse deployment\",\n  \"tags\": [\"synapse\", \"deployment\", \"docker\", \"swarm\", \"decision\"]\n}\n\n// Vous chercherez probablement : ?q=docker+swarm ou ?tag=deployment\n```\n\n## Schémas\n\n### Schéma 1 : projet + sujet\n\n```json\n{ \"tags\": [\"synapse\", \"deployment\"] }\n{ \"tags\": [\"synapse\", \"auth\"] }\n{ \"tags\": [\"synapse-mcp\", \"tools\"] }\n```\n\nRecherche : `?tag=synapse` (toutes les mémoires du projet Synapse)\nRecherche : `?tag=synapse&q=deployment` (mémoires de déploiement dans Synapse)\n\n### Schéma 2 : type + domaine\n\n```json\n{ \"tags\": [\"mistake\", \"deployment\"] }\n{ \"tags\": [\"decision\", \"database\"] }\n{ \"tags\": [\"pattern\", \"auth\"] }\n```\n\nRecherche : `?tag=mistake` (toutes les erreurs)\nRecherche : `?tag=mistake&q=deployment` (erreurs de déploiement)\n\n### Schéma 3 : hiérarchique\n\nPour les sous-projets au sein d'un projet :\n\n```json\n{ \"tags\": [\"synapse\", \"synapse-docs\", \"markdown\"] }\n{ \"tags\": [\"synapse\", \"synapse-mcp\", \"mcp\"] }\n{ \"tags\": [\"synapse\", \"synapse-admin\", \"ui\"] }\n```\n\nRecherche : `?tag=synapse` (tout Synapse)\nRecherche : `?tag=synapse-docs` (juste le sous-projet docs)\n\n### Schéma 4 : suivi de statut\n\n```json\n// Projet actif\n{ \"tags\": [\"synapse\", \"active\"], \"priority\": \"high\" }\n\n// Projet terminé\n{ \"tags\": [\"synapse-v1\", \"completed\"], \"priority\": \"low\" }\n\n// Bloqué\n{ \"tags\": [\"synapse-v2\", \"blocked\"], \"priority\": \"high\" }\n```\n\n## Cas d'usage courants\n\n### Trouver toutes les décisions sur un projet\n\n```bash\ncurl -H \"Authorization: Bearer $KEY\" \\\n     \".../memory/search?q=decision&tag=synapse\"\n```\n\n### Trouver toutes les erreurs dans un domaine\n\n```bash\ncurl -H \"Authorization: Bearer $KEY\" \\\n     \".../memory/search?q=mistake&tag=deployment\"\n```\n\n### Trouver le travail actif\n\n```bash\ncurl -H \"Authorization: Bearer $KEY\" \\\n     \".../memory/by-tag?tag=active\"\n```\n\n### Trouver des mémoires sur une technologie\n\n```bash\ncurl -H \"Authorization: Bearer $KEY\" \\\n     \".../memory/search?q=postgres+performance&tag=database\"\n```\n\n## Maintenance des tags\n\n### Revue périodique\n\n```python\n# Trouver les tags rarement utilisés (candidats au nettoyage)\ntags = requests.get(f\"{URL}/memory/tags\",\n    headers={\"Authorization\": f\"Bearer {KEY}\"}).json()\n\nfor tag, count in tags.items():\n    if count < 2:\n        print(f\"Rare tag: {tag} ({count} memories)\")\n```\n\n### Fusionner les tags\n\nSi vous avez des tags incohérents (`docker` et `Docker`), fusionnez-les :\n\n```python\n# Trouver toutes les mémoires avec le tag \"Docker\"\nmems = requests.get(f\"{URL}/memory/by-tag?tag=Docker\",\n    headers={\"Authorization\": f\"Bearer {KEY}\"}).json()\n\n# Mettre à jour chacune pour utiliser \"docker\" à la place\nfor mem in mems[\"results\"]:\n    tags = [t.lower() for t in mem[\"tags\"]]\n    update_memory(mem[\"id\"], tags=list(set(tags)))\n```\n\n## Bonnes pratiques\n\n> [!TIP]\n> - **Établir le vocabulaire tôt** — des tags cohérents dès le jour 1\n> - **Tagger avec intention de recherche** — comment trouverez-vous cela plus tard ?\n> - **2-5 tags est le sweet spot** — trop peu ou trop est mauvais\n> - **Minuscules + tirets** — `ci-cd` pas `CI/CD`\n> - **Revue périodique** — fusionner les doublons, supprimer les inutilisés\n\n## Prochaines étapes\n\n- [Bonnes pratiques mémoire](/docs/guides/memory-best-practices)\n- [Recherche FTS5](/docs/concepts/fts5-search)\n- [Workflow piloté par les tâches](/docs/llm-cookbook/task-driven-workflow)\n","content_html":"<h1>Stratégie de tagging mémoire</h1>\n<p>Les tags sont le secret d&#39;une récupération de mémoire qui passe à l&#39;échelle. Ce guide\nmontre comment tagger les mémoires pour que les bonnes reviennent au bon moment.</p>\n<h2>Pourquoi les tags comptent</h2>\n<p>Sans tags, vous avez une recherche en texte intégral plate. Avec les tags, vous avez\nune navigation structurée :</p>\n<pre><code class=\"hljs language-bash\"><span class=\"hljs-comment\"># Sans tags : tout chercher</span>\nGET /memory/search?q=docker\n\n<span class=\"hljs-comment\"># Avec tags : filtrer par projet + technologie</span>\nGET /memory/search?q=deployment&amp;tag=synapse&amp;tag=docker</code></pre><p>Les tags permettent :</p>\n<ul>\n<li><strong>Filtrage rapide</strong> — <code>GET /memory/by-tag?tag=production</code></li>\n<li><strong>Recherche scopée</strong> — <code>?q=auth&amp;tag=project-x</code></li>\n<li><strong>Regroupement</strong> — trouver toutes les mémoires « mistake » d&#39;un projet</li>\n<li><strong>Référencement croisé</strong> — les mémoires partageant des tags sont liées</li>\n</ul>\n<h2>Schéma de tagging</h2>\n<h3>Tags de projet</h3>\n<p>Utilisez les noms de projet comme tags :</p>\n<pre><code class=\"hljs language-plaintext\">synapse, synapse-mcp, synapse-chat, synapse-sdk</code></pre><h3>Tags de technologie</h3>\n<p>Utilisez les noms de technologie :</p>\n<pre><code class=\"hljs language-plaintext\">docker, kubernetes, postgres, fastify, react, typescript</code></pre><h3>Tags de sujet</h3>\n<p>Utilisez les catégories de sujet :</p>\n<pre><code class=\"hljs language-plaintext\">deployment, ci-cd, auth, database, frontend, backend, security</code></pre><h3>Tags de statut</h3>\n<p>Utilisez les indicateurs de statut :</p>\n<pre><code class=\"hljs language-plaintext\">active, completed, blocked, deprecated</code></pre><h3>Tags de type</h3>\n<p>Utilisez les indicateurs de type :</p>\n<pre><code class=\"hljs language-plaintext\">decision, mistake, pattern, reference, todo</code></pre><h2>Règles de tagging</h2>\n<h3>Règle 1 : 2-5 tags par mémoire</h3>\n<p>Trop peu de tags = mauvaise découvrabilité. Trop = du bruit.</p>\n<pre><code class=\"hljs language-json\"><span class=\"hljs-comment\">// Bien : 3 tags pertinents</span>\n<span class=\"hljs-punctuation\">{</span> <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;docker&quot;</span><span class=\"hljs-punctuation\">]</span> <span class=\"hljs-punctuation\">}</span>\n\n<span class=\"hljs-comment\">// Mal : 1 tag (trop étroit)</span>\n<span class=\"hljs-punctuation\">{</span> <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-punctuation\">}</span>\n\n<span class=\"hljs-comment\">// Mal : 10 tags (bruit)</span>\n<span class=\"hljs-punctuation\">{</span> <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;docker&quot;</span><span class=\"hljs-punctuation\">,</span> <span class=\"hljs-string\">&quot;vps1&quot;</span><span class=\"hljs-punctuation\">,</span> <span class=\"hljs-string\">&quot;2026&quot;</span><span class=\"hljs-punctuation\">,</span> <span class=\"hljs-string\">&quot;june&quot;</span><span class=\"hljs-punctuation\">,</span> <span class=\"hljs-string\">&quot;ssh&quot;</span><span class=\"hljs-punctuation\">,</span> <span class=\"hljs-string\">&quot;git&quot;</span><span class=\"hljs-punctuation\">,</span> <span class=\"hljs-string\">&quot;main&quot;</span><span class=\"hljs-punctuation\">,</span> <span class=\"hljs-string\">&quot;production&quot;</span><span class=\"hljs-punctuation\">]</span> <span class=\"hljs-punctuation\">}</span></code></pre><h3>Règle 2 : minuscules, avec tirets</h3>\n<pre><code class=\"hljs language-plaintext\">✅ ci-cd, api-key, mind-key\n❌ CI-CD, APIKey, MindKey</code></pre><h3>Règle 3 : utiliser un vocabulaire cohérent</h3>\n<p>Établissez un vocabulaire de tagging et tenez-vous-y :</p>\n<pre><code class=\"hljs language-plaintext\"># Vocabulaire de projet\nsynapse, synapse-mcp, synapse-chat\n\n# PAS : synapse_project, synapseProject, SYNAPSE</code></pre><h3>Règle 4 : tagger avec intention de recherche</h3>\n<p>Demandez : « Comment vais-je rechercher cette mémoire ? »</p>\n<pre><code class=\"hljs language-json\"><span class=\"hljs-comment\">// Stockage d&#x27;une décision de déploiement</span>\n<span class=\"hljs-punctuation\">{</span>\n  <span class=\"hljs-attr\">&quot;content&quot;</span><span class=\"hljs-punctuation\">:</span> <span class=\"hljs-string\">&quot;Decided to use Docker Swarm for Synapse deployment&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;docker&quot;</span><span class=\"hljs-punctuation\">,</span> <span class=\"hljs-string\">&quot;swarm&quot;</span><span class=\"hljs-punctuation\">,</span> <span class=\"hljs-string\">&quot;decision&quot;</span><span class=\"hljs-punctuation\">]</span>\n<span class=\"hljs-punctuation\">}</span>\n\n<span class=\"hljs-comment\">// Vous chercherez probablement : ?q=docker+swarm ou ?tag=deployment</span></code></pre><h2>Schémas</h2>\n<h3>Schéma 1 : projet + sujet</h3>\n<pre><code class=\"hljs language-json\"><span class=\"hljs-punctuation\">{</span> <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-punctuation\">}</span>\n<span class=\"hljs-punctuation\">{</span> <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;auth&quot;</span><span class=\"hljs-punctuation\">]</span> <span class=\"hljs-punctuation\">}</span>\n<span class=\"hljs-punctuation\">{</span> <span class=\"hljs-attr\">&quot;tags&quot;</span><span class=\"hljs-punctuation\">:</span> <span class=\"hljs-punctuation\">[</span><span class=\"hljs-string\">&quot;synapse-mcp&quot;</span><span class=\"hljs-punctuation\">,</span> <span class=\"hljs-string\">&quot;tools&quot;</span><span class=\"hljs-punctuation\">]</span> <span class=\"hljs-punctuation\">}</span></code></pre><p>Recherche : <code>?tag=synapse</code> (toutes les mémoires du projet Synapse)\nRecherche : <code>?tag=synapse&amp;q=deployment</code> (mémoires de déploiement dans Synapse)</p>\n<h3>Schéma 2 : type + domaine</h3>\n<pre><code class=\"hljs language-json\"><span class=\"hljs-punctuation\">{</span> <span class=\"hljs-attr\">&quot;tags&quot;</span><span class=\"hljs-punctuation\">:</span> <span class=\"hljs-punctuation\">[</span><span class=\"hljs-string\">&quot;mistake&quot;</span><span class=\"hljs-punctuation\">,</span> <span class=\"hljs-string\">&quot;deployment&quot;</span><span class=\"hljs-punctuation\">]</span> <span class=\"hljs-punctuation\">}</span>\n<span class=\"hljs-punctuation\">{</span> <span class=\"hljs-attr\">&quot;tags&quot;</span><span class=\"hljs-punctuation\">:</span> <span class=\"hljs-punctuation\">[</span><span class=\"hljs-string\">&quot;decision&quot;</span><span class=\"hljs-punctuation\">,</span> <span class=\"hljs-string\">&quot;database&quot;</span><span class=\"hljs-punctuation\">]</span> <span class=\"hljs-punctuation\">}</span>\n<span class=\"hljs-punctuation\">{</span> <span class=\"hljs-attr\">&quot;tags&quot;</span><span class=\"hljs-punctuation\">:</span> <span class=\"hljs-punctuation\">[</span><span class=\"hljs-string\">&quot;pattern&quot;</span><span class=\"hljs-punctuation\">,</span> <span class=\"hljs-string\">&quot;auth&quot;</span><span class=\"hljs-punctuation\">]</span> <span class=\"hljs-punctuation\">}</span></code></pre><p>Recherche : <code>?tag=mistake</code> (toutes les erreurs)\nRecherche : <code>?tag=mistake&amp;q=deployment</code> (erreurs de déploiement)</p>\n<h3>Schéma 3 : hiérarchique</h3>\n<p>Pour les sous-projets au sein d&#39;un projet :</p>\n<pre><code class=\"hljs language-json\"><span class=\"hljs-punctuation\">{</span> <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;synapse-docs&quot;</span><span class=\"hljs-punctuation\">,</span> <span class=\"hljs-string\">&quot;markdown&quot;</span><span class=\"hljs-punctuation\">]</span> <span class=\"hljs-punctuation\">}</span>\n<span class=\"hljs-punctuation\">{</span> <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;synapse-mcp&quot;</span><span class=\"hljs-punctuation\">,</span> <span class=\"hljs-string\">&quot;mcp&quot;</span><span class=\"hljs-punctuation\">]</span> <span class=\"hljs-punctuation\">}</span>\n<span class=\"hljs-punctuation\">{</span> <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;synapse-admin&quot;</span><span class=\"hljs-punctuation\">,</span> <span class=\"hljs-string\">&quot;ui&quot;</span><span class=\"hljs-punctuation\">]</span> <span class=\"hljs-punctuation\">}</span></code></pre><p>Recherche : <code>?tag=synapse</code> (tout Synapse)\nRecherche : <code>?tag=synapse-docs</code> (juste le sous-projet docs)</p>\n<h3>Schéma 4 : suivi de statut</h3>\n<pre><code class=\"hljs language-json\"><span class=\"hljs-comment\">// Projet actif</span>\n<span class=\"hljs-punctuation\">{</span> <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;active&quot;</span><span class=\"hljs-punctuation\">]</span><span class=\"hljs-punctuation\">,</span> <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\n<span class=\"hljs-comment\">// Projet terminé</span>\n<span class=\"hljs-punctuation\">{</span> <span class=\"hljs-attr\">&quot;tags&quot;</span><span class=\"hljs-punctuation\">:</span> <span class=\"hljs-punctuation\">[</span><span class=\"hljs-string\">&quot;synapse-v1&quot;</span><span class=\"hljs-punctuation\">,</span> <span class=\"hljs-string\">&quot;completed&quot;</span><span class=\"hljs-punctuation\">]</span><span class=\"hljs-punctuation\">,</span> <span class=\"hljs-attr\">&quot;priority&quot;</span><span class=\"hljs-punctuation\">:</span> <span class=\"hljs-string\">&quot;low&quot;</span> <span class=\"hljs-punctuation\">}</span>\n\n<span class=\"hljs-comment\">// Bloqué</span>\n<span class=\"hljs-punctuation\">{</span> <span class=\"hljs-attr\">&quot;tags&quot;</span><span class=\"hljs-punctuation\">:</span> <span class=\"hljs-punctuation\">[</span><span class=\"hljs-string\">&quot;synapse-v2&quot;</span><span class=\"hljs-punctuation\">,</span> <span class=\"hljs-string\">&quot;blocked&quot;</span><span class=\"hljs-punctuation\">]</span><span class=\"hljs-punctuation\">,</span> <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></code></pre><h2>Cas d&#39;usage courants</h2>\n<h3>Trouver toutes les décisions sur un projet</h3>\n<pre><code class=\"hljs language-bash\">curl -H <span class=\"hljs-string\">&quot;Authorization: Bearer <span class=\"hljs-variable\">$KEY</span>&quot;</span> \\\n     <span class=\"hljs-string\">&quot;.../memory/search?q=decision&amp;tag=synapse&quot;</span></code></pre><h3>Trouver toutes les erreurs dans un domaine</h3>\n<pre><code class=\"hljs language-bash\">curl -H <span class=\"hljs-string\">&quot;Authorization: Bearer <span class=\"hljs-variable\">$KEY</span>&quot;</span> \\\n     <span class=\"hljs-string\">&quot;.../memory/search?q=mistake&amp;tag=deployment&quot;</span></code></pre><h3>Trouver le travail actif</h3>\n<pre><code class=\"hljs language-bash\">curl -H <span class=\"hljs-string\">&quot;Authorization: Bearer <span class=\"hljs-variable\">$KEY</span>&quot;</span> \\\n     <span class=\"hljs-string\">&quot;.../memory/by-tag?tag=active&quot;</span></code></pre><h3>Trouver des mémoires sur une technologie</h3>\n<pre><code class=\"hljs language-bash\">curl -H <span class=\"hljs-string\">&quot;Authorization: Bearer <span class=\"hljs-variable\">$KEY</span>&quot;</span> \\\n     <span class=\"hljs-string\">&quot;.../memory/search?q=postgres+performance&amp;tag=database&quot;</span></code></pre><h2>Maintenance des tags</h2>\n<h3>Revue périodique</h3>\n<pre><code class=\"hljs language-python\"><span class=\"hljs-comment\"># Trouver les tags rarement utilisés (candidats au nettoyage)</span>\ntags = requests.get(<span class=\"hljs-string\">f&quot;<span class=\"hljs-subst\">{URL}</span>/memory/tags&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>}).json()\n\n<span class=\"hljs-keyword\">for</span> tag, count <span class=\"hljs-keyword\">in</span> tags.items():\n    <span class=\"hljs-keyword\">if</span> count &lt; <span class=\"hljs-number\">2</span>:\n        <span class=\"hljs-built_in\">print</span>(<span class=\"hljs-string\">f&quot;Rare tag: <span class=\"hljs-subst\">{tag}</span> (<span class=\"hljs-subst\">{count}</span> memories)&quot;</span>)</code></pre><h3>Fusionner les tags</h3>\n<p>Si vous avez des tags incohérents (<code>docker</code> et <code>Docker</code>), fusionnez-les :</p>\n<pre><code class=\"hljs language-python\"><span class=\"hljs-comment\"># Trouver toutes les mémoires avec le tag &quot;Docker&quot;</span>\nmems = requests.get(<span class=\"hljs-string\">f&quot;<span class=\"hljs-subst\">{URL}</span>/memory/by-tag?tag=Docker&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>}).json()\n\n<span class=\"hljs-comment\"># Mettre à jour chacune pour utiliser &quot;docker&quot; à la place</span>\n<span class=\"hljs-keyword\">for</span> mem <span class=\"hljs-keyword\">in</span> mems[<span class=\"hljs-string\">&quot;results&quot;</span>]:\n    tags = [t.lower() <span class=\"hljs-keyword\">for</span> t <span class=\"hljs-keyword\">in</span> mem[<span class=\"hljs-string\">&quot;tags&quot;</span>]]\n    update_memory(mem[<span class=\"hljs-string\">&quot;id&quot;</span>], tags=<span class=\"hljs-built_in\">list</span>(<span class=\"hljs-built_in\">set</span>(tags)))</code></pre><h2>Bonnes pratiques</h2>\n<div class=\"callout callout-ok\"></div><h2>Prochaines étapes</h2>\n<ul>\n<li><a href=\"/docs/guides/memory-best-practices\">Bonnes pratiques mémoire</a></li>\n<li><a href=\"/docs/concepts/fts5-search\">Recherche FTS5</a></li>\n<li><a href=\"/docs/llm-cookbook/task-driven-workflow\">Workflow piloté par les tâches</a></li>\n</ul>\n","urls":{"html":"/docs/llm-cookbook/memory-tagging-strategy","text":"/docs/llm-cookbook/memory-tagging-strategy?format=text","json":"/docs/llm-cookbook/memory-tagging-strategy?format=json","llm":"/docs/llm-cookbook/memory-tagging-strategy?format=llm"},"translations_available":["en","zh","hi","es","fr","ar","pt","ru","ja","de","it","ko","nl","pl","tr","sv","vi","th","id","uk"]}