Logo di Ai Agent Memory Systems

Ai Agent Memory Systems

Community
j4flmao
ai-agent-memory-systems

Use this skill when the user says 'agent memory', 'long-term memory', 'conversation memory', 'remember user preferences', 'context window full', 'summarize history', 'episodic memory', 'semantic memory'. Designs what an agent keeps in its context window, what it stores externally, how it writes and retrieves memories, and how memories expire. Do NOT use for: document RAG pipelines (ai/llm-engineering/rag-architecture), vector DB operations (data or ai vector-database skills), or the agent loop itself (ai/ai-agents/core-architectures).

Panoramica

Autorej4flmao
Repositoryagent-skills
Nome della skillai-agent-memory-systems
Stelle
41
Fork
6
File inclusi
Solo istruzioni
LicenzaMIT
Link
  • Istruzioni in Markdown

    Un file SKILL.md che il modello carica quando serve, consumando token solo quando una richiesta è effettivamente pertinente.

  • Funziona con qualsiasi LLM

    Le skill IA sono in semplice Markdown, non in codice specifico di un fornitore, quindi funzionano con GPT, Claude, Gemini, Grok o un modello locale.

  • Tutto nelle istruzioni

    Tutto ciò che serve al modello è nelle istruzioni: nessun file aggiuntivo da sincronizzare.

  • Open source

    Pubblicata da j4flmao su GitHub. Leggi i sorgenti prima di installarla.

Installazione

Installa la skill IA Ai Agent Memory Systems in TypingMind per usarla con qualsiasi LLM, oppure copiala in un altro agente in grado di leggere SKILL.md.

1

Installa in TypingMind

TypingMind installa una skill direttamente dalla sua cartella GitHub: legge SKILL.md, raccoglie i file delle risorse e salva il risultato in locale.

  1. Apri l'app e vai su Plugin → Skill.
  2. Scegli "Installa da GitHub".
  3. Incolla l'URL della cartella della skill riportato qui sotto e conferma.
    https://github.com/j4flmao/agent-skills/tree/main/skills/ai/ai-agents/memory-systems
  4. Attiva la skill in ogni chat in cui vuoi averla a disposizione.
Plugin → Skill → Nuova skill → Da URL GitHub, poi incolla l'URL della cartella e premi Continua.
2

Installa in un altro agente

Qualsiasi agente che legge il formato Agent Skills può usare questa skill: copia la cartella nella cartella delle skill di quell'agente.

Claude Code — .claude/skills
git clone --depth 1 https://github.com/j4flmao/agent-skills.git /tmp/agent-skills
mkdir -p .claude/skills
cp -r /tmp/agent-skills/skills/ai/ai-agents/memory-systems .claude/skills/ai-agent-memory-systems
Dopo la copia, riavvia Claude Code per caricare la nuova skill.

Usala in TypingMind

Attiva Ai Agent Memory Systems in qualsiasi chat di TypingMind e al resto pensa il modello. Il nome e la descrizione della skill sono nel prompt di sistema e, non appena arriva una richiesta pertinente, il modello carica da solo le istruzioni complete: non devi mai richiamarla manualmente e non consuma token finché non viene effettivamente usata.

Il modello carica automaticamente Ai Agent Memory Systems non appena riceve una richiesta pertinente.

Funziona con qualsiasi modello IA

Le skill IA sono semplici istruzioni in Markdown, non codice specifico di un fornitore, quindi Ai Agent Memory Systems non è vincolata al modello per cui è stata scritta. Installala una sola volta in TypingMind e usala con GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama o un modello locale che esegui tu, sempre con le tue chiavi API.

  • Caricata solo quando serve

    Il prompt di sistema contiene solo il nome e la descrizione. Le istruzioni vengono recuperate alla prima richiesta pertinente, quindi una skill inutilizzata non costa nulla.

  • Cambia modello durante la chat

    Poiché la skill è composta da istruzioni e non da codice, continua a funzionare anche se cambi modello: il nuovo modello legge lo stesso file SKILL.md.

Istruzioni della skill

Questo è il contenuto di SKILL.md che il modello carica. Leggilo prima dell'installazione: una skill è un insieme di istruzioni che il tuo modello seguirà.

Agent Memory Systems

Purpose

An LLM is stateless between calls; anything the agent "remembers" is either placed in the context window or retrieved into it. Memory design is therefore a set of policies: what stays verbatim in context, what gets compressed, what is persisted to external stores, how it is retrieved, and when it is updated or deleted. Bad memory design shows up as forgotten constraints, contradictory facts, and leaked data between users.

Agent Protocol

Trigger

"agent memory", "long-term memory", "remember across sessions", "context window full", "conversation summarization", "user profile memory", "episodic memory", "memory leaks between users".

Input Context

  • Session length and turn count; model context size.
  • What must persist across sessions (preferences, facts, past task outcomes).
  • Privacy/tenancy constraints and retention requirements.
  • Existing storage (Postgres, Redis, vector DB).

Output Artifact

