- Lost context: agents lose context, requiring users to repeat information
- Repetitive interactions: agents ask the same questions in every session
- Missed opportunities: agents can’t provide personalized recommendations based on past behavior
- Poor user experience: the experience may feel impersonal
How memory works
A user interacts with your agent. Memory then operates in these stages:- Retrieval (automatic). The agent loads memories for context in two modes: preload fetches recent memories at conversation start, preflight fetches query-relevant memories before each response.
- Tools (optional). During a conversation, agents can use the following memory tools:
algolia_memorize: saves semantic memories (facts, preferences)algolia_ponder: saves episodic memories (experiences, observations)algolia_memory_search: searches existing memories
Memory types
Agent Studio supports two types of memory, inspired by human cognitive architecture: semantic and episodic.Semantic memory
Stores timeless facts, preferences, and general knowledge about the user. For example:- “User is allergic to peanuts”
- “User prefers dark mode in apps”
- “User lives in Madrid and speaks Spanish and English”
- “User’s job title is Software Engineer”
- User profile information
- Preferences and settings
- Dietary restrictions
- Accessibility needs
- Communication style
Semantic memory structure
Semantic memory structure
JSON
Episodic memory
Captures the agent’s reasoning chain from conversations. This includes what it observed, thought, did, and learned. Use episodic memory to extract meta-learnings for process improvement and analysis. Use episodic memory to understand the agent’s reasoning process. Agent Studio structures this information. It uses the OTAR pattern:- Observation: what happened (user input, context, problem)
- Thoughts: why the agent chose this approach (reasoning, constraints)
- Action: what the agent did (tool calls, responses, workflow)
- Result: what happened and what the agent learned
- Analyze agent performance across user segments
- Identify successful problem-solving patterns
- Review conversations to improve prompts and instructions
- Answer questions like “How does prompt A perform for premium customers asking about returns?”
Episodic memory structure
Episodic memory structure
JSON
Enable memory
To enable memory, you must:- Enable the feature on your agent
- Verify data retention
- Set up user authentication
1
Enable on your agent
- From the dashboard
- With the API
From the Agent Studio agent edit view:
- Open your agent’s settings
- Go to the Customizations section
- Find the Memory toggle
- Click Configure to check prerequisites
- Enable memory once you meet the prerequisites
- Save changes
The dashboard validates prerequisites automatically.
It also guides you through any missing configuration.
2
Verify data retention
Memory learns from conversation history.
To use it, you must store conversations (set the retention period to more than 0 days).From the Algolia dashboard, go to Agent Studio > Settings:You need this because:
- Check the Retention period is set to
30,60, or90days. If you set it to0, Algolia doesn’t store conversation history. As a result, memory can’t extract information from past conversations.
Retention applies to all agents in your Algolia application.
Supported values are
0, 30, 60, and 90 days.- Application-wide setting: retention applies to all agents in your Algolia application, not individual agents.
- Memory extracts information from past conversations A longer retention period helps memory. It gives memory more conversation history to draw on. It can then extract and combine more information from that history.
- Longer retention enables better memory extraction and consolidation
3
Set up user authentication
Memory requires user authentication.
This identifies which user’s memories to load and save.
Memory keeps stored information separate for each user.For complete setup instructions, see User authentication. This guide covers:Set this up first.
Then include the
- Getting your secret key from the dashboard
- Generating JWTs (JSON Web Tokens) on your backend
- Security guidance and token management
The same secure JWTs work for both memory and conversations.
You might already have JWT authentication set up for conversations.
If so, reuse that setup.
X-Algolia-Secure-User-Token header in your completion requests.
This enables user-scoped memory:JavaScript
Memory tools
SettoolsEnabled to true to give your agent access to three memory tools.
Each tool has default activation conditions that you can customize in the agent instructions
algolia_memorize
Saves semantic memories (facts and preferences) during conversation.
Default triggers (built into tool prompt):
- User explicitly says “remember X”
- Agent detects a stable preference or fact (for example, dietary restrictions, account type)
- User provides information useful for future interactions
algolia_memorize.
This saves the fact for later use.
algolia_ponder
Saves episodic memories (the agent’s reasoning chain) during conversation.
Default triggers (built into tool prompt):
- User says “remember this conversation” or “learn from this interaction”
- After solving a problem worth learning from
- After a successful workflow that could help similar future cases
algolia_ponder.
It records what it observed.
It also notes how it reasoned and what it did.
It also records what it learned (OTAR pattern).
algolia_memory_search
Searches existing memories during conversation using Algolia Search.
Default triggers (built into tool prompt):
- Before claiming “I don’t know” about the user
- Before answering questions about user preferences or history
- When user asks “what did I say about X?”
- When context from previous sessions would improve the response
algolia_memory_search.
This finds dietary preferences before the agent recommends anything.
Customizing tool behavior
The default triggers work for most cases. You can override them in your agent’s instructions:Use cases
Personalize user experiences
Personalize user experiences
Problem: generic responses don’t account for individual user preferences and context.Solution: memory enables agents to tailor responses.
Agents base these responses on what they know about each user.For example,
an ecommerce agent remembers a user’s size preferences and favorite brands.
It also remembers past purchases.
Then it provides relevant recommendations without asking repetitive questions.
Reduce repetitive questions
Reduce repetitive questions
Problem: users get frustrated repeating the same information in every conversation.Solution: agents recall information shared earlier, eliminating redundant questions.For example,
a support agent remembers a user’s account type and previous issues.
It also remembers the preferred contact method.
It then jumps straight to solving the current problem.
Improve agent performance through analysis
Improve agent performance through analysis
Problem: you can’t see how your agent reasons through problems.
You also can’t identify what approaches work best.Solution: episodic memory captures the agent’s reasoning chain (OTAR) for each conversation.
This enables analysis across user segments and scenarios.For example, you can export episodic memories.
These come from users who mentioned “returns.”
You might focus especially on those with premium accounts.
Then, analyze how the agent handled those conversations:
- Did it resolve return requests effectively?
- Are there patterns in failed resolutions?
Enable continuous conversations
Enable continuous conversations
Problem: conversations reset with every new session, breaking continuity.Solution: memory retains user context between sessions.
It does this even long after the initial conversation.For example,
a user was considering a laptop last week.
The shopping agent recalls this.
It then proactively asks if they’re still interested.
It also asks if they need more information.
How memory extraction works
When the agent calls a memory tool, Agent Studio doesn’t store the raw input. It runs the information through a quality filter, extracts the memory, and generates metadata before storing it. Quality filters evaluate whether information is useful enough to store.- Utility: would this fact improve future responses?
- Specificity: is it concrete and factual (not mood or chitchat)?
- Effect on behavior: can you think of a query where it changes behavior?
- Factual statements about user preferences
- Important events and interactions
- Skills, knowledge, and relationships
- Patterns inferred from past experiences
- Greetings and pleasantries (“Hello”, “I appreciate it”)
- Generic traits without specifics (“User is friendly”)
- Temporary moods or states
- Duplicate information already stored
Memory lifecycle
Memory retrieval happens automatically before the agent generates a response. You can configure two retrieval modes: preload (recent memories) and preflight (query-relevant memories).Retrieval modes compared
You can enable both modes together.
Preload provides baseline context, and preflight adds query-specific memories.
Recent memories (preload)
Preload retrieves up to the configured number of recent memories when a conversation starts. It does this no matter what the user asks.- Identify user: extract user ID from the JWT token
- Retrieve memories: fetch up to N recent memories (configurable limit)
- Filter by type: semantic, episodic, or both
- Include in context: the agent adds memories to its initial prompt
JSON
- Small memory sets where all memories fit in context
- Always-on personalization (user preferences should always be available)
- Predictable use cases where recent memories are likely relevant
Query-based retrieval (preflight)
Preflight searches memories based on what the user is asking. It doesn’t rely on recency alone. It runs before the agent responds. It adds memories retrieved for the current query to the agent’s context. Configuration example:JSON
limit: maximum memories to retrieve per queryconversationWindow: number of recent messages to analyze for search context
- Large memory sets (100+ memories) where loading all recent memories is less useful
- Diverse memory content where only some memories apply to each query
- When you want to maximize relevant context without wasting tokens
During conversation (tools)
Agents can dynamically save and search memories during the conversation. They do this using memory tools. For example, a user might report an error. It could be similar to one resolved before. The agent then callsalgolia_memory_search to find past resolutions with matching symptoms.
Common integration issues
Memory not enabled - prerequisites not met
Memory not enabled - prerequisites not met
Symptoms: can’t enable memory toggle in dashboard.If you can’t enable the memory toggle in the dashboard,
check the following:
- Verify data retention is greater than 0 days
- Ensure you have
settingsRankingpermission to modify retention settings
Agent doesn't remember information
Agent doesn't remember information
Symptoms: the agent doesn’t recall previous information.
This happens even when memory is enabled.Possible causes:
- No JWT token passed: conversations must include
X-Algolia-Secure-User-Tokenheader - Memory tools not enabled: set
toolsEnabled: truein the agent configuration - Preload limit too low: increase the number of memories loaded at conversation start
- Wrong memory type: if you set the preload type to semantic, episodic memories won’t load
Memories not relevant to user's query
Memories not relevant to user's query
Symptoms: the agent loads memories.
They aren’t relevant to what the user is asking about.Possible causes:You can use both preload and preflight together.
Preload provides baseline context, and preflight adds query-specific memories.
- Using preload with large memory sets: preload fetches recent memories, not the most relevant
- Preflight not configured: query-based retrieval isn’t enabled
JSON