GAIA’s memory system is what makes it truly personal and continuously improving. Unlike traditional AI assistants that forget everything after each conversation, GAIA maintains two distinct memory types: User Memory (what it knows about you) and Skill Memory (what it has learned to do).
Critical Design: These memory types are completely separate. User preferences never pollute skill knowledge, and procedural skills work across all users.
# From: apps/api/app/utils/memory_utils.pyasync def store_user_message_memory( user_id: str, message: str, conversation_id: str): """ Store user message in background (fire-and-forget). Extracts: - Named entities (people, places, organizations) - Dates and deadlines - Preferences and opinions - Action items and commitments """ # Run as background task # Non-blocking, doesn't slow down responses
1
User Sends Message
“I’m meeting with Sarah from ClientX next Tuesday to discuss the Q4 roadmap”
# Store in mem0 with relationshipsawait memory_client.add( messages=[{"role": "user", "content": message}], user_id=user_id, metadata={"conversation_id": conversation_id})
4
Future Retrieval
When you later say “What did Sarah and I discuss?”, GAIA instantly recalls the Q4 roadmap meeting
# From: apps/api/app/agents/tools/memory_tools.py@toolasync def search_memory( config: RunnableConfig, query: str, limit: int = 10) -> dict: """ Search user's memory for relevant information. Examples: - "What projects am I working on?" - "Who is Sarah Johnson?" - "What are my preferences for meetings?" - "When is the Q4 deadline?" """ # Semantic search across memory graph # Returns contextual information with sources
# Agent searches its skill memoryskills = await skill_service.search_skills( query="summarize meetings and send email", agent_id="gmail_agent", limit=5)
3
Skill Injection
# From: apps/api/app/agents/memory/skill_learning/service.py:183-242# Format skills for system promptprompt += """## Learned Procedures (gmail_agent):### 1. Summarizing meetings and emailing teamFirst search calendar for today's events, extract key points from each,generate structured summary, then compose email to team distribution list.**Tools:** GOOGLE_CALENDAR_LIST_EVENTS, GMAIL_COMPOSE_EMAIL**Optimal approach:** Use calendar event descriptions for context**Watch out for:** Include meeting recordings links if available"""
4
Enhanced Execution
Agent executes with learned best practices, avoiding past mistakes and using proven approaches
5
New Learning
After execution, both extractors run to capture any new insights or improvements
# From: apps/api/app/agents/core/nodes/memory_learning_node.pyasync def memory_learning_node( state: State, config: RunnableConfig, store: BaseStore) -> State: """ End-of-graph hook that runs after every agent execution. Learns: 1. Skills (procedural knowledge) → MongoDB per agent 2. User memory (personal info) → mem0 per user Runs as fire-and-forget background task. """ # Extract user_id and agent_id from config # Run both learning processes in parallel await asyncio.gather( skill_learning_service.learn_from_conversation(...), memory_client.add(...) # User memory )
This node runs on every agent execution—both main agent and subagents. This means GAIA learns continuously from all interactions.
# Stored in mem0 with user_id as namespaceawait memory_client.add( messages=[...], user_id="user_123", # Isolates this user's memories metadata={...})# Search only returns this user's memoriesresults = await memory_client.search( query="my preferences", user_id="user_123")
# Stored in MongoDB with agent_id as namespaceskill = Skill( agent_id="gmail_agent", # This skill is for gmail_agent only trigger="compose professional email", procedure="...")# Search only returns skills for this specific agentskills = await search_skills( query="send email", agent_id="gmail_agent", # Won't return twitter_agent skills limit=5)
Critical Separation: User memories are private per user. Skills are shared across all users of the same agent but isolated per agent type.
# From: apps/api/app/agents/tools/memory_tools.pyMEMORY_TOOLS = [ search_memory, # Search user's memory list_memory, # List all user memories add_memory, # Manually add memory update_memory, # Update existing memory delete_memory, # Remove memory]# These tools are included in every agent's toolkit
# Agent automatically searches memory when neededresult = await search_memory( query="client meetings this week", user_id="user_123", limit=5)# Returns:{ "memories": [ "Meeting with ClientX scheduled for Tuesday 2pm", "ClientX CEO is Sarah Johnson ([email protected])", "Previous meeting notes: discussed Q4 roadmap" ]}