AGENT SKILL

agent-memory

Implement memory systems for AI agents — short-term context, long-term vector storage, episodic memory, and knowledge graphs. Use when: "add memory to agent", "agent memory", "RAG for agents", "persistent context", "knowledge base", or when agents forget things.

License 许可
MIT
所属仓库
kalash33/kstack
最近更新
2026-05-20
Stars
★ 0
Forks
0

01 前言 Front Matter

name
agent-memory
description
Implement memory systems for AI agents — short-term context, long-term vector storage, episodic memory, and knowledge graphs. Use when: "add memory to agent", "agent memory", "RAG for agents", "persistent context", "knowledge base", or when agents forget things.

03 SKILL.md 正文

/agent-memory — Memory Systems

Agents without memory start from zero every time. Fix that.

When to Use

  • Agent keeps forgetting context between sessions
  • Need to store and retrieve knowledge
  • Building RAG pipelines for agents
  • Implementing learning from past interactions

Memory Types

Short-term (Context Window)

  • Last N messages in conversation
  • Current task state
  • Implementation: Simple buffer, sliding window

Long-term (Vector Store)

  • Documents, code, past conversations
  • Semantic search for relevant context
  • Implementation: ChromaDB, Pinecone, pgvector, Qdrant

Episodic (What Happened)

  • Key decisions and their outcomes
  • Successful/failed approaches
  • Implementation: Structured logs with embeddings

Graph (Relationships)

  • Entity relationships (user → project → feature)
  • Dependency maps
  • Implementation: Neo4j, NetworkX, or simple adjacency lists

Implementation Patterns

Pattern 1: RAG Memory

# Store
chunks = split_document(doc, chunk_size=512)
embeddings = embed(chunks)
vector_store.upsert(chunks, embeddings)

# Retrieve
query_embedding = embed(user_query)
relevant = vector_store.search(query_embedding, top_k=5)
context = "\n".join(relevant)

Pattern 2: Conversation Summary

# When context window fills up
summary = llm.summarize(old_messages)
memory = [system_msg, summary_msg] + recent_messages[-5:]

Pattern 3: Tool-Result Cache

# Cache expensive tool calls
cache_key = hash(tool_name + str(args))
if cache_key in memory:
    return memory[cache_key]
result = tool.run(args)
memory[cache_key] = result

Chaining

  • Before: /agent-design (decides what memory is needed)
  • After: /agent-eval (tests retrieval quality)

04 同仓库更多 Skills