-
Notifications
You must be signed in to change notification settings - Fork 11
features agent research
Magnus Hedemark edited this page Jun 10, 2026
·
1 revision
Active contributors: groktopus
The agent endpoint (POST /v2/agent) is GroktoCrawl's autonomous web research capability. It searches the web, scrapes relevant pages, and synthesizes findings using an LLM -- all in a single API call. It is the project's flagship feature.
-
POST /v2/agentcreates a job in Valkey and returns a job ID -
_process_agent_async()inworker.pyruns the research loop in the background:- Searches SearXNG if no seed URLs are provided
- Scrapes each URL through the scraper-svc pipeline (with concurrency limits)
- Feeds scraped content into the LLM with a system prompt
- Stores the synthesized result in Valkey
-
GET /v2/agent/{job_id}returns the status and result - Optional webhook fires on completion or failure
When stream: true is set, the endpoint bypasses job creation and runs inline:
POST /v2/agent {"prompt": "...", "stream": true}
→ SSE event stream:
→ data: {"type": "sources_pending", "sources": [...]} -- search results found
→ data: {"type": "source_scraped", "url": "...", ...} -- each page scraped
→ data: {"type": "token", "content": "..."} -- LLM token output
→ data: {"type": "done", "result": "...", "sources": [...], "latency_ms": N}
→ data: [DONE]
The agent uses a fixed SYSTEM_PROMPT in research.py that instructs the LLM to:
- Evaluate source quality (official docs > established outlets > blogs > aggregators)
- Synthesize across multiple pages, detecting contradictions
- Cite sources by URL for every factual claim
- Flag uncertainty when sources are thin or incomplete
- Never use pre-training knowledge to fill gaps -- answer only from provided context
A lighter-weight synchronous endpoint that bridges search and agent: search, scrape top results, LLM synthesis with citations. Designed for 1-3s latency. Supports SSE streaming.
Scrapes provided URLs and extracts structured data matching a user-provided JSON Schema. Uses the EXTRACT_SYSTEM_PROMPT for LLM guidance.
| File | Purpose |
|---|---|
agent-svc/agent/research.py |
Research loop: run_research(), run_research_stream(), run_answer(), run_extract()
|
agent-svc/agent/worker.py |
Async job processors for agent, crawl, extract, batch scrape |
agent-svc/agent/llm.py |
OpenAI-compatible LLM client with streaming |
agent-svc/agent/api.py |
Route handlers for agent, answer, extract endpoints |
agent-svc/agent/searxng_client.py |
Search client for source discovery |
agent-svc/agent/scraper_client.py |
Scrape client for content extraction |