通过逐步细化检索上下文,提升子代理任务理解与结果质量。
复制安装指令,让 AI 自动完成配置 · 推荐新手
请帮我安装 askskill 上的 "iterative-retrieval" 技能: 1. 下载 https://raw.githubusercontent.com/affaan-m/ECC/main/skills/iterative-retrieval/SKILL.md 2. 保存为 ~/.claude/skills/iterative-retrieval/SKILL.md 3. 装好后重载技能,告诉我可以用了
请使用 iterative-retrieval 模式,先根据我的任务拆出关键信息需求,再分轮检索代码库、接口文档和历史决策记录。每轮总结缺失信息,并在信息足够后给出最终实现方案。任务:为支付模块新增退款状态回调处理。
输出分阶段检索过程、每轮缺口分析,以及基于充分上下文的实现方案。
请用 iterative-retrieval 方法排查这个问题:生产环境某个异步任务偶发超时。先检索日志特征,再检索相关服务代码、队列配置和近期变更记录,逐步缩小范围,最后给出最可能原因和验证步骤。
输出逐步收敛的排查路径、关键证据、最可能根因及验证建议。
请采用 iterative-retrieval 技能,针对“是否要重构用户权限系统”这个问题,先列出需要的背景信息,再分轮检索需求文档、现有架构说明、事故记录和团队反馈,最后形成决策建议。
输出信息需求清单、分轮检索摘要,以及有依据的决策建议。
Solves the "context problem" in multi-agent workflows where subagents don't know what context they need until they start working.
Subagents are spawned with limited context. They don't know:
Standard approaches fail:
A 4-phase loop that progressively refines context:
┌─────────────────────────────────────────────┐
│ │
│ ┌──────────┐ ┌──────────┐ │
│ │ DISPATCH │─────│ EVALUATE │ │
│ └──────────┘ └──────────┘ │
│ ▲ │ │
│ │ ▼ │
│ ┌──────────┐ ┌──────────┐ │
│ │ LOOP │─────│ REFINE │ │
│ └──────────┘ └──────────┘ │
│ │
│ Max 3 cycles, then proceed │
└─────────────────────────────────────────────┘
Initial broad query to gather candidate files:
// Start with high-level intent
const initialQuery = {
patterns: ['src/**/*.ts', 'lib/**/*.ts'],
keywords: ['authentication', 'user', 'session'],
excludes: ['*.test.ts', '*.spec.ts']
};
// Dispatch to retrieval agent
const candidates = await retrieveFiles(initialQuery);
Assess retrieved content for relevance:
function evaluateRelevance(files, task) {
return files.map(file => ({
path: file.path,
relevance: scoreRelevance(file.content, task),
reason: explainRelevance(file.content, task),
missingContext: identifyGaps(file.content, task)
}));
}
Scoring criteria:
Update search criteria based on evaluation:
function refineQuery(evaluation, previousQuery) {
return {
// Add new patterns discovered in high-relevance files
patterns: [...previousQuery.patterns, ...extractPatterns(evaluation)],
// Add terminology found in codebase
keywords: [...previousQuery.keywords, ...extractKeywords(evaluation)],
// Exclude confirmed irrelevant paths
excludes: [...previousQuery.excludes, ...evaluation
.filter(e => e.relevance < 0.2)
.map(e => e.path)
],
// Target specific gaps
focusAreas: evaluation
.flatMap(e => e.missingContext)
.filter(unique)
};
}
Repeat with refined criteria (max 3 cycles):
async function iterativeRetrieve(task, maxCycles = 3) {
let query = createInitialQuery(task);
let bestContext = [];
for (let cycle = 0; cycle < maxCycles; cycle++) {
const candidates = await retrieveFiles(query);
const evaluation = evaluateRelevance(candidates, task);
// Check if we have sufficient context
const highRelevance = evaluation.filter(e => e.relevance >= 0.7);
if (highRelevance.length >= 3 && !hasCriticalGaps(evaluation)) {
return highRelevance;
}
// Refine and continue
query = refineQuery(evaluation, query);
bestContext = mergeContext(bestContext, highRelevance);
}
return bestContext;
}
…
通过双评审智能体对结果进行对抗式校验,提升输出发布前的可靠性
通过为每个任务分派独立子代理并穿插代码审查,稳步推进实现计划。