rlm
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseRecursive Language Model (RLM)
Recursive Language Model (RLM)
"Context is an external resource, not a local variable."
You are the Root Node. Your job is NOT to read code directly, but to orchestrate sub-agents that read code for you.
"上下文是外部资源,而非局部变量。"
你是根节点。你的任务不是直接读取代码,而是编排子Agent来替你读取代码。
The RLM Loop
RLM循环
Phase 1: Index & Filter
阶段1:索引与筛选
Identify relevant files without loading them into context.
bash
undefined在不将文件加载到上下文中的情况下识别相关文件。
bash
undefinedFind candidate files
Find candidate files
grep -rl "pattern" src/ --include=".ts"
find . -name ".py" -newer last_check
undefinedgrep -rl "pattern" src/ --include=".ts"
find . -name ".py" -newer last_check
undefinedPhase 2: Parallel Map
阶段2:并行映射
Split work into atomic units, spawn parallel agents.
- Launch 3-5+ agents in parallel for broad tasks
- Give each agent ONE specific file or chunk
- Each agent returns a structured summary
Example spawn:
Agent 1: "Read src/api/routes.ts. List all endpoints with their auth decorators."
Agent 2: "Read src/api/users.ts. List all endpoints with their auth decorators."
...将工作拆分为原子单元,启动并行Agent。
- 针对广泛任务启动3-5个及以上Agent并行处理
- 为每个Agent分配一个特定文件或代码块
- 每个Agent返回结构化摘要
启动示例:
Agent 1: "读取src/api/routes.ts文件,列出所有带有权限认证装饰器的端点。"
Agent 2: "读取src/api/users.ts文件,列出所有带有权限认证装饰器的端点。"
...Phase 3: Reduce & Synthesize
阶段3:归约与合成
Collect all agent outputs, find patterns, compile into a coherent answer.
If incomplete, recurse: run a second RLM pass on the specific gaps.
收集所有Agent的输出,查找模式,整理成连贯的结果。
如果结果不完整,则递归执行:针对特定空白点运行第二轮RLM流程。
Critical Rules
关键规则
- NEVER read more than 3-5 files into your main context
- ALWAYS use parallel agents when file count > 5
- Write Python scripts for state tracking across 50+ files — let the script scan and summarize
- If parallel agents are unavailable, fall back to iterative Python scripting
- 绝对不要将超过3-5个文件加载到主上下文中
- 当文件数量超过5个时,务必使用并行Agent
- 编写Python脚本来跟踪50个以上文件的状态——让脚本负责扫描和摘要
- 如果无法使用并行Agent,则退回到迭代式Python脚本
Example: "Find all API endpoints, check for Auth"
示例:"查找所有API端点,检查权限认证情况"
Wrong (monolithic): Read each file sequentially → context fills up, reasoning degrades.
RLM Way:
- → 20 files
grep -l "@Controller" src/**/*.ts - Spawn 20 agents, each extracts endpoints + auth status
- Collect outputs, compile table, identify missing auth
错误做法(单体式):依次读取每个文件 → 上下文被占满,推理能力下降。
RLM正确做法:
- → 得到20个文件
grep -l "@Controller" src/**/*.ts - 启动20个Agent,每个提取端点及权限认证状态
- 收集输出,整理成表格,识别缺失权限认证的情况
Output Format
输出格式
Return a structured summary:
- Findings table (file, pattern, status)
- Gaps identified (what needs deeper investigation)
- Confidence level (how complete the scan was)
返回结构化摘要:
- 发现表格(文件、模式、状态)
- 识别出的空白点(需要深入调查的内容)
- 置信度(扫描的完整程度)
Skill Boundaries
技能边界
Excels for: Codebases >100 files, cross-file pattern search, audit tasks, large file analysis.
Not ideal for: Small projects (<50 files), single file analysis, file modification tasks.
擅长场景: 超过100个文件的代码库、跨文件模式搜索、审计任务、大型文件分析。
不适用场景: 小型项目(少于50个文件)、单文件分析、文件修改任务。