letheClaw — Agent memory
You can use the letheClaw API to store and retrieve memories for the user or the current session. The API base URL is in the environment variable LETHECLAWAPIURL.
Environment patterns:
- - Docker Compose with letheClaw API container: INLINECODE0
- Host machine from Docker Desktop (Windows/Mac): INLINECODE1
- Local testing (same machine): INLINECODE2
If LETHECLAWAPIURL is unset, try http://host.docker.internal:51234 first (Docker Desktop default), then ask the user.
⚠️ PROTOCOL (NON-NEGOTIABLE)
Retrieval Rule
When the user asks about
history, decisions, prior work, "what did we do", or any past context:
- 1. ALWAYS query letheClaw API FIRST:
CODEBLOCK0
- 2. Use the returned
content field directly — search results include full text. No need for memory_get or flat file access.
- 3. NEVER use
memory_search tool as the first step. That tool searches flat markdown files, which are backup/reference only.
- 4. Apply criticality filtering when appropriate:
- Security/config: add
&min_criticality=0.7
- General recall: add
&min_criticality=0.5
- Exploratory: no filter
- 5. Use tag pre-filtering when query domain is clear (e.g.,
tags=moltbook for Moltbook questions).
- 6. letheClaw is the authoritative memory system. Flat files may be stale or incomplete.
Storage Rule
When the user says "log this", "remember that", or you observe something worth recording:
- 1. POST to letheClaw API (see "Store a memory" below)
- Assign appropriate criticality: 0.3 (transient) → 0.5 (useful) → 0.7 (important) → 0.9 (critical)
- Tag precisely: 2-5 specific tags (type + domain, e.g.
["episodic", "security", "moltbook"]) - Set source:
operator_input (user said it), direct_observation (you verified it), inferred (derived)
No exceptions. This is operator-mandated protocol.
Store a memory
- - POST INLINECODE14
- Body (JSON):
content (required), optional: source (e.g. operator_input, direct_observation, inferred), tags (array), operator, session_key, INLINECODE23 - Returns:
memory_id (UUID). Save it to update criticality or fetch provenance later.
Search memories (semantic)
- - GET INLINECODE25
- Optional:
min_criticality (0–1) to filter by importance. - Optional:
tags (comma-separated) to pre-filter by tag before semantic search (e.g. tags=moltbook,security) - Returns:
results array with id, content (full text), criticality, tags, source, created_at, INLINECODE36
Important: Search results include full content — you do NOT need to call memory_get afterward. Use the returned content directly.
Criticality filtering guidance:
- - Security/config queries:
min_criticality=0.7 (critical knowledge only) - General recall:
min_criticality=0.5 (useful and above) - Exploratory search: no filter (all results)
Tag pre-filtering (performance optimization):
When query intent is clear, pre-filter by tags to reduce search space:
CODEBLOCK1
Recent memories
- - GET INLINECODE39
- Returns: Recently stored memories (from cache or DB).
Update criticality (manual)
- - POST INLINECODE40
- Body (JSON):
criticality (0–1, required), optional INLINECODE42 - Use when the user or you want to mark a memory as more or less important.
Mark operator correction
- - POST INLINECODE43
- No body. Call when the user corrects something about this memory; this boosts criticality and increments a correction counter so provenance shows how often it was corrected.
Get provenance
- - GET INLINECODE44
- Returns: Full memory object plus
events (history of criticality changes: manualboost, operatorcorrection, etc.) and correction_count.
Errors
- - 400 — Invalid request or invalid memory ID format.
- 404 — Memory not found (wrong or deleted ID).
- 5xx — Server/upstream error; suggest checking if letheClaw is running and reachable.
When the user says they want to remember something, search memory, see why a memory is important, or correct a memory, use the appropriate endpoint above.
letheClaw — 智能体记忆
您可以使用letheClaw API为用户或当前会话存储和检索记忆。API基础URL位于环境变量 LETHECLAWAPIURL 中。
环境模式:
- - 包含letheClaw API容器的Docker Compose:http://api:8080
- Docker Desktop(Windows/Mac)中的宿主机:http://host.docker.internal:51234
- 本地测试(同一台机器):http://localhost:51234
如果LETHECLAWAPIURL未设置,请先尝试 http://host.docker.internal:51234(Docker Desktop默认值),然后询问用户。
⚠️ 协议(不可协商)
检索规则
当用户询问关于
历史记录、决策、先前工作、我们做了什么或任何过往上下文时:
- 1. 始终先查询letheClaw API:
bash
curl -s {LETHECLAW
APIURL}/memory/search?q=<查询词>&limit=5
- 2. 直接使用返回的 content 字段 — 搜索结果包含完整文本。无需调用 memory_get 或访问平面文件。
- 3. 切勿将 memory_search 工具作为第一步。 该工具搜索的是平面Markdown文件,这些文件仅作为备份/参考。
- 4. 在适当时应用关键性过滤:
- 安全/配置:添加 &min_criticality=0.7
- 一般回忆:添加 &min_criticality=0.5
- 探索性:不过滤
- 5. 当查询领域明确时使用标签预过滤(例如,Moltbook相关问题使用 tags=moltbook)。
- 6. letheClaw是权威记忆系统。 平面文件可能已过时或不完整。
存储规则
当用户说记录这个、记住那个,或您观察到值得记录的内容时:
- 1. 向letheClaw API发送POST请求(见下方存储记忆)
- 分配适当的关键性: 0.3(临时)→ 0.5(有用)→ 0.7(重要)→ 0.9(关键)
- 精确标记: 2-5个具体标签(类型+领域,例如 [episodic, security, moltbook])
- 设置来源: operatorinput(用户所述)、directobservation(您已验证)、inferred(推导得出)
无例外。 这是操作员强制执行的协议。
存储记忆
- - POST {LETHECLAWAPIURL}/memory
- 请求体(JSON): content(必填),可选:source(例如 operatorinput、directobservation、inferred)、tags(数组)、operator、sessionkey、context
- 返回: memoryid(UUID)。保存此ID以便后续更新关键性或获取溯源信息。
搜索记忆(语义搜索)
- - GET {LETHECLAWAPIURL}/memory/search?q={查询词}&limit=5
- 可选:mincriticality(0–1)按重要性过滤。
- 可选:tags(逗号分隔)在语义搜索前按标签预过滤(例如 tags=moltbook,security)
- 返回: results 数组,包含 id、content(完整文本)、criticality、tags、source、createdat、access_count
重要提示: 搜索结果包含完整内容 — 您无需在之后调用memory_get。直接使用返回的内容。
关键性过滤指南:
- - 安全/配置查询:mincriticality=0.7(仅关键知识)
- 一般回忆:mincriticality=0.5(有用及以上)
- 探索性搜索:不过滤(所有结果)
标签预过滤(性能优化):
当查询意图明确时,按标签预过滤以减少搜索空间:
bash
最新的Moltbook帖子
curl {LETHECLAW
APIURL}/memory/search?q=posts&tags=moltbook,episodic&limit=5
安全发现
curl {LETHECLAW
APIURL}/memory/search?q=findings&tags=security,semantic&min_criticality=0.7&limit=3
最近记忆
- - GET {LETHECLAWAPIURL}/memory/recent
- 返回: 最近存储的记忆(来自缓存或数据库)。
更新关键性(手动)
- - POST {LETHECLAWAPIURL}/memory/{memory_id}/criticality
- 请求体(JSON): criticality(0–1,必填),可选 reason
- 当用户或您希望将某条记忆标记为更重要或更不重要时使用。
标记操作员更正
- - POST {LETHECLAWAPIURL}/memory/{memory_id}/correction
- 无请求体。当用户更正与此记忆相关的内容时调用;这会提升关键性并增加更正计数器,以便溯源信息显示其被更正的频率。
获取溯源信息
- - GET {LETHECLAWAPIURL}/memory/{memoryid}/provenance
- 返回: 完整记忆对象,外加 events(关键性变更历史:manualboost、operatorcorrection等)和 correctioncount。
错误
- - 400 — 无效请求或无效记忆ID格式。
- 404 — 未找到记忆(ID错误或已删除)。
- 5xx — 服务器/上游错误;建议检查letheClaw是否正在运行且可访问。
当用户表示想要记住某些内容、搜索记忆、查看某条记忆为何重要或更正某条记忆时,请使用上述相应的端点。