Skip to content

064-loop: autonomous goal-directed research #87

Description

@ahoward

Summary

brane loop — autonomous research cycle. Give brane a goal, it reflects on gaps, searches the web, digests findings, and repeats until convergent.

Why

This is the capstone. An agent with digest, ask, and storm can consume, query, and explore — but a human has to drive it. Loop makes brane self-directed: "learn everything about X" becomes a single command. Bunny's loop does this with web search + digest in a cycle. We do the same but write into the structured graph.

What

CLI

brane loop "understand JWT refresh token rotation patterns"
brane loop "map the competitive landscape for vector databases" --rounds 5
brane loop --resume <id>              # resume a paused loop
brane loop list                        # show all loops with status

Flags

  • --rounds <n> — max rounds (default: 5)
  • --resume <id> — resume a previous loop
  • --dry-run / -n — show what would happen without writing
  • --json / -j — JSON output

Loop Cycle (per round)

  1. Reflect — LLM examines current knowledge vs goal, identifies gaps
    { gaps: string[], queries: string[], assessment: string, converging: boolean }
  2. Search — execute web searches for identified queries
  3. Fetch — load top URLs from search results
  4. Digest — feed fetched content through digest pipeline
  5. Journal — record what was searched, fetched, digested this round

State Persistence

Loop state is stored so loops can be resumed:

{
  id: string,
  goal: string,
  status: "running" | "converged" | "paused" | "max_rounds",
  rounds_completed: number,
  search_history: string[],  // avoid re-searching
  created_at: string,
  updated_at: string
}

Convergence

Loop stops when:

  • LLM signals converging: true for 2 consecutive rounds
  • Max rounds reached
  • No new search results found

Web Search

Uses existing LLM tool-use infrastructure (Claude with WebSearch tool). Search history prevents duplicate fetches across rounds.

MCP Tool

loop: { goal: string, rounds?: number, dry_run?: boolean }
loop_resume: { id: string }
loop_list: {}

Depends On

Acceptance

  • Single goal → multi-round autonomous research
  • Web search finds relevant sources
  • Each round digests new findings into graph
  • Convergence detection stops the loop
  • State persists for resume
  • Search history prevents duplicate work
  • Round journals record what happened
  • MCP tools exposed
  • Spike test passes

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions