context-loader
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseContext Loader
上下文加载器
Pre-fetches relevant memories to prime context before working on a task.
在处理任务前预获取相关记忆以初始化上下文。
When to use
使用场景
- Session start (invoke manually or auto-triggered by skill description matching)
- User starts work on a specific feature or file set
- Complex multi-step task begins
- User says "what do we know about X" or "context for X"
- 会话启动时(手动调用或通过技能描述匹配自动触发)
- 用户开始处理特定功能或文件集时
- 复杂多步骤任务启动时
- 用户询问“我们对X了解多少”或“X的上下文”时
Steps
操作步骤
-
Extract topics from current message/task. Identify: file paths, module names, feature areas, error patterns.
-
Run 2-4 parallelcalls with different angles:
search_memoriesQuery angle Filter Purpose Feature/module name {"AND": [{"user_id": "<id>"}, {"app_id": "<pid>"}, {"metadata": {"type": "decision"}}]}Architecture decisions File paths mentioned {"AND": [{"user_id": "<id>"}, {"app_id": "<pid>"}, {"metadata": {"type": "convention"}}]}Coding patterns Error keywords (if any) {"AND": [{"user_id": "<id>"}, {"app_id": "<pid>"}, {"metadata": {"type": "anti_pattern"}}]}Known pitfalls Broad project context {"AND": [{"user_id": "<id>"}, {"app_id": "<pid>"}]}Catch-all -
Deduplicate results by memory ID across all search responses.
-
Output compact context block (max 10 memories):
context-loader: loaded <N> memories for "<task summary>"
- [decision] <content> [mem0:<short_id>]
- [convention] <content> [mem0:<short_id>]
- [anti_pattern] <content> [mem0:<short_id>]- If zero results: output nothing. Don't announce empty context.
-
提取主题:从当前消息/任务中提取主题,识别文件路径、模块名称、功能领域、错误模式。
-
从不同角度并行调用2-4次:
search_memories查询角度 过滤器 用途 功能/模块名称 {"AND": [{"user_id": "<id>"}, {"app_id": "<pid>"}, {"metadata": {"type": "decision"}}]}架构决策 提及的文件路径 {"AND": [{"user_id": "<id>"}, {"app_id": "<pid>"}, {"metadata": {"type": "convention"}}]}编码模式 错误关键词(如有) {"AND": [{"user_id": "<id>"}, {"app_id": "<pid>"}, {"metadata": {"type": "anti_pattern"}}]}已知陷阱 宽泛项目上下文 {"AND": [{"user_id": "<id>"}, {"app_id": "<pid>"}]}全面覆盖 -
去重:根据记忆ID对所有搜索结果进行去重。
-
输出精简上下文块(最多10条记忆):
context-loader: loaded <N> memories for "<task summary>"
- [decision] <content> [mem0:<short_id>]
- [convention] <content> [mem0:<short_id>]
- [anti_pattern] <content> [mem0:<short_id>]- 如果无结果:不输出任何内容,不要告知上下文为空。
Constraints
约束条件
- Read-only — never modify or delete memories
- Max 10 memories returned (most relevant only)
- Silent on empty — only surfaces findings if relevant context exists
- Skip memories already visible in current session context
- 只读 — 绝不修改或删除记忆
- 最多返回10条记忆(仅返回最相关的)
- 无结果时静默 — 仅当存在相关上下文时才展示结果
- 跳过当前会话上下文中已可见的记忆