Skip to content

Tutorial: Build a Research Pipeline

This tutorial builds a research pipeline that decomposes a goal, retrieves context, synthesizes findings, and verifies results — driven through G6's surfaces (Claude Code via MCP, the GUI, or REST). You don't write Python; you compose existing components.

What you will build

A five-stage pipeline that:

  1. Decomposes a research goal into subtasks
  2. Searches for relevant context
  3. Retrieves and grounds information with RAG
  4. Synthesizes findings using an LLM agent
  5. Verifies conclusions with formal methods
flowchart LR
    A[Goal] --> B[goal_engine<br/>Decompose]
    B --> C[ctx_search<br/>Web Search]
    C --> D[ctx_rag<br/>Retrieve + Ground]
    D --> E[agent_claude<br/>Synthesize]
    E --> F[formal_methods<br/>Verify]
    F --> G[Verified Result]

Run it in one step

The fastest path is the built-in research pipeline. In Claude Code, ask:

Use the G6 run_research_pipeline tool to research:
"common memory safety patterns in systems programming" — decompose it, search,
retrieve and ground sources, synthesize an analysis, and verify the conclusions.

Claude calls the run_research_pipeline tool and orchestrates the stages for you, returning the summary, the sources it used, and confidence scores. In the GUI, the same flow is available from the Dashboard by creating a run with this goal.

The five stages

Under the hood the pipeline chains these components. You can also run any stage on its own.

# Stage Component Operation Notes
1 Decompose goal_engine decompose Breaks the goal into a subtask tree
2 Search ctx_search search engine: mock / duckduckgo / serpapi
3 Retrieve ctx_rag add, then retrieve TF-IDF (optional BM25); top_k chunks
4 Synthesize agent_claude infer Requires an Anthropic API key
5 Verify formal_methods verify strategy: propositional (built-in DPLL)

Search engine options

  • mock — always works, returns synthetic results (useful for testing)
  • duckduckgo — real web search, no API key needed
  • serpapi — premium search (requires a SERPAPI_KEY)

Synthesis needs an API key

agent_claude needs your Anthropic API key configured in Settings (or ~/.g6/.env). See Configuration. Without it, the synthesis stage returns a clear diagnostic instead of failing silently.

Run it stage by stage

Ask for each stage in natural language — your assistant maps it to the right tool (decompose_goal, invoke_component, …):

1. Use G6 to decompose: "Analyze common memory safety patterns in systems programming"
2. Use G6 ctx_search to search "memory safety patterns systems programming" with duckduckgo
3. Use G6 ctx_rag to add those snippets and retrieve the top 5 for "memory safety formal verification"
4. Use G6 agent_claude to synthesize an analysis from the retrieved context
5. Use G6 formal_methods to verify: "(memory_safe AND verified) -> safe_to_deploy"

Run G6 as a self-hosted REST server and invoke each component over HTTP (POST /invoke/{component}). Two example stages:

# Stage 2 — search
curl -X POST http://localhost:8000/invoke/ctx_search \
  -H "Content-Type: application/json" \
  -d '{"operation": "search", "params": {"query": "memory safety patterns systems programming", "engine": "duckduckgo", "max_results": 10}}'

# Stage 3 — retrieve (after adding documents)
curl -X POST http://localhost:8000/invoke/ctx_rag \
  -H "Content-Type: application/json" \
  -d '{"operation": "retrieve", "params": {"query": "memory safety formal verification", "top_k": 5}}'

See REST Endpoints for every component's request/response schema.

From the Dashboard, create a run for the research goal. The Reasoning Flow view shows each stage (Assessment → Execution → Evaluation) with evidence links, and Artifacts shows the raw output of each stage.

Verify the conclusions

The final stage proves a logical property of the result with the built-in DPLL solver — no external dependencies. Ask G6 (or call formal_methods) to verify, e.g.:

Use G6 formal_methods to check that "(memory_safe AND verified) -> safe_to_deploy"
is satisfiable when memory_safe and verified are both true.

A satisfiable result means the conclusion is logically consistent; an unsatisfiable result returns a counterexample.

Next steps