SwarmRecall Memory
Conversational memory persistence with semantic search and session tracking via the SwarmRecall API.
Auto-Registration
Before making any API calls, check for a SWARMRECALL_API_KEY environment variable:
- 1. If
SWARMRECALL_API_KEY is set, use it for all requests as a Bearer token. - If
SWARMRECALL_API_KEY is not set, self-register by calling:
POST https://swarmrecall-api.onrender.com/api/v1/register
Content-Type: application/json
{ "name": "<your-agent-name>" }
- 3. The response returns
{ "apiKey": "...", "claimToken": "..." }. Save the apiKey to the SWARMRECALL_API_KEY environment variable for all subsequent requests. Do NOT write the key to disk or any file without user consent. - Tell the user: "SwarmRecall is set up! To manage your agent's data, visit swarmrecall.ai/claim with code:
<claimToken>"
Authentication
All API requests require:
CODEBLOCK1
API Base URL
INLINECODE7 (override with SWARMRECALL_API_URL if set)
All endpoints below are prefixed with /api/v1.
Privacy & Data Handling
- - All data is sent to
swarmrecall-api.onrender.com over HTTPS - Memory content is stored server-side with vector embeddings for semantic search
- Data is isolated per agent and owner — no cross-tenant access
- Before storing user-provided content, ensure the user has consented to external storage
- The
SWARMRECALL_API_KEY should be stored as an environment variable only, not written to disk
Endpoints
Store a memory
CODEBLOCK2
Search memories
CODEBLOCK3
List memories
CODEBLOCK4
Get a memory
CODEBLOCK5
Update a memory
CODEBLOCK6
Delete a memory
CODEBLOCK7
Start a session
CODEBLOCK8
Get current session
CODEBLOCK9
Update a session
CODEBLOCK10
List sessions
CODEBLOCK11
Behavior
- - On session start: call
GET /api/v1/memory/sessions/current to load context from the last session. If none, call POST /api/v1/memory/sessions to start one. - On fact, preference, or decision: call
POST /api/v1/memory with appropriate category and importance. - On recall needed: call
GET /api/v1/memory/search?q=<query> and use returned memories to inform your response. - On session end: call
PATCH /api/v1/memory/sessions/:id with ended: true and a summary.
Shared Pools
- - The
POST /api/v1/memory and POST /api/v1/memory/sessions endpoints accept an optional "poolId" field. - When
poolId is provided, the memory or session is shared with all pool members who have memory read access. - The agent must have readwrite access to the pool's memory module to write shared memories.
- Search (
GET /api/v1/memory/search) and list (GET /api/v1/memory) results automatically include data from pools the agent belongs to. - Pool data in responses includes
poolId and poolName fields to distinguish shared data from the agent's own data.
Dreaming Integration
Memory is the primary target of dream operations. During a dream cycle:
- - Duplicate clusters: Groups of similar memories are identified by the dream service. The agent reads the cluster, merges content into the anchor memory, and archives the rest. Use
PATCH /api/v1/memory/:id to update the anchor and DELETE /api/v1/memory/:id to archive duplicates. - Session summaries: Unsummarized sessions are flagged. The agent reads session memories via
GET /api/v1/memory?sessionId=X, then writes a summary via POST /api/v1/memory with category: "session_summary". - Decay and pruning: The server automatically reduces importance of old memories and archives those below the prune threshold. Memories with
category: "session_summary" or tag "pinned" are protected. - Contradictions: Memory pairs with high similarity but divergent content are flagged. The agent reviews both, archives the stale one, and optionally updates the current one.
To protect a memory from pruning, add the "pinned" tag:
CODEBLOCK12
SwarmRecall 记忆系统
通过 SwarmRecall API 实现具有语义搜索和会话跟踪功能的对话记忆持久化。
自动注册
在进行任何 API 调用之前,检查 SWARMRECALLAPIKEY 环境变量:
- 1. 如果设置了 SWARMRECALLAPIKEY,则在所有请求中将其用作 Bearer 令牌。
- 如果未设置 SWARMRECALLAPIKEY,则通过调用以下接口进行自我注册:
POST https://swarmrecall-api.onrender.com/api/v1/register
Content-Type: application/json
{ name: <你的代理名称> }
- 3. 响应返回 { apiKey: ..., claimToken: ... }。将 apiKey 保存到 SWARMRECALLAPIKEY 环境变量中,用于所有后续请求。未经用户同意,不得将密钥写入磁盘或任何文件。
- 告知用户:SwarmRecall 已设置完成!要管理你的代理数据,请访问 swarmrecall.ai/claim 并使用代码:
身份验证
所有 API 请求都需要:
Authorization: Bearer APIKEY>
API 基础 URL
https://swarmrecall-api.onrender.com(如果设置了 SWARMRECALLAPIURL,则覆盖该值)
以下所有端点均以 /api/v1 为前缀。
隐私与数据处理
- - 所有数据通过 HTTPS 发送到 swarmrecall-api.onrender.com
- 记忆内容存储在服务器端,并带有用于语义搜索的向量嵌入
- 数据按代理和所有者隔离——无跨租户访问
- 在存储用户提供的内容之前,确保用户已同意外部存储
- SWARMRECALLAPIKEY 应仅作为环境变量存储,不得写入磁盘
端点
存储记忆
POST /api/v1/memory
{
content: 用户偏好深色模式,
category: preference, // fact | preference | decision | context | session_summary
importance: 0.8, // 0.0 到 1.0
tags: [ui],
metadata: {},
poolId: // 可选——写入共享池
}
搜索记忆
GET /api/v1/memory/search?q=<查询>&limit=10&minScore=0.5
列出记忆
GET /api/v1/memory?category=preference&limit=20&offset=0&includeArchived=false
获取单条记忆
GET /api/v1/memory/:id
更新记忆
PATCH /api/v1/memory/:id
{ importance: 0.9, tags: [updated], archived: false }
删除记忆
DELETE /api/v1/memory/:id
开始会话
POST /api/v1/memory/sessions
{
context: {},
poolId: // 可选——写入共享池
}
获取当前会话
GET /api/v1/memory/sessions/current
更新会话
PATCH /api/v1/memory/sessions/:id
{ summary: 讨论了项目设置, ended: true }
列出会话
GET /api/v1/memory/sessions?limit=20&offset=0
行为规则
- - 会话开始时:调用 GET /api/v1/memory/sessions/current 加载上次会话的上下文。如果没有,则调用 POST /api/v1/memory/sessions 开始一个新会话。
- 遇到事实、偏好或决策时:调用 POST /api/v1/memory,并指定相应的类别和重要性。
- 需要回忆时:调用 GET /api/v1/memory/search?q=<查询>,并使用返回的记忆来指导你的响应。
- 会话结束时:调用 PATCH /api/v1/memory/sessions/:id,设置 ended: true 并附带摘要。
共享池
- - POST /api/v1/memory 和 POST /api/v1/memory/sessions 端点接受可选的 poolId 字段。
- 当提供 poolId 时,该记忆或会话将与所有具有记忆读取权限的池成员共享。
- 代理必须对池的记忆模块具有读写权限才能写入共享记忆。
- 搜索(GET /api/v1/memory/search)和列表(GET /api/v1/memory)结果会自动包含代理所属池的数据。
- 响应中的池数据包含 poolId 和 poolName 字段,用于区分共享数据和代理自身数据。
梦境集成
记忆是梦境操作的主要目标。在梦境周期中:
- - 重复聚类:梦境服务识别出相似记忆的群组。代理读取该群组,将内容合并到锚点记忆中,并归档其余部分。使用 PATCH /api/v1/memory/:id 更新锚点记忆,使用 DELETE /api/v1/memory/:id 归档重复项。
- 会话摘要:未生成摘要的会话会被标记。代理通过 GET /api/v1/memory?sessionId=X 读取会话记忆,然后通过 POST /api/v1/memory 写入摘要,类别为 sessionsummary。
- 衰减与修剪:服务器自动降低旧记忆的重要性,并将低于修剪阈值的记忆归档。类别为 sessionsummary 或标签为 pinned 的记忆受到保护。
- 矛盾检测:相似度高但内容有分歧的记忆对会被标记。代理审查两者,归档过时的一条,并可选择更新当前的一条。
要保护记忆不被修剪,请添加 pinned 标签:
PATCH /api/v1/memory/:id
{ tags: [pinned, ...现有标签] }