From simple LLM chains to production-grade stateful AI agents.
A hands-on implementation of cyclic, persistent, and human-supervised agentic workflows using LangGraph and LangChain.
Most LLM applications are linear: input → model → output. Real-world agents don't work that way.
This repository implements cyclic, stateful agentic workflows where agents can plan, act, reflect, use external tools, pause for human review, and resume from any point in history — all within a structured graph architecture.
Built on top of LangGraph and LangChain, covering everything from a bare-metal ReAct agent to a full Essay Writer with multi-step reflection loops.
User Input
│
▼
┌─────────────────────────────────────┐
│ LangGraph Agent │
│ │
│ ┌────────┐ ┌────────┐ │
│ │ Node │───▶│ Node │ │
│ └────────┘ └───┬────┘ │
│ ▲ │ (cyclic) │
│ └────────────┘ │
│ │
│ State: SqliteSaver (persistent) │
│ Tools: Tavily Search │
│ Gates: Human-in-the-Loop │
└─────────────────────────────────────┘
│
▼
Structured Output / Final Response
langgraph-agentic-workflows/
│
├── 01_Basics/ # ReAct agent from scratch
│ ├── react_agent.py
│ └── langgraph_intro.py
│
├── 02_State_Management/ # Persistence & streaming
│ ├── sqlite_persistence.py
│ ├── conversation_threads.py
│ └── token_streaming.py
│
├── 03_Tool_Integration/ # Agentic search with Tavily
│ ├── tavily_search_agent.py
│ └── tool_calling_workflow.py
│
├── 04_Human_in_the_loop/ # Approval gates & time travel
│ ├── interrupt_before.py
│ ├── state_editing.py
│ └── time_travel_debug.py
│
├── 05_Use_Cases/ # Full-scale Essay Writer Agent
│ └── essay_writer_agent.py
│
├── requirements.txt
├── .env.example
└── README.md
Unlike linear chains, LangGraph workflows are iterative. Agents plan, act, observe results, reflect, and loop — enabling complex multi-step reasoning that simple pipelines can't achieve.
Using Annotated types with SqliteSaver to give agents true long-term memory. Conversations persist across sessions and can be resumed on any thread — essential for production deployments.
Strategic interrupt_before checkpoints allow humans to review, approve, or modify agent decisions before execution continues — critical for high-stakes tasks like financial operations or data writes.
Agents can rewind to any previous state, fork the execution history, and re-run logic from that point. Invaluable for debugging agent behavior and steering workflows mid-execution.
Unlike standard web search, Tavily is optimized for LLM consumption — returning clean, structured, citation-ready results that agents can reason over directly.
- Python 3.10+
- OpenAI API key
- Tavily API key (free tier available at tavily.com)
# 1. Clone the repository
git clone https://github.com/ozereray/langgraph-agentic-workflows.git
cd langgraph-agentic-workflows
# 2. Install dependencies
pip install -r requirements.txt
# 3. Set up environment variables
cp .env.example .envAdd your API keys to the .env file:
OPENAI_API_KEY=your_openai_api_key
TAVILY_API_KEY=your_tavily_api_key# Start with the basics
python 01_Basics/react_agent.py
# Run the full Essay Writer agent
python 05_Use_Cases/essay_writer_agent.py| Module | What You'll Build | Core Concept |
|---|---|---|
01_Basics |
ReAct agent from scratch | Nodes, Edges, State |
02_State_Management |
Persistent multi-session agent | SqliteSaver, Threading |
03_Tool_Integration |
Search-augmented agent | Tavily, Tool Calling |
04_Human_in_the_loop |
Supervised agent with approval gates | interrupt_before, Time Travel |
05_Use_Cases |
Full Essay Writer with reflection | Cyclic workflows, Self-critique |
| Tool | Role |
|---|---|
| LangGraph | Graph-based agent orchestration |
| LangChain | LLM abstraction & tool layer |
| OpenAI GPT-4o | Core reasoning model |
| Tavily | LLM-optimized web search |
| SQLite | Local agent state persistence |
Contributions, issues, and feature requests are welcome. Feel free to open a PR or issue.
github.com/ozereray