Ai Agent Memory Systems logo

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).

Overview

Publisherj4flmao
Repositoryagent-skills
Skill nameai-agent-memory-systems
Stars
41
Forks
6
Bundled files
Instructions only
LicenseMIT
Links
  • Markdown instructions

    A SKILL.md file the model loads on demand, so it only costs tokens when a request actually matches.

  • Works with any LLM

    AI skills are plain Markdown, not provider-specific code, so this works with GPT, Claude, Gemini, Grok, or a local model.

  • Self-contained

    Everything the model needs lives in the instructions — no extra files to sync.

  • Open source

    Published by j4flmao on GitHub. Read the source before you install it.

Installation

Install the Ai Agent Memory Systems AI skill in TypingMind to use it with any LLM, or drop it into another agent that reads SKILL.md.

1

Install in TypingMind

TypingMind installs a skill straight from its GitHub folder — it reads SKILL.md, bundles the resource files, and stores the result locally.

  1. Open the app and go to Plugins → Skills.
  2. Choose "Install from GitHub".
  3. Paste the skill folder URL below and confirm.
    https://github.com/j4flmao/agent-skills/tree/main/skills/ai/ai-agents/memory-systems
  4. Enable the skill in any chat where you want it available.
Plugins → Skills → Add skill → From GitHub URL, then paste the folder URL and press Continue.
2

Install in another agent

Any agent that reads the Agent Skills format can use this skill — copy the folder into that agent's skills directory.

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
Restart Claude Code after copying so it picks up the new skill.

Use it in TypingMind

Enable Ai Agent Memory Systems in any TypingMind chat and the model takes it from there. Its name and description sit in the system prompt, and the moment a request matches, the model loads the full instructions itself — you never invoke it by hand, and it costs no tokens until it is actually used.

The model loads Ai Agent Memory Systems on its own as soon as a request matches it.

Works with any AI model

AI skills are plain Markdown instructions rather than provider-specific code, so Ai Agent Memory Systems is not tied to the model it was written for. Install it once in TypingMind and use it with GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama, or a local model you run yourself — all on your own API keys.

  • Loaded only when it is needed

    The system prompt carries just the name and description. The instructions are fetched on the first matching request, so an idle skill costs nothing.

  • Switch models mid-chat

    Because the skill is instructions rather than code, changing model does not break it — the next model reads the same SKILL.md.

Skill instructions

This is the SKILL.md content the model loads. Read it before installing — a skill is instructions your model will follow.

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

Frequently asked questions

What does the Ai Agent Memory Systems AI skill do?

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).

Why use Ai Agent Memory Systems on TypingMind?

Because you install it once and use it with any model. Ai Agent Memory Systems is plain Markdown rather than provider-specific code, so the same skill runs on GPT-5, Claude, Gemini, Grok, or a local model — and you can switch model mid-chat without it breaking. TypingMind runs on your own API keys, so you pay providers directly instead of a per-seat subscription, and your skills and chats stay in your own storage.

How do I install Ai Agent Memory Systems in TypingMind?

Open Plugins → Skills → Install from GitHub in TypingMind and paste https://github.com/j4flmao/agent-skills/tree/main/skills/ai/ai-agents/memory-systems. TypingMind reads its SKILL.md and installs it as a skill you can enable per chat.

Which AI models can use Ai Agent Memory Systems?

Any model you connect in TypingMind. AI skills are plain Markdown instructions rather than provider-specific code, so GPT, Claude, Gemini, Grok, and local models can all load this skill when a request matches it.

How many AI models can I use with Ai Agent Memory Systems?

As many as you like. As long as a model supports skills, you can use Ai Agent Memory Systems with it — GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama and more — all on TypingMind with your own API keys.

Is the Ai Agent Memory Systems AI skill free?

Yes. It is published on GitHub by j4flmao under the MIT license. You only pay your own AI provider for the tokens you use.

What are AI skills?

An AI skill is a reusable instruction bundle that teaches an AI model how to do one specific task. It follows the open Agent Skills format: a SKILL.md file with a name and description, plus any scripts, templates or reference files the model may need. The model reads the instructions only when your request matches the skill, so an installed skill costs nothing until it is used.

How are AI skills different from plugins or MCP servers?

A plugin or MCP server gives a model new tools to call — code that runs somewhere and returns a result. An AI skill gives the model knowledge and process instead: how to approach a task, which steps to follow, what good output looks like. Skills are plain Markdown, so they need no server, no API key and no runtime, and they work with any model.

View all

Set up your own AI workspace now

Get notified about new features and future giveaways by subscribing to our newsletter 👇