fanout
Dispatch the same query to multiple subagents in parallel across chunks in a manifest and aggregate results with source provenance
What this skill does
# Fanout
Dispatch the same query to multiple subagents in parallel, each processing one chunk from a chunk manifest. Aggregates results with source provenance — every answer is tagged with which chunk it came from.
## Triggers
Alternate expressions and non-obvious activations:
- "search all chunks" → fanout query across manifest
- "run in parallel across the chunks" → fanout with current manifest
- "ask each piece this question" → fanout with default parallelism
- "parallel grep" → fanout with a pattern as the query
## Trigger Patterns Reference
| Pattern | Example | Action |
|---------|---------|--------|
| Fanout search | "search all chunks for authentication bugs" | Fanout query across manifest |
| Explicit chunks dir | "fanout across .aiwg/rlm-chunks/auth/" | `--chunks .aiwg/rlm-chunks/auth/` |
| Limit parallelism | "search chunks, max 2 at a time" | `--max-parallel 2` |
| Synthesis request | "search all chunks and give me one answer" | `--synthesize` |
| Model selection | "use haiku to search the chunks" | `--model haiku` |
| Manifest path | "fanout using manifest.json" | `--chunks manifest.json` |
## Behavior
When triggered:
1. **Parse arguments** — extract query, chunks path (directory or manifest), parallelism limit, model, and synthesis flag.
2. **Load manifest** — read `manifest.json` from the chunks directory, or use the provided manifest path directly. Validate that chunk files exist.
3. **Respect context budget** — if `AIWG_CONTEXT_WINDOW` is set, cap `--max-parallel` at the budget-appropriate limit per the context-budget rule. Default cap is 4 parallel subagents.
4. **Dispatch subagents** — launch up to `--max-parallel` subagents simultaneously. Each subagent:
- Receives the query and exactly one chunk's content
- Is instructed to answer only from that chunk's content
- Returns a structured result: `{ chunk_id, answer, confidence, relevant_lines }`
5. **Wait for all subagents** — collect results as they complete. Track which chunks returned answers vs. "not found in this chunk".
6. **Aggregate with provenance** — compile results into a provenance-tagged list. Each entry shows:
- The answer or finding
- The chunk it came from (`chunk-0003`)
- The source lines within that chunk
- Confidence level (high / medium / low)
7. **Optionally synthesize** — if `--synthesize` is set, pass all results to a synthesis subagent that merges them into a single coherent answer.
8. **Report result** — print the aggregated findings with provenance, or the synthesized answer.
### Aggregated Result Format
```
Fanout Query: "Where is the token refresh logic?"
Chunks searched: 8 | Matches found: 3 | Model: haiku
Matches:
[chunk-0002] lines 45-67 — HIGH confidence
Token refresh is handled in `AuthMiddleware.refreshToken()`.
The method checks expiry, calls `/auth/refresh`, and updates the
session cookie on success.
[chunk-0005] lines 112-118 — MEDIUM confidence
`refreshToken()` is called from the React hook `useSession`
when the access token has less than 60 seconds remaining.
[chunk-0007] lines 203-208 — LOW confidence
Environment variable REFRESH_INTERVAL_MS controls refresh
frequency. Default: 300000 (5 minutes).
Chunks with no match: chunk-0001, chunk-0003, chunk-0004, chunk-0006, chunk-0008
```
### Synthesized Result Format (--synthesize)
```
Fanout Query: "Where is the token refresh logic?"
Synthesis from 3 matching chunks:
Token refresh is implemented in `AuthMiddleware.refreshToken()` (chunk-0002,
lines 45-67). The React layer triggers refresh via the `useSession` hook when
the access token has less than 60 seconds remaining (chunk-0005, lines 112-118).
Refresh interval is configurable via REFRESH_INTERVAL_MS (default: 5 minutes,
chunk-0007, lines 203-208).
```
## Parameters
- `<query>` — Natural language question or task to answer using the chunks (required)
- `--chunks <dir|manifest.json>` — Path to chunks directory or manifest file (default: `.aiwg/rlm-chunks/`)
- `--max-parallel N` — Max simultaneously active subagents (default: `4`, bounded by context budget). Alias `--parallel` is accepted for one release cycle and emits a deprecation warning; remove it after the next stable release.
- `--model haiku|sonnet|opus` — Model for subagents (default: `haiku` for cost efficiency)
- `--synthesize` — After collecting results, synthesize into a single answer
## Examples
### Example 1: Basic fanout search
**User**: "fanout search across the auth chunks: where is token expiry checked?"
**Action**: Dispatch query to each chunk in `.aiwg/rlm-chunks/auth/`, 4 parallel subagents using haiku.
**Response**:
```
Fanout Query: "where is token expiry checked?"
Chunks searched: 6 | Matches found: 2 | Model: haiku
Matches:
[chunk-0002] lines 88-95 — HIGH confidence
Token expiry is checked in `validateToken()` by comparing
`token.exp` against `Date.now() / 1000`.
[chunk-0004] lines 31-38 — MEDIUM confidence
JWT middleware also checks expiry via the `express-jwt`
`credentialsRequired` option, which rejects expired tokens
before reaching route handlers.
Chunks with no match: chunk-0001, chunk-0003, chunk-0005, chunk-0006
```
---
### Example 2: Synthesized answer
**User**: "search all chunks for how errors are logged, and give me one answer"
**Action**:
```bash
aiwg fanout "how are errors logged?" --chunks .aiwg/rlm-chunks/api/ --synthesize
```
**Response**:
```
Synthesis from 4 matching chunks:
Errors are logged through three mechanisms: (1) the `logger.error()` wrapper
in `src/utils/logger.ts` formats structured JSON logs with request ID and stack
trace (chunk-0001, lines 12-28); (2) unhandled exceptions are caught by the
Express error handler in `src/middleware/error.ts` and forwarded to the logger
(chunk-0003, lines 55-71); (3) async errors in service classes use the
`@LogError` decorator (chunk-0006, lines 9-18).
```
---
### Example 3: Budget-constrained fanout
**User**: "parallel search the chunks but only 2 at a time — system is under load"
**Action**:
```bash
aiwg fanout "find all database connection setup" --chunks .aiwg/rlm-chunks/services/ --max-parallel 2
```
**Response**: Runs subagents in batches of 2. Reports matches with provenance after all 9 chunks are processed.
---
### Example 4: Expensive query on a large chunk set
**User**: "fanout across all the migration chunks using sonnet — I need precise SQL analysis"
**Action**:
```bash
aiwg fanout "find any ALTER TABLE statements that drop columns" \
--chunks .aiwg/rlm-chunks/migrations/ \
--model sonnet \
--synthesize
```
**Response**: Dispatches sonnet subagents, synthesizes findings with exact line references.
## Clarification Prompts
If the user's intent is ambiguous:
- "Which chunks directory should I search? (found: `.aiwg/rlm-chunks/`)"
- "Should I synthesize the results into one answer, or list all matches with provenance?"
- "How many parallel subagents? Default is 4 (use `--max-parallel N` to override)."
## References
- @$AIWG_ROOT/agentic/code/addons/rlm/skills/chunk/SKILL.md — Produce the chunk manifest fanout reads
- @$AIWG_ROOT/agentic/code/addons/rlm/skills/rlm-search/SKILL.md — Full pipeline (prep + fanout + synthesize)
- @$AIWG_ROOT/agentic/code/addons/aiwg-utils/rules/context-budget.md — Parallel budget constraints
- @$AIWG_ROOT/agentic/code/addons/aiwg-utils/rules/subagent-scoping.md — Subagent isolation rules
- @$AIWG_ROOT/agentic/code/addons/rlm/schemas/rlm-chunk-manifest.yaml — Manifest schema
Related in General
modeling-omnistudio-epc-catalog
IncludedSalesforce Industries CME EPC product-modeling skill for Product2-based catalog creation. Use when creating EPC products, configuring product attributes, building offer bundles with Product Child Items, or reviewing EPC DataPack JSON metadata for product catalog changes. TRIGGER when: user creates or updates Product2 EPC records, AttributeAssignment payloads, AttributeMetadata/AttributeDefaultValues, Offer bundles, or ProductChildItem relationships. DO NOT TRIGGER when: designing OmniScripts/FlexCards/Integration Procedures (use building-omnistudio-omniscript, building-omnistudio-flexcard, or building-omnistudio-integration-procedure), implementing Apex business logic (use generating-apex), or troubleshooting deployment pipelines (use deploying-metadata).
relationship-science-coach
IncludedUse this skill for direct, practical adult relationship coaching: couples conflict, repair, trust, marriage, dating, flirting, attachment patterns, emotional connection, sex, desire differences, eroticism, kink negotiation, affection, love languages, breakups, and long-term passion. Draw on Gottman, EFT and Hold Me Tight, attachment science, modern sex research, Perel, Nagoski, Kerner, Schnarch, Love and Stosny, and flexible love-language tools. Be concrete and low-hedge. Redirect only for imminent danger, abuse, coercive control, minors, non-consent, self-harm, stalking, or medical/legal/psychiatric decisions.
building-sf-integrations
IncludedSalesforce integration architecture and runtime plumbing with 120-point scoring. Use this skill to set up Named Credentials, External Credentials, External Services, REST/SOAP callout patterns, Platform Events, and Change Data Capture. TRIGGER when: user sets up Named Credentials, External Services, REST/SOAP callouts, Platform Events, CDC, or touches .namedCredential-meta.xml files. DO NOT TRIGGER when: Connected App/OAuth config (use configuring-connected-apps), Apex-only logic (use generating-apex), or data import/export (use handling-sf-data).
venue-templates
IncludedAccess comprehensive LaTeX templates, formatting requirements, and submission guidelines for major scientific publication venues (Nature, Science, PLOS, IEEE, ACM), academic conferences (NeurIPS, ICML, CVPR, CHI), research posters, and grant proposals (NSF, NIH, DOE, DARPA). This skill should be used when preparing manuscripts for journal submission, conference papers, research posters, or grant proposals and need venue-specific formatting requirements and templates.
let-fate-decide
IncludedDraws the 12 Houses of the Zodiac Tarot spread to inject entropy into planning when prompts are vague, ambiguous, or casually delegated. Interprets the spread to guide next steps. Use when the user says 'let fate decide', 'YOLO', 'whatever', 'idk', or other nonchalant phrases, makes Yu-Gi-Oh references, or when you are about to arbitrarily pick between multiple reasonable approaches. Prefer over ask-questions-if-underspecified when the user's tone is casual or playful rather than precision-seeking.
net-ops
IncludedCross-platform network troubleshooting (Windows, macOS, Linux) via local or remote shell. Use for: DNS broken, can't resolve hostnames, nslookup/dig works but apps fail, NRPT, WFP, scutil, /etc/resolver, systemd-resolved, /etc/resolv.conf, NetworkManager, VPN DNS leak residue (ProtonVPN/Mullvad/WireGuard/AnyConnect), AV/firewall blocking DNS or DoH, Tailscale DNS interaction, intermittent connectivity, remote diagnostics over SSH.