SwarmRecall Learnings
Error tracking, correction logging, and pattern detection 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 - Learning data (errors, corrections, discoveries) 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
Log a learning
CODEBLOCK2
Search learnings
CODEBLOCK3
Get a learning
CODEBLOCK4
List learnings
CODEBLOCK5
Update a learning
CODEBLOCK6
Get recurring patterns
CODEBLOCK7
Get promotion candidates
CODEBLOCK8
Link related learnings
CODEBLOCK9
Behavior
- - On error: call
POST /api/v1/learnings with category: "error", the summary, details, and the command/output that failed. - On correction: call
POST /api/v1/learnings with category: "correction" and what was wrong vs. what is correct. - On session start: call
GET /api/v1/learnings/patterns to preload known recurring issues. Check GET /api/v1/learnings/promotions for patterns ready to be promoted. - On promotion candidates: surface candidates to the user for approval before acting on them.
Shared Pools
- - The
POST /api/v1/learnings endpoint accepts an optional "poolId" field. - When
poolId is provided, the learning is shared with all pool members who have learnings read access. - The agent must have readwrite access to the pool's learnings module to write shared learnings.
- Search (
GET /api/v1/learnings/search) and list (GET /api/v1/learnings) 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
Learnings benefit from dream-time promotion:
- - Promotion candidates: The existing
GET /api/v1/learnings/promotions endpoint surfaces patterns meeting promotion criteria (3+ recurrences, 2+ sessions, within 30 days). During a dream cycle, the agent reads each candidate, synthesizes a best-practice learning, and creates it via POST /api/v1/learnings with category: "best_practice" and status: "promoted". - Pattern consolidation: Related learnings are already linked via
POST /api/v1/learnings/:id/link. During dreaming, the agent can review patterns and archive individual learnings that are fully subsumed by the promoted best practice.
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/learnings
{
category: error, // error | correction | discovery | optimization | preference
summary: npm install 因对等依赖失败,
details: 完整错误输出...,
priority: high, // low | medium | high | critical
area: build,
suggestedAction: 使用 --legacy-peer-deps 标志,
tags: [npm, build],
metadata: {},
poolId: // 可选——写入共享池
}
搜索学习记录
GET /api/v1/learnings/search?q=<查询>&limit=10&minScore=0.5
获取一条学习记录
GET /api/v1/learnings/:id
列出学习记录
GET /api/v1/learnings?category=error&status=open&priority=high&area=build&limit=20&offset=0
更新一条学习记录
PATCH /api/v1/learnings/:id
{ status: resolved, resolution: 添加了 --legacy-peer-deps, resolutionCommit: abc123 }
获取重复模式
GET /api/v1/learnings/patterns
获取推广候选
GET /api/v1/learnings/promotions
关联相关学习记录
POST /api/v1/learnings/:id/link
{ targetId: <其他学习记录ID> }
行为
- - 发生错误时:调用 POST /api/v1/learnings,设置 category: error,包含摘要、详细信息以及失败的命令/输出。
- 进行修正时:调用 POST /api/v1/learnings,设置 category: correction,说明错误内容与正确内容。
- 会话开始时:调用 GET /api/v1/learnings/patterns 预加载已知的重复问题。检查 GET /api/v1/learnings/promotions 以获取准备推广的模式。
- 对于推广候选:在采取行动前,将候选内容呈现给用户以获得批准。
共享池
- - POST /api/v1/learnings 端点接受可选的 poolId 字段。
- 当提供了 poolId 时,该学习记录将与所有具有学习记录读取权限的池成员共享。
- 代理必须拥有池中学习记录模块的读写权限,才能写入共享学习记录。
- 搜索(GET /api/v1/learnings/search)和列表(GET /api/v1/learnings)结果会自动包含代理所属池中的数据。
- 响应中的池数据包含 poolId 和 poolName 字段,用于区分共享数据与代理自身的数据。
梦境集成
学习记录受益于梦境时段的推广:
- - 推广候选:现有的 GET /api/v1/learnings/promotions 端点会筛选出满足推广条件的模式(3次以上重复、2个以上会话、30天内)。在梦境周期中,代理读取每个候选,综合形成最佳实践学习记录,并通过 POST /api/v1/learnings 创建,设置 category: best_practice 和 status: promoted。
- 模式整合:相关的学习记录已通过 POST /api/v1/learnings/:id/link 进行关联。在梦境期间,代理可以审查模式,并归档那些完全被推广的最佳实践所涵盖的单个学习记录。