Back to Recipes

Agent Memory with Squish

Give your AI agents persistent, searchable memory across sessions using the Squish memory system.

Best for: Developers building AI agents that need to remember context

What You Get

  • -Squish MCP server setup
  • -Memory write/read integration
  • -Cross-session context retention
  • -Semantic memory search
  • -Memory consolidation strategy

Step by Step

1. Install and configure Squish MCP server

Follow docs at squishplugin.dev to install the Squish MCP server. Configure it with your project path. Test basic operations: remember, recall, search, and context via MCP inspector.

2. Create the memory toolkit for your agent

Give your agent access to Squish tools: squish_remember (store facts, decisions, observations), squish_recall (retrieve specific memory by ID), squish_search (semantic search across memories). Define clear guidelines for what to remember.

3. Implement auto-context loading

On agent startup, call squish_context to load relevant project context. Pass the agent's task description and user identity to filter relevant memories. Set a max context limit (e.g., top 10 memories).

4. Add memory consolidation

Implement a scheduled job (weekly) that: identifies low-confidence memories (confidence < 30), identifies memories older than 30 days with < 5 accesses, archives them using squish_forget or tier=cold, logs consolidation stats.

5. Build the memory inspector UI

Create a simple Next.js page that displays: total memory count by type, recent memories, search interface, memory detail view (content, type, confidence, created_at, access_count), and pin/unpin controls.

6. Add logging and monitoring

Log every memory operation: write, read, search result count, consolidation actions. Monitor: total memory size, API call frequency, average recall relevance score.

Stack

Squish (memory MCP)OpenAI/ClaudeNode.js/TypeScriptSQLiteMCP protocol

Build This

Copy this prompt and paste it into Claude Code, OpenCode, Codex, or Cursor to build this recipe.

Build an agent memory system with search, tagging, and context-aware recall. ROLE: You are a memory management system that enables AI agents to persist, search, and recall knowledge across sessions. CONSTRAINTS: - Memory entries must be tagged with at least one category and one priority level - Memory recall must respect token budgets (default: 500 tokens per recall query) - Memory deletion is soft-delete only; archives are kept for 90 days - Each memory entry has a confidence score (0.0-1.0) based on source reliability - Maximum 10,000 memories per project; oldest low-confidence memories are archived first TOOL CALLING: - Use function calling for: store_memory(content, tags[], priority, source, confidence), search_memory(query, tags?, limit?, min_confidence?), recall_context(project_id, topic, token_budget), delete_memory(memory_id), list_memories(filter?) - Each tool returns structured JSON with memory data and metadata STRUCTURED OUTPUT: - Memory entry must return JSON: { id: string, content: string, tags: string[], priority: 'low' | 'medium' | 'high', source: string, confidence: number, created_at: string, accessed_at: string, access_count: number } - Search results must return JSON: { query: string, results: [{ id: string, content: string, score: number, tags: string[] }], total_count: number, token_count: number } - Context summary must return JSON: { topic: string, memories_used: number, token_count: number, summary: string, key_facts: string[] } CHAIN OF THOUGHT: - Storage: analyze content → extract key facts → assign tags → score confidence → store with metadata - Search: parse query → expand synonyms → match against tags and content → rank by recency and relevance → return top results - Recall: determine topic → retrieve relevant memories → compress to fit token budget → return structured summary FEW-SHOT EXAMPLES: Store: 'OpenAI API costs are $0.02 per 1K tokens for GPT-4, $0.002 per 1K tokens for GPT-3.5' Tags: ['costs', 'api', 'openai'] Priority: high Confidence: 0.95 Source: official documentation Search: 'How much does OpenAI cost?' Results: [{ id: 'mem_123', content: 'OpenAI API costs are $0.02 per 1K tokens for GPT-4...', score: 0.92, tags: ['costs', 'api', 'openai'] }] Summary: 'OpenAI charges $0.02/1K tokens for GPT-4 and $0.002/1K tokens for GPT-3.5' EVALUATION CRITERIA: - Search relevance: percentage of search results that are topically related to the query - Recall efficiency: percentage of token budget used without truncation - Tag accuracy: percentage of memories correctly categorized - Confidence calibration: correlation between assigned confidence and actual accuracy The system should: 1) Set up the Squish MCP server (follow the Squish docs at squishplugin.dev), 2) Give the agent tools to remember facts, decisions, and observations with squish_remember, 3) Give the agent tools to recall relevant memories with squish_search and squish_recall, 4) When the agent starts a new session, load relevant context automatically using squish_context, 5) Implement a memory consolidation strategy: archive old/low-confidence memories after 30 days, 6) Log memory operations for debugging, 7) Include a simple UI to inspect what the agent remembers.

Common Failure Modes

  • !Memory context gets too large and expensive
  • !Retrieval returns irrelevant memories
  • !Memory conflicts from contradictory information
  • !SQLite lock contention at scale

Implementation Notes

Pin critical memories (API keys, user preferences) to prevent consolidation. Monitor memory storage size. Tune search parameters per use case.

Ship agent memory with squish in production with 4M Labs

4M Labs designs and ships applied AI systems -- connected to your tools, secured for your team, deployed with monitoring.

  • Connected to your tools and data sources
  • Secured for your team with proper access controls
  • Deployed with monitoring and error handling
  • Documented for handoff and future maintenance
Work With 4M Labs

Frequently Asked Questions

Can I use this recipe in production?
Yes. Every recipe is production-tested with error handling, logging, and deployment guidance.
Which LLM providers are supported?
Recipes support OpenAI, Anthropic Claude, Google Gemini, and open-source models via a unified interface.
How do I customize these recipes?
Each recipe includes a configuration section. Override model selection, API keys, and parameters without changing core logic.