Memory design: tiers, schemas, write/read/eviction policies, isolation and retention rules.

Response Format

Working memory: pinned={...} window={n turns} compression={summary|drop}
Semantic store: {schema} retrieval={hybrid+rerank} k={n}
Episodic store: {schema} written on={event}
Profile/facts: {key-value schema} update={upsert w/ provenance}
Isolation: {tenant/user key}  Retention: {ttl}  Deletion: {API}

Completion Criteria

  • Pinned context (instructions, goal, constraints) never evicted.
  • Every stored memory carries owner id, source, timestamp.
  • Retrieval is scoped by owner before similarity search.
  • Conflicting facts resolved by recency/provenance, not duplicated.
  • User-facing delete path exists.

Memory Tiers

TierLives inContentRetrievalTypical store
WorkingContext windowSystem prompt, goal, plan, recent turns, tool resultsAlways presentIn-process
SemanticExternalFacts, documents, user profileSimilarity + filtersPostgres/pgvector, vector DB, KV
EpisodicExternalPast tasks: what was tried, outcome, lessonBy task similarity or recencyTable + embeddings
ProceduralPrompt/codeLearned instructions, tool usage rulesLoaded at startVersioned prompt files

Semantic memory answers "what is true"; episodic memory answers "what happened when I tried". Raw transcripts are not episodic memory: distill them into short records (task, actions, outcome, lesson).

Working Memory Management

Context is finite and long contexts degrade attention to the middle, so budget it explicitly:

[pinned]     system prompt, tool definitions, goal, constraints     ~fixed
[state]      current plan, key facts extracted so far              small, rewritten each step
[retrieved]  top-k memories for this step                          capped tokens
[window]     last N turns verbatim                                 sliding
[summary]    rolling summary of older turns                        rewritten when window overflows
python
from __future__ import annotations

from dataclasses import dataclass, field


@dataclass
class WorkingMemory:
    pinned: str
    max_window_tokens: int
    window: list[dict] = field(default_factory=list)
    summary: str = ""

    def add(self, message: dict, count_tokens, summarize) -> None:
        self.window.append(message)
        while sum(count_tokens(m["content"]) for m in self.window) > self.max_window_tokens:
            # Evict oldest turns into the rolling summary; never touch pinned content.
            oldest = self.window[:4]
            self.window = self.window[4:]
            self.summary = summarize(self.summary, oldest)

    def render(self, retrieved: list[str]) -> list[dict]:
        preamble = self.pinned
        if self.summary:
            preamble += f"\n\n<conversation_summary>\n{self.summary}\n</conversation_summary>"
        if retrieved:
            preamble += "\n\n<memories>\n" + "\n".join(retrieved) + "\n</memories>"
        return [{"role": "system", "content": preamble}, *self.window]

Keep tool-call/tool-result pairs together when evicting; most APIs reject a tool result whose call was removed.

Long-Term Memory Store

sql
CREATE TABLE agent_memory (
    id            BIGINT GENERATED ALWAYS AS IDENTITY PRIMARY KEY,
    tenant_id     TEXT NOT NULL,
    user_id       TEXT NOT NULL,
    kind          TEXT NOT NULL CHECK (kind IN ('fact', 'preference', 'episode')),
    subject_key   TEXT,                       -- e.g. 'preferred_language' for upserts
    content       TEXT NOT NULL,
    embedding     vector(1024),               -- pgvector; dimension = your embedding model
    source        TEXT NOT NULL,              -- message id / tool / user-stated
    confidence    REAL NOT NULL DEFAULT 1.0,
    created_at    TIMESTAMPTZ NOT NULL DEFAULT now(),
    expires_at    TIMESTAMPTZ,
    deleted_at    TIMESTAMPTZ,
    UNIQUE (tenant_id, user_id, kind, subject_key)
);
CREATE INDEX ON agent_memory USING hnsw (embedding vector_cosine_ops);
CREATE INDEX ON agent_memory USING gin (to_tsvector('english', content));

Retrieval: filter by tenant_id, user_id, deleted_at IS NULL, expires_at first; then hybrid search (vector + full-text, fused with reciprocal rank fusion) and rerank; inject only the top few with their timestamps so the model can judge freshness.

Write Policies

PolicyWhenRisk
Explicit ("remember that...")User asksLow
Extraction after each sessionBackground job extracts facts/preferencesHallucinated or sensitive facts stored
Episode on task completionStore task, outcome, lessonStoring failed approaches as advice
Agent-initiated tool (save_memory)Model decidesNoise, prompt-injected writes

Rules: upsert by subject_key so a new preference replaces the old one; store provenance; never persist secrets or content from untrusted documents as "facts" without review; treat retrieved memories as data, not instructions.

Anti-Patterns

  • Stuffing the entire history until the context limit; cost and latency balloon and quality drops.
  • Similarity search without owner filters: cross-user leakage.
  • Append-only facts with no conflict resolution ("likes tea", "likes coffee", both returned).
  • Summaries that drop constraints ("budget under $500"); pin constraints in state instead.
  • Memories with no expiry or deletion path (privacy and GDPR issues).

