Files
Claude 2d3a29e4b3 Apply lessons from studying real GitHub projects
Studied via direct fetches: SakanaAI/AI-Scientist-v2, WecoAI/aideml,
anthropics/skills, obra/superpowers, UniM0cha/claude-self-improving-
skills, SamuelSchmidgall/AgentLaboratory, princeton-nlp/SWE-agent,
openai/preparedness (PaperBench), open-mmlab/mmsegmentation,
facebookresearch/dinov2, karpathy/nanoGPT. Applied the top verified
findings:

- extract_commands: join backslash-continued commands (every dinov2 run
  command was previously truncated to an unrunnable `python ... \` stub)
  and classify entrypoint-first with word-boundary keywords (nanoGPT's
  `train.py ... --eval_iters=20` classified as evaluation, which would
  execute training while bypassing the authorization gate). Quick-start
  sections now count as run sections. Both real-repo patterns added as
  regression fixtures.
- research-thinking-loop: draft/debug/improve iteration types with a
  3-attempt debug cap (AIDE journal semantics), no-parsed-metric ⇒ buggy
  and never best, replication across 3 seeds before a candidate replaces
  current_research (AI-Scientist-v2 multi-seed evaluation), metric-only
  best selection note, typed stop reasons, defaults table, ledger-first
  grounding.
- annotate_readme: PaperBench-style evidence tiers per annotation
  (code-development / execution / result-match) and a weighted 0-1
  reproduction score in the header chip and readme_section_coverage.
- lessons_store: touch/prune lifecycle with usage-extended staleness
  windows, credential-shape blocklist (AKIA/ghp_/sk-/xox/AIza),
  best-effort security wording, what-NOT-to-record and human-reviewed
  promotion flow in the policy.
- Demo bundles and preview images regenerated with score and tiers.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HT2VAaQodjqTJdjBHSStxA
2026-07-26 18:22:07 +00:00

4.1 KiB
Raw Permalink Blame History

Research Thinking Loop

Modern agents implement well but think in engineering steps. This loop is the required thinking spine for exploratory research work: a greedy, evidence-grounded cycle from observation to a fair keep-or-rollback decision. It adapts the greedy solution-space search of AIDE and the managed agentic tree search of AI-Scientist-v2 to RigorPilot's comparability-first rules.

The loop

Each iteration improves on the current best state (current_research) by at most one deliberate change.

  1. Observe. Read the latest run evidence: metrics, curves, failures, ledger entries. State what is surprising or limiting, in one sentence.
  2. Ground. Before proposing anything, search for support — starting with the experiment ledger (prior runs are the cheapest evidence), then paper claims (lookup records), source implementations, or an explicitly labeled experimental intuition. Every hypothesis must cite at least one anchor and label it paper, code, prior-run, or intuition. Unanchored ideas go to the idea bank, not to execution.
  3. Choose the iteration type.
    • draft: no working candidate exists yet — propose a fresh minimal approach (start 23 independent drafts before committing to one line).
    • debug: the last run is buggy (crash, or no parsed primary metric) — fix it. Debugging does not count as a new single-variable change, and is capped at 3 attempts per candidate before the line is abandoned.
    • improve: the current best works — make one deliberate change to it.
  4. Hypothesize. Write a falsifiable statement: expected direction on the frozen primary metric, and the mechanism that would explain it.
  5. Design. Single-variable, reversible, bounded (subset or short run first). Keep dataset, preprocessing, evaluation command, and seeds frozen; anything unavoidable to change must be declared as a comparability break.
  6. Run. Execute the smallest trustworthy version. Record real evidence (changed files, metrics, logs) — never predicted numbers.
  7. Compare fairly. Same evaluation contract as current_research. A run with no parsed primary metric is buggy — it can never be best, only debugged or abandoned. If conditions differ, the comparison is labeled non-comparable and cannot justify a keep decision.
  8. Decide greedily. Better on the primary metric under fair conditions → the candidate becomes the new best (still candidate-grade, not trusted). Before it may replace current_research as the standing reference, it needs a replication pass: rerun under the frozen contract across multiple seeds (default 3) and keep only if the aggregate still wins. Not better, noisy, or unfair → roll back and record why. Ties favor the simpler, cheaper change.
  9. Record. One ledger entry per iteration: iteration type, anchor, hypothesis, design, evidence, decision, and what the result teaches next.

Discipline

  • One active change per iteration; no silent multi-variable jumps.
  • A failed iteration is information: mine it for the next hypothesis before proposing something unrelated.
  • Greedy applies to selection, not honesty: never keep a candidate on non-comparable or partial evidence.
  • Best-candidate selection is metric-only under the frozen contract — never by an LLM's holistic judgment of which run "looks better".
  • Stop with a typed reason, not silently. Recorded stop reasons: budget-exhausted, no-fair-improvement (two consecutive iterations without a comparable win), debug-attempts-exhausted, researcher-redirect, blocked.

Defaults

Knob Default Note
Initial independent drafts 23 before committing to one line
Debug attempts per candidate 3 then abandon the line
Replication seeds before promotion 3 aggregate must still win
Run boundedness subset / short-run first full runs need explicit budget

Boundary

This loop lives inside the explore lane and inherits every trusted-lane and campaign gate: frozen evaluation, explicit authorization, candidate-only claims, and auditable rollback.