Smara Memory Skill
Gives your agent persistent memory across conversations. Store facts about users, search by meaning, and retrieve full context — powered by Smara's Ebbinghaus decay scoring.
When to use
- - When the agent learns something about a user that should persist (preferences, facts, context)
- When the agent needs to recall what it knows about a user
- When the agent should check if it already knows something before asking again
- After meaningful conversations to extract and store key facts
Setup
- 1. Get a free API key at https://smara.io
- Set
SMARA_API_KEY in your environment
Actions
Store a memory
CODEBLOCK0
Search memories
CODEBLOCK1
Get full user context
CODEBLOCK2
Delete a memory
CODEBLOCK3
Instructions for the agent
- 1. After conversations: Extract key facts (preferences, decisions, context) and store them as memories with relevant tags
- Before responding: Search for relevant memories to personalize responses
- Contradiction handling: Smara automatically handles contradictions — if a user changes a preference, just store the new one and the old one is soft-deleted
- Duplicate handling: Smara skips duplicates automatically — safe to store the same fact multiple times
- Decay scoring: Memories naturally lose weight over time. Recent, frequently-accessed memories rank higher. This is automatic.
Example workflow
CODEBLOCK4
API Reference
Full docs: https://api.smara.io/docs/
Smara 记忆技能
为您的智能体提供跨对话的持久记忆能力。存储关于用户的事实信息,通过语义进行搜索,并检索完整上下文——由Smara的艾宾浩斯衰减评分驱动。
适用场景
- - 当智能体了解到应持久保存的用户信息时(偏好、事实、上下文)
- 当智能体需要回忆已掌握的用户信息时
- 当智能体在重复询问前应检查是否已掌握相关信息时
- 在有意义的对话后,提取并存储关键事实
配置方法
- 1. 在 https://smara.io 获取免费API密钥
- 在环境中设置 SMARAAPIKEY
操作指令
存储记忆
bash
curl -X POST https://api.smara.io/v1/memories \
-H Authorization: Bearer $SMARAAPIKEY \
-H Content-Type: application/json \
-d {
userid: userid_here,
fact: 用户偏好深色模式并使用vim快捷键,
importance: 0.7
}
搜索记忆
bash
curl https://api.smara.io/v1/memories/search?userid=userid_here&query=编辑器偏好&limit=5 \
-H Authorization: Bearer $SMARAAPIKEY
获取完整用户上下文
bash
curl https://api.smara.io/v1/users/useridhere/context \
-H Authorization: Bearer $SMARAAPIKEY
删除记忆
bash
curl -X DELETE https://api.smara.io/v1/memories/MEMORY_ID \
-H Authorization: Bearer $SMARAAPIKEY
智能体操作指南
- 1. 对话结束后:提取关键事实(偏好、决策、上下文)并作为记忆存储,附带相关标签
- 响应前:搜索相关记忆以个性化回复内容
- 矛盾处理:Smara自动处理矛盾——如果用户更改偏好,只需存储新信息,旧信息将被软删除
- 重复处理:Smara自动跳过重复内容——多次存储相同事实是安全的
- 衰减评分:记忆会随时间自然衰减。近期频繁访问的记忆排名更高。此过程自动进行。
示例工作流程
用户:我上周切换到Neovim了
智能体思考:
- 1. 搜索编辑器偏好记忆 → 找到使用vim快捷键
- 存储新记忆:已切换到Neovim(从vim迁移) 附带标签 [偏好, 编辑器]
- Smara自动检测与旧vim记忆的矛盾 → 软删除旧记忆
- 回复确认切换信息
API参考
完整文档:https://api.smara.io/docs/