Overview
Persistent memory system using knowledge graphs for AI agents. Stores entities, relations, and observations as a graph, enabling semantic retrieval and reasoning over accumulated knowledge.
Capabilities
- Extract entities and relations from conversations and documents
- Store knowledge as a graph (nodes + edges + observations)
- Retrieve relevant knowledge via semantic search and graph traversal
- Consolidate and deduplicate knowledge over time
- Query knowledge with natural language
When to Use
Trigger phrases:
"memory knowledge graph"
"Knowledge graph-based persistent memory for AI agents — entities, relations, and"
Building AI agents with long-term memory
Need to remember user preferences, facts, and context across sessions
Knowledge base that grows and improves over time
Cross-referencing information across multiple sources
When NOT to Use
- Task is outside your authorization scope
- You need to implement controls (use implementing-* skills)
- Task is about analysis, not action (use analyzing-* skills)
- You don't have access to target systems
- Task requires compliance expertise (consult professionals)
- Task is about defense, not offense (use defensive skills)
Pseudo Code
# Example workflow for this skill
def execute(input_data):
# Step 1: Validate input
if not input_data:
raise ValueError("Input data is required")
# Step 2: Process core logic
result = process(input_data)
# Step 3: Validate output
validate_output(result)
return result
Entity Extraction
def extract_entities(text):
prompt = f"""Extract entities and relations from:
{text}
Return JSON: {{"entities": [{{"name": "...", "type": "...", "observations": [...]}}], "relations": [{{"from": "...", "to": "...", "type": "..."}}]}}"""
return llm.generate(prompt)
Knowledge Retrieval
def retrieve_relevant(query, graph, top_k=5):
# 1. Semantic search on entity names and observations
semantic_results = graph.semantic_search(query, top_k=top_k)
# 2. Graph traversal - get connected entities
related = []
for entity in semantic_results:
related.extend(graph.get_neighbors(entity.id, depth=2))
# 3. Deduplicate and rank
return rank_by_relevance(semantic_results + related, query)
Memory Consolidation
def consolidate(graph):
# Merge duplicate entities
duplicates = find_similar_entities(graph, threshold=0.9)
for dup_group in duplicates:
merge_entities(graph, dup_group)
# Remove stale observations
for entity in graph.entities:
entity.observations = [o for o in entity.observations if o.relevance > 0.3]
Common Patterns
- Extract on every interaction: Build knowledge from every conversation
- Semantic + graph traversal: Combine vector search with graph walks for better retrieval
- Consolidate periodically: Merge duplicates and prune stale knowledge
- Entity types: Person, Organization, Concept, Event, Preference
How to Use
- Invoke the skill when relevant domain keywords appear in the request
- Provide required inputs as specified in the skill definition
- Review the output for correctness before delivering to the user
- Combine with related skills for complex multi-step workflows
Verification
After completing this skill, confirm:
- Output meets the defined quality and completeness requirements
- All prerequisites are verified and documented
- Error handling covers edge cases
- Results are accurate and actionable
Process
- Analyze the task requirements
- Apply domain expertise
- Verify output quality
Anti-Rationalization Table
| Rationalization | Reality |
|---|---|
| "I will just use curl" | MCP handles auth, retries, streaming, and type safety. Use the SDK. |
| "One mega-server is simpler" | Single-responsibility servers are easier to debug and maintain. |
| "MCP is just a wrapper" | MCP enables cross-platform tool sharing. It is infrastructure, not overhead. |