Skip to content

Repository files navigation

LangGraph Agentic Workflows 🧠

Python LangGraph LangChain License Status

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.


Table of Contents


🔍 Overview

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.


🏗 Architecture

User Input
    │
    ▼
┌─────────────────────────────────────┐
│           LangGraph Agent           │
│                                     │
│  ┌────────┐    ┌────────┐           │
│  │  Node  │───▶│  Node  │           │
│  └────────┘    └───┬────┘           │
│       ▲            │  (cyclic)      │
│       └────────────┘                │
│                                     │
│  State: SqliteSaver (persistent)    │
│  Tools: Tavily Search               │
│  Gates: Human-in-the-Loop           │
└─────────────────────────────────────┘
    │
    ▼
Structured Output / Final Response

📁 Project Structure

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

🌟 Key Concepts

1. Agentic Workflows (Cyclic Graphs)

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.

2. State Management & Persistence

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.

3. Human-in-the-Loop

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.

4. Time Travel & State Forking

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.

5. Agentic Search (Tavily)

Unlike standard web search, Tavily is optimized for LLM consumption — returning clean, structured, citation-ready results that agents can reason over directly.


🚀 Getting Started

Prerequisites

  • Python 3.10+
  • OpenAI API key
  • Tavily API key (free tier available at tavily.com)

Installation

# 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 .env

Configuration

Add your API keys to the .env file:

OPENAI_API_KEY=your_openai_api_key
TAVILY_API_KEY=your_tavily_api_key

Run a Module

# 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 Walkthrough

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

🛠 Tech Stack

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

🤝 Contributing

Contributions, issues, and feature requests are welcome. Feel free to open a PR or issue.


Built with 🧠 for the AI Agent community
github.com/ozereray

About

An advanced agentic workflow implementation using LangGraph and LangChain, featuring iterative research, autonomous planning, and persistent state management for high-quality content generation.

Topics

Resources

Stars

2 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages