LangGraph and Oxylabs: build a Python research agent
Build a four-stage Python research agent with LangGraph and Oxylabs, cap planning at four queries, grade sources, and save a cited Markdown report.
Player not loading? Watch on YouTube
This tutorial builds a research AI agent in a single Python file, using LangGraph to connect planning, retrieval, evaluation and synthesis. The presenter describes the implementation as about 300 lines. Setup uses a virtual environment and a .env file containing Oxylabs Web Scraper API credentials and an LLM key. The example calls OpenAI; the speaker says any OpenAI-compatible endpoint will work.
Retrieval connects to the hosted Oxylabs MCP server. Its search tool finds pages, and Universal Scraper requests their content as Markdown. The tutorial explains how blocked requests and empty JavaScript shells can leave a research workflow with incomplete evidence. It also filters search responses for organic results so ads do not displace sources.
The planner caps its output at four subqueries. A model then grades each retrieved page against its subquery on a zero-to-10 scale, supplies a reason, and drops scores below six. This checks relevance, rather than independently proving each claim true. The writer receives numbered sources and instructions to cite them, then saves report.md with a reference list.
The graph runs the four stages in sequence; searching again would require a conditional edge. Although the Python script runs on the user's machine, the demonstrated setup relies on hosted retrieval and model services. It is not an offline workflow.