An educational and production-ready workspace demonstrating agentic design patterns using LangGraph and LangChain. The project exhibits three core architectures: basic state-based conversational agents, human-in-the-loop orchestration with interrupts, and multi-agent coordination with specialized roles.
This repository contains independent modules built on top of LangGraph's state machine execution model. Each module addresses a specific complexity pattern in AI agent design.
View System Orchestration & Flow Diagram
graph TD
classDef main fill:#1C3C3C,stroke:#333,stroke-width:1px,color:#fff;
classDef chatbot fill:#3776AB,stroke:#333,stroke-width:1px,color:#fff;
classDef human fill:#F55036,stroke:#333,stroke-width:1px,color:#fff;
classDef multi fill:#008080,stroke:#333,stroke-width:1px,color:#fff;
classDef tool fill:#f4f4f4,stroke:#333,stroke-width:1px,color:#333;
Workspace([User Prompt]) --> Route{Select Workflow}
%% Pattern 1
Route -->|Basic Chat| P1[1-BasicChatBot]:::chatbot
P1 --> ChatbotNode[ChatBot Node]:::chatbot
ChatbotNode -->|Response| Output1([User Response])
%% Pattern 2
Route -->|Human Approval| P2[Human Assistance]:::human
P2 --> HILChat[Chatbot Node]:::human
HILChat -->|Conditional Edge| HILTools[Tool Node]:::tool
HILTools -->|TavilySearch| WebSearch[Web Search]:::tool
HILTools -->|human_assistance| Interrupt[State Interrupt]:::human
Interrupt -->|Input Data| ResumedChat[Resume Execution]:::human
%% Pattern 3
Route -->|Multi-Agent| P3[Multi-Agent System]:::multi
P3 --> ResAgent[Researcher Agent]:::multi
ResAgent -->|Execute Search| SearchTool[search_web]:::tool
SearchTool --> WritAgent[Technical Writer]:::multi
WritAgent -->|Summarize| Summary[write_summary]:::tool
- State-Based Graph Orchestration — Flexible node-and-edge configuration utilizing LangGraph
StateGraphwith explicit state variables and message reducers (add_messages). - Human-in-the-Loop Interruption — Mid-execution pauses utilizing LangGraph
interruptandMemorySavercheckpointer memory to request manual user inputs or reviews before resuming. - Supervised Multi-Agent Architecture — Specialized agent routines (Researcher & Writer) cooperating dynamically via state passing and tool node routing.
- High-Speed Inference — Integrates
groq:llama-3.3-70b-versatilevia LangChain's unifiedinit_chat_modelfor low-latency completions. - Dynamic Web Grounding — Live internet queries using Tavily search APIs to provide real-time contexts.
.
├── 1-BasiChatBot/
│ └── 1-basicchatbot.ipynb # Basic StateGraph conversational agent
├── HumanAssitance/
│ └── HumaninLoop.ipynb # Interrupt checkpointer and human-in-the-loop tool
├── MultiAgents/
│ └── Agents.ipynb # Hierarchical multi-agent research & write graph
├── main.py # Global entrypoint script
├── pyproject.toml # UV tool configuration & dependency specifications
├── requirements.txt # Standard requirements file
├── .env # API secrets (GROQ & TAVILY)
└── README.md # System documentation
- Python 3.13+
- A Groq API Key (get one from console.groq.com)
- A Tavily API Key (get one from tavily.com)
# Clone the repository
git clone https://github.com/your-username/langgraph-agentic-ai.git
cd langgraph-agentic-ai
# Create and activate a virtual environment
python -m venv .venv
source .venv/bin/activate # On Windows: .venv\Scripts\activate
# Install dependencies using uv (recommended)
uv pip install -r requirements.txt
# Or using standard pip:
pip install -r requirements.txtCreate a .env file in the root of the project to configure your credentials:
GROQ_API_KEY=your_groq_api_key_here
TAVILY_API_KEY=your_tavily_api_key_hereLocated in 1-basicchatbot.ipynb, this workflow configures a single-node graph mapping user prompts directly to the Groq inference engine. It demonstrates the fundamental mechanics of message serialization, graph node compilation, and invocation streaming.
Located in HumaninLoop.ipynb, this workflow uses a memory checkpointer (MemorySaver). When the chatbot attempts to trigger the human_assistance tool, the system invokes an interrupt, stopping execution and persisting the state. The user can inspect the state, edit the payload, and resume the graph run dynamically.
Located in Agents.ipynb, this module explores advanced multi-agent orchestrations. It transitions from a basic linear handoff to an intelligent Supervisor-led corporate team structure managed dynamically by the LLM.
A straight-line state transition where the Researcher performs the initial grounding and automatically passes control to the Technical Writer to output a finalized markdown summary.
graph LR
classDef agent fill:#008080,stroke:#333,stroke-width:1px,color:#fff;
classDef tool fill:#f4f4f4,stroke:#333,stroke-width:1px,color:#333;
Researcher[Researcher Agent]:::agent -->|search_web| Tavily[Tavily Search]:::tool
Tavily --> Writer[Technical Writer Agent]:::agent
Writer -->|write_summary| Out([Final Report])
An advanced state machine where a centralized Supervisor Agent controls a group of specialized agents. The Supervisor reads the current conversation state and dynamically determines who works next, routing control iteratively until the task is complete.
graph TD
classDef supervisor fill:#F55036,stroke:#333,stroke-width:1px,color:#fff;
classDef worker fill:#3776AB,stroke:#333,stroke-width:1px,color:#fff;
classDef router fill:#1C3C3C,stroke:#333,stroke-width:1px,color:#fff;
Task([User Request]) --> Supervisor[Supervisor Agent]:::supervisor
Supervisor -->|LLM Routing Decision| Router{State Router}:::router
Router -->|assign researcher| Researcher[Researcher Agent]:::worker
Router -->|assign analyst| Analyst[Analyst Agent]:::worker
Router -->|assign writer| Writer[Writer Agent]:::worker
Router -->|DONE| End([Final Compiled Report])
Researcher -->|return research_data| Supervisor
Analyst -->|return analysis| Supervisor
Writer -->|return final_report| Supervisor
Note
SupervisorState Definition The state of the supervisor model is tracked using custom schema definitions:
class SupervisorState(MessagesState):
next_agent: str # Tracks routing targets (researcher/analyst/writer/end)
research_data: str # Gathers facts and search summaries
analysis: str # Houses analytic insights and strategic risks
final_report: str # Gathers the final report markdown compiled by the writer
task_complete: bool # Signal flag to trigger END
current_task: str # Stores original user request metadataView Agent System Prompts & Configurations
- Supervisor Agent
- Role: Dynamic Project Manager.
- Instruction: Evaluates variables
{has_research},{has_analysis}, and{has_report}. Invokesgroq:llama-3.3-70b-versatileto decide the next step. Outputs onlyresearcher,analyst,writer, orDONE.
- Researcher Agent
- Role: Gathers source information, details, background facts, and current trends.
- Analyst Agent
- Role: Reviews raw research data to provide actionable key insights, strategic risks, opportunities, and structured recommendations.
- Writer Agent
- Role: Synthesizes the analysis and research findings into a publication-grade Executive Report.
Tip
Dynamic Routing Logic The supervisor routes messages using a declarative LangGraph conditional edge mapping function:
def router(state: SupervisorState) -> Literal["supervisor", "researcher", "analyst", "writer", "__end__"]:
next_agent = state.get("next_agent", "supervisor")
if next_agent == "end" or state.get("task_complete", False):
return END
return next_agentThe workspace is designed to be highly modular and extensible. You can adapt it to any set of services:
| Component | Target File | Modification Details |
|---|---|---|
| Change LLM Model | pyproject.toml / Jupyter Notebooks | Modify init_chat_model("groq:llama-3.3-70b-versatile") parameters in notebooks. |
| Alter Agent Roles | Agents.ipynb | Edit system_msg strings in the researcher_agent or writer_agent blocks. |
| Add Custom Tools | Jupyter Notebooks | Decorate new Python functions with @tool and bind them to the model (e.g., llm.bind_tools(...)). |
| Add Checkpointers | HumaninLoop.ipynb | Replace MemorySaver with persistent databases (e.g., SqliteSaver or PostgresSaver) for production. |
- LangGraph Documentation for state graph architecture and patterns.
- LangChain Community for standard integrations.
- Groq for high-performance Llama 3.3 model inference.