Stateful Multi-Step Web Research Agents
Build research agents with explicit state tracking to prevent hallucination across multi-step tasks.

A web research agent needs an API that turns live URLs into structured, timestamped data it can verify later. The agents that finish complex, multi-step tasks are the ones built with explicit state: a plan, an evidence log with full provenance, and a verification step that checks extracted claims before they reach a final answer. This piece breaks down why that architecture matters and which tools actually handle the extraction layer cleanly.
Why multi-step web research fails without explicit state
A demo that answers one question looks impressive because it only has to survive one step. It's memory: an agent that has to plan, search, browse, verify, and synthesize across many steps will loop on the same query, forget what it already found, or cite a source it never actually visited, unless something is tracking all of that for it.
Old-school web scraping never had this problem, because it never tried to do this much. A scraper built on fixed selectors and plain HTTP requests pulls data from a known location using rules set in advance, with no decision-making involved. That works until the page changes or the task requires reacting to what the last step turned up, at which point a fixed selector just breaks.
An AI browser agent works differently, and that difference is the whole reason state becomes necessary. It runs a loop: read a rendered snapshot of the page, decide on the next action toward a goal written in plain language, carry out that action, then read the page again. Forgetting is not.
None of these are separate, isolated bugs, and they compound as the task gets longer: a five-minute demo can look flawless while a twenty-step research task falls apart halfway through.
What "state" means inside a research agent
State isn't one memory bank an agent writes to and reads from.
The fastest layer is short-term memory: the current conversation, the active queue of tasks, whatever a tool just returned. This needs to be available almost instantly, so it typically lives in an in-memory store like Redis rather than anywhere slower. Long-term memory sits a layer down: summaries of past interactions, learned preferences, patterns the agent has picked up, stored in a vector database and pulled back in by semantic similarity when a new step needs older context.
Neither of those two layers, on their own, covers what a research agent specifically needs. Four things have to exist somewhere in state or the loop falls apart: the running plan (what the agent set out to do), the evidence log (what it found and where it came from), the verification status (which claims are backed by a source and which are still unconfirmed), and the reasoning trace (why the last action got chosen). None of these get built in automatically just because an agent has short-term and long-term memory. They have to be built in on purpose.
The evidence log is the clearest example of what happens when this gets skipped. Without one, a multi-step agent will take its own earlier output, feed it back into a later step, and treat that output as if it were a fresh source it just discovered. This is a direct result of not keeping a record of what was actually retrieved versus what the agent generated on its own.
The research loop
Take a concrete multi-turn task, one long enough that the agent must carry a plan across turns, track which sources it has verified, and distinguish what it retrieved from what it inferred.
Phase one is planning. The agent breaks "compare three competitors" into sub-tasks, something like identifying the three products, finding each one's pricing page, and pulling out comparable features. That plan gets written to state up front, and every phase after this one checks back against it to decide what to do next and to catch the moment the agent starts drifting off task.
Phase two is search. What matters here is a structured record of which queries were tried, which sources came back, and which ones the agent chose to visit. If that record is skipped, the agent ends up running the same search again two steps later, burning time and tokens on work it already did.
Phase three is browsing. Whatever it pulls out, say, a price point or a list of plan features, needs to be stored along with where it came from: the URL, the time it was retrieved, and which field in the agent's schema it maps to. A web scraping API like Context can turn a URL like a competitor's pricing page into clean Markdown and extract structured fields against a defined schema, which gives the browse phase a clean way to capture that evidence with the source and field mapping already attached, so the verification step doesn't have to parse raw HTML by hand.
Phase four is verification. The agent takes each price and feature claim it logged and checks it against the plan and against anything else it retrieved, marking each one unverified, corroborated, or contradicted. This phase only works because phase three left behind a structured log with provenance attached. Without that, there's nothing concrete to check a claim against.
Phase five is synthesis. The agent writes the final comparison using only what's in the verified evidence log, not whatever it might recall from its own training data about these products. A sloppy one produces a confident, polished answer built on claims nobody checked.
LangGraph as the reference architecture for stateful research loops
LangGraph earns its place in this conversation because of one property: it supports cycles. An agent built on LangGraph can go back to the search phase after a verification check fails, route to a separate validation step when it isn't confident about an extracted field, and only exit the loop once its own confidence threshold is actually met. Once it runs through its steps, it's done, whether the output was good or not.
LangChain's own comparison of the two frameworks makes the upgrade path clear. Teams usually start with LangChain because it's fast to prototype with, and they move to LangGraph once their architecture needs explicit state tracked across multiple steps or multiple agents. That move is about needing loops and persistence that a simple chain was never built to hold.
A concrete example of what this looks like in practice: when an extraction agent isn't confident about a field it pulled from a page, LangGraph can route that output to a validation node instead of just passing it along as if it were solid.
LangGraph isn't the only way to structure this kind of agent. For research tasks specifically, where verification failures need to route back into earlier steps, the graph-based model earns its reference-architecture status.
Why live web data is a hard requirement
For a research agent, stale information is worse than the cost of fetching live data every time.
Specific categories of information move faster than any index can keep up with: news, prices, library versions, security CVEs, competitive feature sets. An agent grounded only in a static index answers questions as of whenever that index was last built. It will answer questions about a competitor's current pricing with confidence, using numbers that may no longer be true.
The fix is SERP grounding: fetching the live web at the moment a query comes in, instead of pulling from whatever was indexed earlier.
Most teams running these agents in production don't pick one side of that trade-off and stick with it everywhere. They build a hybrid: vector search for owned content that updates on a known schedule, live web fetch for anything that needs to be current or sits outside what's already indexed. Routing between the two doesn't need to be complicated. Freshness keywords, confidence thresholds, and basic topic classification are usually enough to decide which path a given query should take.
Getting live web content into a research agent cleanly: the extraction layer
Fetching a URL takes one line of code. Turning that page into clean, structured content an LLM can actually reason over is where most research agent projects lose weeks before shipping a single feature. JavaScript rendering, inconsistent layouts, and anti-bot defenses all stand between a URL and usable text.
Anti-bot defenses deserve specific attention here, because they're not an occasional annoyance, they're a real blocker in production. The clearest signal a site uses to flag a bot is a direct jump to a deep content URL with no referrer and no browsing history behind it. A scraper, left unaddressed, often arrives at the final URL with an empty session, a pattern a site can easily detect and block.
A few named tools handle this cleanly, each solving a different piece of it. Crawl4AI uses Playwright to render pages the way a browser would, and packages the result into clean Markdown or structured JSON. For pages where a fixed selector won't hold up, it supports LLM-based extraction built around a defined JSON schema and a plain-language instruction, so even a chaotic page still comes out as structured JSON on the other end.
That schema matters more than it might seem at first. The schema functions as the contract between the browse phase and the verify phase: without it, there's nothing concrete for verification to check.
Context.dev covers this ground with a single API: clean Markdown, rendered HTML, sitemaps, screenshots, structured extraction against a schema, and company or brand data, all through one key. For a team trying to ship an agent rather than spend months building scraping infrastructure, that consolidation is the practical appeal.
On the document side, separate from live web pages entirely, LlamaParse handles ingestion of uploaded files, interpreting structure, context, and multimodal content across complex documents.
MCP as the connective tissue between agents and extraction tools
The Model Context Protocol, or MCP, is what lets an agent call tools like scraping APIs, extraction services, and brand data providers directly at runtime, using plain language instead of custom integration code written for each tool ahead of time.
The agent becomes more flexible as a result. Picture an agent mid-research task that decides it needs to check a competitor's current pricing page. With MCP in place, it can reach for a scraping tool and extract that structured data on the spot, without a developer having wired up that exact call in advance. MCP is what makes the extraction layer and the orchestration layer, LangGraph or otherwise, actually work together instead of needing custom glue code for every new tool added to the stack.
Where research agents still fail
The single most important fact for anyone deciding how much to trust a research agent is the benchmark record. On the Mind2Web 2 agentic-search benchmark, the strongest system, OpenAI Deep Research, reached a meaningful but still partial share of human performance on long-horizon tasks, and still fell short of humans overall.
The TestMuAI 2026 scorecard adds a useful warning to that picture: numbers on sandboxed benchmarks look considerably better than numbers on realistic live-web tasks, and a lot of misplaced confidence in these systems comes from people reading the easier benchmark.
What actually breaks on long-horizon tasks is compounding errors across steps: a bad extraction back in step three quietly corrupts the evidence log that step seven depends on for its synthesis, and without an explicit verification phase, nothing in the system catches that or fixes it.
There's a security dimension to this too, and it doesn't get resolved by better state management alone. Indirect prompt injection, where content planted on a web page redirects an agent's actions, falls under Prompt Injection, the category ranked first on the OWASP LLM Top 10. Any research agent that browses live pages is exposed to adversarial content on every page it reads, and that risk doesn't disappear with a cleaner architecture.
Research from August 2025 on large-scale asynchronous reinforcement learning for long-horizon agentic search suggests this ceiling is a limitation of where the field is right now, not something baked in permanently. It's moving. It's still a ceiling today, though, and that distinction should shape how these agents get deployed. The right use today is a constrained domain: a bounded task horizon, known evidence sources, and a verification step built to catch compounding errors before they reach synthesis. Open-ended, long-horizon research without those guardrails remains the failure mode, not a use case worth shipping yet.
Building a research agent that finishes: the architectural decisions that matter
No single model upgrade turns an unreliable research agent into a reliable one. What changes the outcome is a set of explicit decisions made about state structure, extraction contracts, verification routing, and how the system recovers when something goes wrong.
The first decision comes before any code gets written: define the plan object, the evidence log schema, and the verification status enum up front. Changing it in the middle of building the agent breaks every phase already built against the old version.
From there, the rest of the decisions follow the same logic traced through every section above. And keep the task bounded: known sources, a clear horizon, and a system built to catch a bad extraction before it quietly corrupts everything synthesized after it.
A research agent that finishes is the product of a plan that persists, an evidence log with real provenance, and a verification step that actually gets to run before the final answer gets written.


