ワンクリックで
iterative-retrieval
Pattern for progressively refining context retrieval to solve the subagent context problem
Codex または Claude でインストール この Prompt をコピーして Codex、Claude、または他のアシスタントに貼り付けると、Skill ページを確認してインストールできます。
メニュー
Pattern for progressively refining context retrieval to solve the subagent context problem
Codex または Claude でインストール この Prompt をコピーして Codex、Claude、または他のアシスタントに貼り付けると、Skill ページを確認してインストールできます。
SOC 職業分類に基づく
The Evaluate-Loop coordinator for soe. Runs the BRAINSTORM → PLAN → EVALUATE_PLAN → EXECUTE → EVALUATE_EXEC → (FIX↺ | COMPLETE) state machine for a track: dispatches leaf agents, dispatches workers into isolated worktrees and applies their validated returns serially, and is the SOLE writer of .soe/tracks/{id}/state.json. Resumes crash-safely from committed state and bounds its fix/plan loops. Use when: 'run the loop', 'orchestrate', 'run the track', 'evaluate-loop', 'drive the track to completion'.
Session-model-led multi-model tiering. Use in ANY conversation (ambient) or in the pipeline to decide which model tier does which slice of work, and to delegate to the right model-pinned agent (strategist/deep-reasoner/fast-worker). The session model you selected IS the orchestrator; it self-selects its topology from its own model identity.
Use when the orchestrator needs to delegate an implementation task to an isolated worker — dispatches each worker as a Task-tool subagent in its own git worktree, awaits its return as the completion signal, and applies results serially as the sole state.json writer behind a validated context firewall
Use when about to claim work is complete, fixed, or passing, before committing or creating PRs - requires running verification commands and confirming output before making any success claims; evidence before assertions always
Use when creating new skills, editing existing skills, or verifying skills work before deployment
Use at run start to discover what reviewers/analyzers/generators any installed plugin provides and route work by ROLE. Builds a role→provider map via lib/capability-scan.js so the loop prefers the best-matching installed specialist (a Go reviewer, a Flutter reviewer, AgentShield, ...) and falls back to soe-core's generic (soe:code-reviewer, soe:security-reviewer, soe:architect, ...) when none is installed. soe-core is self-sufficient and NEVER hard-depends on packs.
| name | iterative-retrieval |
| description | Pattern for progressively refining context retrieval to solve the subagent context problem |
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;
}
Task: "Fix the authentication token expiry bug"
Cycle 1:
DISPATCH: Search for "token", "auth", "expiry" in src/**
EVALUATE: Found auth.ts (0.9), tokens.ts (0.8), user.ts (0.3)
REFINE: Add "refresh", "jwt" keywords; exclude user.ts
Cycle 2:
DISPATCH: Search refined terms
EVALUATE: Found session-manager.ts (0.95), jwt-utils.ts (0.85)
REFINE: Sufficient context (2 high-relevance files)
Result: auth.ts, tokens.ts, session-manager.ts, jwt-utils.ts
Task: "Add rate limiting to API endpoints"
Cycle 1:
DISPATCH: Search "rate", "limit", "api" in routes/**
EVALUATE: No matches - codebase uses "throttle" terminology
REFINE: Add "throttle", "middleware" keywords
Cycle 2:
DISPATCH: Search refined terms
EVALUATE: Found throttle.ts (0.9), middleware/index.ts (0.7)
REFINE: Need router patterns
Cycle 3:
DISPATCH: Search "router", "express" patterns
EVALUATE: Found router-setup.ts (0.8)
REFINE: Sufficient context
Result: throttle.ts, middleware/index.ts, router-setup.ts
Use in agent prompts:
When retrieving context for this task:
1. Start with broad keyword search
2. Evaluate each file's relevance (0-1 scale)
3. Identify what context is still missing
4. Refine search criteria and repeat (max 3 cycles)
5. Return files with relevance >= 0.7
soe:soe-workers - Context firewall for isolated workers; this skill complements it by letting a worker fetch context progressively.soe:continuous-learning-v2 skill - For patterns that improve over time.agents/.