A conversational AI agent with persistent memory capabilities using Strands Agents, Mem0, and local FAISS storage.
- Persistent Memory: Remembers conversations and information across sessions
- Local Storage: No cloud dependencies - everything runs locally
- Intelligent Memory: Mem0's advanced memory capabilities (relationship inference, semantic understanding)
- FAISS Backend: High-performance local vector database
- OpenAI Embeddings: High-quality semantic vectors
- Conversation Loop: Interactive chat interface with memory commands
βββββββββββββββββββ βββββββββββββββββββ βββββββββββββββββββ
β Strands Agent βββββΆβ Custom Memory βββββΆβ Mem0 + FAISS β
β β β Tool β β Backend β
βββββββββββββββββββ βββββββββββββββββββ βββββββββββββββββββ
- Strands Agent: Manages conversation flow and tool orchestration
- Custom Memory Tool: Bridges the agent with Mem0's memory system
- Mem0 + FAISS: Provides intelligent memory with local vector storage
- Python 3.8+
- OpenAI API key
- uv (recommended) or pip
-
Clone the repository:
git clone https://github.com/labeveryday/strands-memory-agent.git cd strands-memory-agent
-
Install dependencies:
uv sync # or with pip: # pip install -r requirements.txt
-
Set up environment variables:
cp .env.example .env # Edit .env and add your OpenAI API key
Create a .env
file with:
OPENAI_API_KEY=your_openai_api_key_here
The memory system is configured in memory_example.py
:
config = {
"vector_store": {
"provider": "faiss",
"config": {
"collection_name": "agent_memories",
"path": "./local_memories",
"distance_strategy": "cosine"
}
}
}
Run the conversation loop:
uv run memory_example.py
help
- Show available commandsmemory
- Display stored memoriesquit
/exit
/bye
- Exit the conversation
The agent can:
- Store information you share
- Search memories semantically
- List all memories for review
- Maintain context across conversations
Modify the USER_ID
variable in memory_example.py
:
USER_ID = "your_custom_user_id"
Change the storage location in the config:
"path": "./your_custom_path"
Choose from available FAISS distance strategies:
"cosine"
- Best for semantic similarity"euclidean"
- L2 distance"inner_product"
- Dot product similarity
strands-memory-agent/
βββ README.md # This file
βββ memory_example.py # Main application with conversation loop
βββ pyproject.toml # Project dependencies and configuration
βββ .env.example # Environment variables template
βββ .gitignore # Git ignore rules
βββ local_memories/ # Memory storage directory (created automatically)
- Initialization: Creates Mem0 instance with FAISS backend
- Tool Creation: Wraps Mem0 in a custom tool for Strands integration
- Agent Setup: Creates Strands Agent with memory capabilities
- Conversation Loop: Interactive chat with persistent memory
- Memory Operations: Store, search, and retrieve information using Mem0's intelligence
- Semantic Understanding: Not just vector similarity, but actual meaning comprehension
- Relationship Inference: Connects related memories intelligently
- Memory Consolidation: Merges and organizes information
- Context Awareness: Understands deeper meaning and context
- Temporal Reasoning: Understands when and how memories relate
- Local Storage: No cloud dependencies
- High Performance: Optimized for speed and efficiency
- Scalability: Handles large numbers of memories
- Multiple Distance Metrics: Cosine, Euclidean, Inner Product
-
OpenAI API Key Error
- Ensure
.env
file exists withOPENAI_API_KEY
- Verify API key is valid and has credits
- Ensure
-
Memory Not Persisting
- Check
./local_memories/
directory exists - Verify file permissions
- Check
-
Import Errors
- Ensure all dependencies are installed:
uv sync
- Check Python version compatibility
- Ensure all dependencies are installed:
Enable debug logging by modifying the logging level in the code.
Create new tools using the @tool
decorator:
@tool
def your_custom_tool(param: str) -> str:
"""Your tool description."""
return "Your tool result"
Then add the tool to:
multimodal_agent = Agent(
system_prompt=MULTIMODAL_SYSTEM_PROMPT,
tools=[memory_tool, your_custom_tool],
model=model,
)
Modify the memory_tool
function to add new actions or enhance existing ones.
- strands-agents: AI agent framework
- mem0ai: Intelligent memory system
- faiss-cpu: Local vector database
- openai: Embedding and LLM services
- python-dotenv: Environment variable management
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests if applicable
- Submit a pull request
This project is licensed under the MIT License - see the LICENSE file for details.
- Strands Agents for the agent framework
- Mem0 for intelligent memory capabilities
- FAISS for local vector storage
- OpenAI for embedding and language models
If you encounter issues or have questions:
- Check the troubleshooting section above
- Search existing issues in the repository
- Create a new issue with detailed information
Happy coding! π