Checklist

  • Token budget per working-memory section.
  • Rolling summary keeps decisions, constraints, open questions.
  • Store schema with owner, kind, provenance, timestamps, expiry, soft delete.
  • Scoped hybrid retrieval with reranking; k and token cap set.
  • Upsert semantics for facts/preferences.
  • Deletion and export endpoints; retention job.
  • Eval: questions that require recalling facts from earlier sessions.

References

  • Packer et al., "MemGPT: Towards LLMs as Operating Systems" (2023) — tiered memory paging.
  • Park et al., "Generative Agents" (UIST 2023) — recency/importance/relevance retrieval scoring.
  • Liu et al., "Lost in the Middle" (TACL 2024) — position effects in long contexts.

Shared References

Additional reference material for this skill, stored outside its own references/ folder.

  • ../../../harness-engineering/context-engineering/references/context-drift-mitigation.md — Context Drift Mitigation
  • ../../../harness-engineering/context-engineering/references/dynamic-injection-patterns.md — Dynamic Injection Patterns
  • ../../../harness-engineering/context-engineering/references/memory-retrieval-architectures.md — Memory Retrieval Architectures
  • ../../../harness-engineering/context-engineering/references/priority-scoring-algorithms.md — Priority Scoring Algorithms
  • ../../../harness-engineering/context-engineering/references/prompt-token-optimization.md — Prompt Token Optimization

Domande frequenti

Cosa fa la skill IA Ai Agent Memory Systems?

Use this skill when the user says 'agent memory', 'long-term memory', 'conversation memory', 'remember user preferences', 'context window full', 'summarize history', 'episodic memory', 'semantic memory'. Designs what an agent keeps in its context window, what it stores externally, how it writes and retrieves memories, and how memories expire. Do NOT use for: document RAG pipelines (ai/llm-engineering/rag-architecture), vector DB operations (data or ai vector-database skills), or the agent loop itself (ai/ai-agents/core-architectures).

Perché usare Ai Agent Memory Systems su TypingMind?

Perché la installi una volta e la usi con qualsiasi modello. Ai Agent Memory Systems è scritta in semplice Markdown anziché in codice specifico di un fornitore, quindi la stessa skill funziona con GPT-5, Claude, Gemini, Grok o un modello locale, e puoi cambiare modello durante la chat senza che smetta di funzionare. TypingMind usa le tue chiavi API, quindi paghi direttamente i fornitori anziché un abbonamento per posto utente, e le tue skill e chat restano nel tuo spazio di archiviazione.

Come installo Ai Agent Memory Systems in TypingMind?

Apri Plugin → Skill → Installa da GitHub in TypingMind e incolla https://github.com/j4flmao/agent-skills/tree/main/skills/ai/ai-agents/memory-systems. TypingMind legge il file SKILL.md e installa la skill, che puoi abilitare per ogni singola chat.

Quali modelli IA possono usare Ai Agent Memory Systems?

Qualsiasi modello che colleghi in TypingMind. Le skill IA sono semplici istruzioni in Markdown anziché codice specifico di un fornitore, quindi GPT, Claude, Gemini, Grok e i modelli locali possono tutti caricare questa skill quando una richiesta corrisponde al suo scopo.

Quanti modelli IA posso usare con Ai Agent Memory Systems?

Quanti ne vuoi. Se un modello supporta le skill, puoi usarlo con Ai Agent Memory Systems: GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama e molti altri, tutti su TypingMind con le tue chiavi API.

La skill IA Ai Agent Memory Systems è gratuita?

Sì. È pubblicata su GitHub da j4flmao con licenza MIT. Paghi solo il tuo fornitore IA per i token che usi.

Cosa sono le skill IA?

Una skill IA è un pacchetto di istruzioni riutilizzabili che insegna a un modello IA come svolgere un'attività specifica. Segue il formato aperto Agent Skills: un file SKILL.md con un nome e una descrizione, più eventuali script, modelli o file di riferimento di cui il modello potrebbe aver bisogno. Il modello legge le istruzioni solo quando la tua richiesta corrisponde alla skill, quindi una skill installata non comporta costi finché non viene usata.

In cosa si differenziano le skill IA dai plugin o dai server MCP?

Un plugin o un server MCP fornisce a un modello nuovi strumenti da richiamare: codice che viene eseguito da qualche parte e restituisce un risultato. Una skill IA, invece, fornisce al modello conoscenze e procedure: come affrontare un'attività, quali passaggi seguire e quali caratteristiche deve avere un buon output. Le skill sono semplici istruzioni in Markdown, quindi non richiedono server, chiavi API né ambienti di esecuzione e funzionano con qualsiasi modello.

Vedi tutti

Crea subito la tua area di lavoro IA

Iscriviti alla nostra newsletter per ricevere aggiornamenti sulle nuove funzionalità e sulle prossime iniziative a premi 👇