$curl -o .claude/agents/research-loop.md https://raw.githubusercontent.com/Oshayr/LLM-Wiki/HEAD/agents/research-loop.mdAutonomous iterative research loop — hypothesis, search, ingest, evaluate, keep/discard via checkpoint. Max 3 iterations.
| 1 | Run an autonomous research loop: generate hypotheses, search, ingest to wiki, evaluate quality, keep or discard via checkpoint. Max 3 iterations by default. Stops on metric plateau or question saturation. |
| 2 | |
| 3 | ## Setup |
| 4 | |
| 5 | Resolve `.wiki/` from plugin install scope. |
| 6 | Read the research program (provided by caller): topic, seed questions, search strategy. |
| 7 | |
| 8 | ## Iteration Loop |
| 9 | |
| 10 | ### 1. Checkpoint Baseline |
| 11 | Create a checkpoint of current `.wiki/` state as a rollback point. |
| 12 | |
| 13 | ### 2. Generate Hypotheses |
| 14 | From the program's seed questions and any remaining open questions from `.wiki/overview.md`: |
| 15 | - Pick the 2-3 most promising questions for this iteration |
| 16 | - Generate search queries targeting these specific questions |
| 17 | |
| 18 | ### 3. Search |
| 19 | Launch `search-orchestrator` with the queries. Receive ranked, deduplicated results. |
| 20 | |
| 21 | ### 4. Ingest |
| 22 | For each top result: launch `wiki-writer` (mode: ingest) to compile into wiki pages. |
| 23 | |
| 24 | ### 5. Evaluate |
| 25 | After ingestion, assess: |
| 26 | - **Questions answered**: how many of the iteration's questions got substantive answers? |
| 27 | - **New questions discovered**: did the results open new interesting directions? |
| 28 | - **Confidence changes**: did any pages get upgraded/downgraded? |
| 29 | - **Contradiction count**: any new contradictions flagged? |
| 30 | |
| 31 | ### 6. Keep or Discard |
| 32 | - If quality metrics improved (questions answered > 0, net confidence up): **keep** (commit changes) |
| 33 | - If no meaningful progress or quality degraded: **discard** (rollback to baseline) |
| 34 | - If metric plateau (same scores as last iteration): **stop** — further iterations won't help |
| 35 | |
| 36 | ### 7. Continue or Stop |
| 37 | - If iteration < max (3): continue to next iteration with updated questions |
| 38 | - If question saturation (all seed questions answered): stop early |
| 39 | - If metric plateau: stop early |
| 40 | |
| 41 | ## Output |
| 42 | |
| 43 | After the loop completes: |
| 44 | - Write a deep-dive summary page to `.wiki/pages/<topic>-deep-dive.md` |
| 45 | - Include: questions answered, wiki coverage assessment, confidence levels, open questions remaining |
| 46 | - Update `.wiki/log.md` with iteration summary |
| 47 | |
| 48 | ## Rules |
| 49 | - Maximum 3 iterations by default (caller can override) |
| 50 | - Always create checkpoint baseline before each iteration |
| 51 | - Discard iterations that don't improve quality |
| 52 | - Stop early if questions are saturated or metrics plateau |
| 53 | - Report: iterations run, questions answered, pages added/updated, final confidence |