Memory Insight
Memory Insight organizes multiple accumulated memories around a business topic into high-level conclusions that are ready to read and use. It helps agents identify trends, changes, risks, and recommended actions.
Overview
Memory Insight does more than return historical records. It helps agents identify trends, changes, risks, and recommended next steps. Memory Insight is mainly used for:
Compressing long-term context to increase information density.
Discovering cross-memory patterns.
Generating topic-focused results to support business decisions.
Memory Consolidation organizes repeated, scattered, or changing facts into more stable memories. Memory Insight further organizes multiple memories around a business topic into readable and actionable summaries and recommendations.
Examples
The following example calls the online service to write raw memories, create an insight, and view the result.
Step 1: Configure the service endpoint and API key
export MEMORY_BASE_URL="https://api-longmemory-cn-beijing.opentrust.net"
export MEMORY_API_KEY="<Replace with your API Key>"
export USER_ID="demo-insight-user-001"Step 2: Write 3 raw memories
curl -sS -X POST "$MEMORY_BASE_URL/memories" \
-H "Authorization: Token $MEMORY_API_KEY" \
-H "Content-Type: application/json" \
-d '{"messages":[{"role":"user","content":"I always prefer aisle seats when flying on business trips."}],"user_id":"demo-insight-user-001","infer":true}'
curl -sS -X POST "$MEMORY_BASE_URL/memories" \
-H "Authorization: Token $MEMORY_API_KEY" \
-H "Content-Type: application/json" \
-d '{"messages":[{"role":"user","content":"I prefer morning flights for business travel."}],"user_id":"demo-insight-user-001","infer":true}'
curl -sS -X POST "$MEMORY_BASE_URL/memories" \
-H "Authorization: Token $MEMORY_API_KEY" \
-H "Content-Type: application/json" \
-d '{"messages":[{"role":"user","content":"Departing after 7 PM affects my sleep, so I usually avoid late flights."}],"user_id":"demo-insight-user-001","infer":true}'The write API returns PENDING first, indicating the memories are queued for background processing. The response format is the same for all three writes:
{
"results": [
{
"message": "Memory processing has been queued for background execution",
"status": "PENDING",
"event_id": "<event_id>",
"id": null
}
]
}After a short wait, query the user's memories to confirm the 3 raw memories are available:
curl -sS "$MEMORY_BASE_URL/memories?user_id=demo-insight-user-001" \
-H "Authorization: Token $MEMORY_API_KEY"Example output. For readability, only memory content and type are shown here:
{
"results": [
{
"memory": "User always prefers aisle seats when flying on business trips",
"fact_type": "raw"
},
{
"memory": "User prefers morning flights for business travel",
"fact_type": "raw"
},
{
"memory": "User usually avoids flights departing after 7 PM because late flights affect sleep",
"fact_type": "raw"
}
],
"total": 3
}Step 3: Create an insight
Create a travel preference insight for this user. Use definition to describe what you want the system to summarize in natural language. min_memories specifies the minimum number of memories required before generation:
curl -sS -X POST "$MEMORY_BASE_URL/memory-insights" \
-H "Authorization: Token $MEMORY_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"name": "Travel Preferences",
"definition": "Summarize flight time, seat, and travel habits for business trips, and provide booking recommendations",
"user_id": "demo-insight-user-001",
"min_memories": 3,
"max_tokens": 1024,
"background": false
}'In this test, the API completes the generation synchronously and returns ready:
{
"user_id": "demo-insight-user-001",
"name": "Travel Preferences",
"status": "ready",
"insight_id": "<insight_id>",
"created_new": true,
"last_error": null
}Step 4: View the insight result
Extract the insight_id from the creation response, then query the full insight content:
export INSIGHT_ID="<insight_id from creation response>"
curl -sS "$MEMORY_BASE_URL/memory-insights/$INSIGHT_ID" \
-H "Authorization: Token $MEMORY_API_KEY"The generated insight content from this test:
Business Trip Flight Preferences and Booking Recommendations
Flight Time Preferences
- User prefers morning flights.
- Avoid flights departing after 7 PM as they affect sleep.
Seat Preferences
- Always prefers aisle seats when flying on business trips.
Booking Recommendations
- Prioritize booking morning flights.
- Ensure seat selection is aisle.
- Avoid booking flights departing after 19:00.The travel agent can use this insight directly to filter flights and seats without reading all historical memories each time.
What can be generated
Memory Insight topics are defined by the business. Common content includes:
Scenario | Insight example |
User services | Current preferences, preference changes, unresolved issues, and potential churn risks. |
Education | Learning progress, weak knowledge areas, and follow-up study recommendations. |
Project management | Key decisions, recurring blockers, and delay risks. |
Enterprise agents | Team habits, collaboration patterns, and frequent business questions. |
Coding agents | Common errors, effective solutions, and project constraints. |
More usage options
Batch creation and list query
To batch-create insights on the same topic across all existing users and agents in the database, use the group_by parameter:
curl -sS -X POST "$MEMORY_BASE_URL/memory-insights" \
-H "Authorization: Token $MEMORY_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"name": "Travel Preferences",
"definition": "Summarize different users' flight times, seat preferences, and travel habits for business trips, and provide booking recommendations",
"group_by": "user_id_agent_id",
"min_memories": 3,
"background": true
}'Query existing insights for a specific user:
curl -sS "$MEMORY_BASE_URL/memory-insights?user_id=demo-insight-user-001" \
-H "Authorization: Token $MEMORY_API_KEY"Create through the console
You can also create insights from the Data > Insight page in the console. Enter the insight name, definition (natural language description of what to summarize), User ID or Agent ID (at least one is required), set the minimum number of memories, and click Create.
View and use insights
After an insight is created, you can view its generation status and content through the console or API. Completed insights can be queried by user, agent, and topic. You can also search based on the current question and provide the insight as high-density context to the agent.
When underlying memories change significantly, you can manually refresh the insight to regenerate conclusions based on the latest information. For continuously running businesses, you can also configure automatic updates to existing insights after memory consolidation.
If the current number of memories is insufficient or there is no information directly related to the topic, the insight waits for more memories instead of generating conclusions without sufficient evidence.
Best practices
Be specific about topics: Use "Summarize flight times, seat preferences, and travel habits for business trips, and provide booking recommendations" instead of "Summarize the user" for more stable results.
Choose topics with continuous data: Examples include user preferences, learning progress, project risks, and common issues.
Use insights for understanding and decision-making: Insights are best for expressing trends, patterns, and recommendations. Specific facts such as times and amounts should still be verified against original memories.
Refresh at business pace: Topics with frequently changing information can be refreshed more often. Stable topics do not need frequent rebuilds.
Start with a few high-value topics: Verify that insights can improve actual responses or decisions before expanding the topic scope.