sndev
Project CategoriesDeveloper LearnDeveloper Insights
LoginGet Started
sndevv1.0.0
AboutProject FeedInsightsYouTubePrivacy PolicyTerms of Service

Β© 2026 sndev β€’ v1.0.0

Home
Categories
Dev Learn
Insights
Sign In
Agentic AI
Nov 26, 2026
s
sndev

Building a Multi-Agent Workflow with LangGraph | Deep Research Agent – Part 11

GitHub RepositoryWatch on YouTube

β€œConnect Planner, Researcher, Critic, and Writer agents using LangGraph StateGraph, implement graph execution with astream(), and prepare real-time agent status updates for the frontend.”

Project SeriesPart 11 of 13

Deep Research Agent

Series Progress85%
Series Episodes (13)
Build an Autonomous Deep Research Agent | End-to-End Agentic AI Project | Part 1
Available
Setup & Installation for Autonomous Deep Research Agent | End-to-End Agentic AI Project | Part 2
Available
Building the Agentic AI Brain with LangGraph | Autonomous Deep Research Agent | Part 3
Available
Building AI Agent with LangGraph | Planner Agent Implementation | Deep Research Agent | Part 4
Available
Building AI Agent Tools | Rate Limiting & Source Credibility | Deep Research Agent | Part 5
Available
Building a Web Search Tool for AI Agents with Tavily API | Deep Research Agent Part 6
Available
Building arXiv Search, Cross-Referencing, and Citation Tools | Deep Research Agent Part 7
Available
Building the Researcher Agent with Web Search, arXiv & Source Ranking | Deep Research Agent Part 8
Available
Building the Critic Agent: Detecting Conflicting Research | Deep Research System Part 9
Available
Building the Writer Agent – Generating Structured AI Research Reports | Part 10
Available
P11
Building a Multi-Agent Workflow with LangGraph | Deep Research Agent – Part 11
Current Part
Building a Real-Time WebSocket Streaming Engine with FastAPI | Deep Research Agent – Part 12
Available
Building and Deploying a Full-Stack AI Deep Research Agent | Part 13 – Final Chapter
Available
Part 10Part 12

In this chapter of our Autonomous Deep Research Agent project, we move from building individual AI agents to connecting them into a complete multi-agent workflow using LangGraph.

Until now, we have developed four specialized agents: Planner, Researcher, Critic, and Writer. However, these agents are still independent components. We need an orchestration layer that defines their execution order, manages shared state, and coordinates the entire research process.

This is where LangGraph comes in.

1. Building the Agent Execution Graph

We create a graph.py file to define the workflow using LangGraph's StateGraph.

Our graph contains four nodes:

  • Planner: Breaks the research query into actionable subqueries.

  • Researcher: Searches for relevant information and gathers sources.

  • Critic: Evaluates research findings, identifies contradictions, and cross-references claims.

  • Writer: Generates the final structured research report.

Each node operates on a shared AgentState, allowing information to flow between agents throughout execution.

Workflow Architecture

The execution follows a sequential pipeline:

  1. User submits a research query.

  2. Planner generates the research plan.

  3. Researcher gathers relevant information.

  4. Critic evaluates the collected evidence.

  5. Writer generates the final research report.

2. Connecting Nodes with StateGraph

We initialize StateGraph with our AgentState schema and register all four agent nodes.

Next, we define the entry point and execution edges:

  • Planner β†’ Researcher

  • Researcher β†’ Critic

  • Critic β†’ Writer

  • Writer β†’ END

Finally, we compile the graph and store the compiled instance as research_graph, which can be reused whenever a research request arrives.

3. Initializing the Agent State

Before executing the graph, we prepare an initial state dictionary.

It contains the user's query, maximum source limit, report ID, callback function, and empty fields for intermediate research data.

These fields include:

  • Subqueries

  • Sources

  • Citations

  • Conflict flags

  • Research sections

  • Summary

  • Execution status

  • Error information

This shared state acts as a common data container that travels through every agent node.

Generating Architecture Diagram…

4. Executing the Graph with astream()

Instead of waiting for the entire workflow to finish before updating the frontend, we use LangGraph's asynchronous astream() method.

This allows us to capture intermediate execution updates as individual nodes complete their work.

Our implementation uses an asynchronous iteration over the graph output to:

  • Identify which node has completed execution.

  • Extract the updated agent state.

  • Capture the current execution status.

  • Pass status updates through a callback function.

  • Prepare the updates for frontend delivery through WebSockets.

This approach makes the research workflow more transparent because the user can eventually see which agent is currently working.

5. Error Handling and Execution Status

We also implement a try-except block around graph execution.

If an API call or agent execution fails, we:

  • Update the report status to FAILED.

  • Capture and log the exception details.

  • Notify the frontend through the update callback.

  • Return the updated initial state.

This ensures that failures are communicated instead of leaving the frontend waiting indefinitely.

Final Outcome

By the end of Part 11, all four individual agents are connected through a compiled LangGraph StateGraph.

We have also implemented the graph execution function, initialized shared state, captured intermediate node updates using astream(), and added basic error handling.

What's Next?

In the next stage, we will connect this graph execution pipeline to our main FastAPI application and expose it through API endpoints, bringing the backend orchestration closer to the frontend application.

The goal is to turn our individual AI agents into a fully coordinated Autonomous Deep Research Agent.

Series Navigation

Up Next: Part 12

Continue following "Deep Research Agent" with Building a Real-Time WebSocket Streaming Engine with FastAPI | Deep Research Agent – Part 12.

Part 10Read Part 12

Community Discussion
0

Ask questions, discuss architecture, and share insights with other developers.

Sort:

Sign in to join the discussion and share your thoughts with other developers.

Sign In to Comment
Loading discussions…