Skip to content

Build a Research Pipeline

In this guide, we'll build a complete three-agent research system that takes a raw topic, searches the web, fact-checks the findings, and synthesises them into a formatted markdown report.

The Architecture

We'll use a Sequential Flow defining three agents:

  1. researcher: Gathers raw facts.
  2. fact-checker: Verifies claims.
  3. writer: Formats the final report.

Step 1: Create the Agents

agents/researcher.json

json
{
  "name": "researcher",
  "llm": { "provider": "google", "model": "gemini-2.0-flash", "key_ref": "GOOGLE_API_KEY" },
  "tools": ["web_search"],
  "config": {
    "system_prompt": "You are an expert researcher. Given a topic, formulate 3 distinct queries, search the web, and output raw bullet points of facts mapping to sources."
  }
}

agents/fact-checker.json

json
{
  "name": "fact-checker",
  "llm": { "provider": "anthropic", "model": "claude-3-5-haiku-20241022", "key_ref": "ANTHROPIC_API_KEY" },
  "tools": ["web_search"],
  "config": {
    "system_prompt": "You are a ruthless fact checker. Given raw notes, verify the claims. Output ONLY claims that are independently verified. Flag contradictions."
  }
}

agents/writer.json

json
{
  "name": "writer",
  "llm": { "provider": "openai", "model": "gpt-4o", "key_ref": "OPENAI_API_KEY" },
  "config": {
    "system_prompt": "You are an executive summary writer. Take verified notes and produce a clean, Markdown-formatted executive brief. No fluff."
  }
}

Step 2: Create the System Topology

system.json

json
{
  "name": "deep-research-pipeline",
  "version": "1.0",
  "agents": {
    "r": { "agent": "path:./agents/researcher.json" },
    "f": { "agent": "path:./agents/fact-checker.json" },
    "w": { "agent": "path:./agents/writer.json" }
  },
  "flow": {
    "type": "sequence",
    "steps": [
      {
        "id": "step1",
        "agent": "r",
        "input_template": "Topic: \{\{ system.input }}"
      },
      {
        "id": "step2",
        "agent": "f",
        "input_template": "Verify these claims: \{\{ step1.output }}"
      },
      {
        "id": "step3",
        "agent": "w",
        "input_template": "Format this into a final report: \{\{ step2.output }}"
      }
    ]
  }
}

Step 3: Deploy and Execute

Set your keys:

bash
savine config set GOOGLE_API_KEY="AIza..."
savine config set ANTHROPIC_API_KEY="sk-ant..."
savine config set OPENAI_API_KEY="sk-proj..."

Deploy the system:

bash
savine systems deploy system.json

Run the pipeline:

bash
savine systems run deep-research-pipeline --input "Recent advances in solid state batteries for EVs"

The system will automatically instantiate the three sandboxes, pass the data sequentially according to your input_template mappings, and return the final writer's markdown output.