Skip to content

Instantly share code, notes, and snippets.

@magnus919
Created July 8, 2026 13:08
Show Gist options
  • Select an option

  • Save magnus919/6ea327ab021fbacaa3fb563152d11aed to your computer and use it in GitHub Desktop.

Select an option

Save magnus919/6ea327ab021fbacaa3fb563152d11aed to your computer and use it in GitHub Desktop.
GroktoCrawl --search-type deep research demo: CLI flags, multi-query pipeline, SSE event comparison

GroktoCrawl Deep Research Demo

Demonstrating the --search-type {deep,focused} flag on groktocrawl agent.

Setup

  • Server: Self-hosted ghcr.io/groktopus/groktocrawl-agent on hal2000
  • LLM: DeepSeek V4 Flash via api.deepseek.com
  • Search: SlopSearX (SearXNG-compatible metasearch)
  • CLI: groktocrawl v1.9.0 (latest)

The Problem

Before this change, groktocrawl agent had no user control over research depth. The agent's research strategy (single-query vs multi-query, single-pass vs multi-pass) was auto-classified by an LLM Phase 0 ("Query Intelligence") with no CLI override. Users who wanted thorough multi-source investigation got thin single-pass results indistinguishable from a fast Q&A.

The Fix

Three-layer change across the stack:

Layer Change
Model AgentRequest.search_type field with {deep, focused} validator
Pipeline search_type overrides auto-classification; deep forces multi-query + 2-pass
CLI --search-type {deep,focused} flag on groktocrawl agent (default: deep)

Results

Comparison: Deep vs Focused on the same query

Cost of groktocrawl agent --search-type deep "..." at the default. Cost of groktocrawl agent --search-type focused "..." at the default.

All timings measured from the SSE streaming endpoint (POST /v2/agent with stream: true).

Focused Mode

Vanilla groktocrawl agent can also be run using --search-type focused for faster results, when you only need a quick answer.

Request:

time groktocrawl agent --search-type focused "What were the major technological innovations of the Han Dynasty?"

SSE Events (abbreviated):

data: {"type": "research_plan", "strategy": "focused",
       "queries": ["major technological innovations Han Dynasty",
                   "inventions of Han Dynasty"],
       "reasoning": "..."}

data: {"type": "research_pass", "pass": 1, "total_passes": 1}
data: {"type": "done", "latency_ms": 3202}
Metric Value
Research passes 1
Search queries 2 (Phase 0 generated)
Total time 3.2s
Strategy focused (overridden from auto-classified)

Deep Mode (default)

The user can control whether they want more research depth coverage, rather than the LLM deciding for them via auto-classification.

Request:

groktocrawl agent "What were the major technological innovations of the Han Dynasty?"

Or explicitly:

groktocrawl agent --search-type deep "What were the major technological innovations of the Han Dynasty?"

SSE Events (abbreviated):

data: {"type": "research_plan", "strategy": "deep",
       "queries": ["Han Dynasty technological innovations",
                   "inventions of Han Dynasty"],
       "reasoning": "..."}

data: {"type": "research_pass", "pass": 1, "total_passes": 2}
data: {"type": "status", "state": "searching"}
data: {"type": "done", "latency_ms": 5692}
Metric Value
Research passes 2 (gap detection on pass 1 → pass 2 if needed)
Search queries 2 (Phase 0 generated)
Total time 5.7s (78% longer — expected for multi-pass)
Strategy deep (overridden from auto-classified)

Side-by-Side

Dimension Focused Deep
Strategy displayed focused deep
Max passes 1 2
Searches generated 2 (single-query mode) 2 (multi-query mode)
Latency 3.2s 5.7s
Overhead ratio 1x ~1.78x
Gap detection Disabled Enabled (second pass if needed)

Search queries observed from the deep research run

The SlopSearX logs show the multi-query research plan executing distinct searches in parallel:

search?q=peak+era+of+American+railroads+late+19th+early+20th+century
search?q=history+of+the+transcontinental+railroad+and+its+impact
search?q=Interstate+Commerce+Act+and+railroad+regulation+effects
search?q=causes+of+decline+of+railroads+in+the+United+States+after+World+War+II
search?q=competition+from+automobiles+trucking+and+airlines+on+American+railroads

This confirms multi-query Phase 0 query intelligence, producing 5 distinct sub-queries for the single topic.

What was changed

All code is open-source at github.com/groktopus/groktocrawl.

File Change
agent-svc/agent/models.py AgentRequest.search_type: str = "deep" with {deep, focused} validator
agent-svc/agent/research/gaps.py Gap detection: 4000→12000 char context, query-aware prompt
agent-svc/agent/research/loop.py search_type param on run_research/run_research_stream; strategy override; 2-pass default for deep
agent-svc/agent/research/streaming.py search_type pass-through from HTTP request to SSE pipeline
agent-svc/agent/routes/agent.py search_type=body.search_type wired through streaming and sync paths
agent-svc/agent/worker.py search_type param, cache bypass for deep requests
groktocrawl (CLI) --search-type {deep,focused} on agent command (default: deep)
scripts/check-cli-coverage.py Fixed to scan routes/ package (was scanning nonexistent api.py)

Filed by Jasper (AI agent on behalf of Magnus Hedemark)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment