π Interactive Web Showcase & Simulator: phlppgdfry.github.io/langgraph-multi-agent-system
A production-grade, stateful multi-agent intelligence swarm built with LangGraph, LangChain Core, LangSmith observability, reflection-driven self-correction, SQLite state persistence, and Human-in-the-Loop governance.
In real-world enterprise deployments, single-turn LLM chains fail because they lack state persistence, cyclical feedback, verifiable audit trails, and human oversight.
Nexus demonstrates how to build an enterprise-grade autonomous multi-agent system utilizing LangGraph's cyclically directed state graphs and LangChain's unified tool abstractions. The system coordinates a team of specialized agents that gather live intelligence, extract quantitative KPIs, cross-verify assertions, execute reflection self-correction loops, and generate executive-ready decision briefings.
Full distributed tracing, token consumption, and run trees are piped directly to LangSmith for enterprise observability and latency profiling.
[Objective / Prompt]
β
βΌ
βββββββββββββββββββββ
β π§ Supervisor ββββββββββββββββββββββ
βββββββββββ¬ββββββββββ β
β (Dynamic Planning & Routing) β (Self-Correction & Updates)
βΌ β
βββββββββββββββββββββ β
β π¬ Researcher ββββββββββββββββββββββ€
βββββββββββ¬ββββββββββ β
βΌ β
βββββββββββββββββββββ β
β π Data Analyst ββββββββββββββββββββββ€
βββββββββββ¬ββββββββββ β
βΌ β
βββββββββββββββββββββ β
β βοΈ Critic Agent βββββ[Score < 80]βββββ
βββββββββββ¬ββββββββββ
β [Score >= 80]
βΌ
βββββββββββββββββββββ
β π‘οΈ Human Gate β (Checkpointed Approval / State Rewind)
βββββββββββ¬ββββββββββ
βΌ
βββββββββββββββββββββ
β βοΈ Executive Writerβ
βββββββββββ¬ββββββββββ
βΌ
[π Strategic Briefing .md]
flowchart TD
START([Start / User Objective]) --> Supervisor[π§ Supervisor Agent]
subgraph Swarm ["Nexus Agent Swarm (LangGraph StateGraph)"]
Supervisor -->|Route: Research| Researcher[π¬ Researcher Agent]
Researcher -->|Emit: research_notes| Supervisor
Supervisor -->|Route: Analysis| Analyst[π Data Analyst Agent]
Analyst -->|Emit: quantitative_data| Supervisor
Supervisor -->|Route: Quality Audit| Critic[βοΈ Critic / Fact-Checker]
Critic -->|Reflection Rejection < 80| Supervisor
Critic -->|Verification Passed >= 80| Supervisor
Supervisor -->|Route: Governance Check| HumanGate{π‘οΈ Human-in-the-Loop Gate}
HumanGate -->|Approved| Writer[βοΈ Executive Writer Agent]
HumanGate -->|Revision Requested| Supervisor
end
Writer --> FinalReport([π Executive Briefing Markdown])
FinalReport --> END([End])
classDef agent fill:#0f172a,stroke:#38bdf8,stroke-width:2px,color:#ffffff;
classDef gate fill:#2e1065,stroke:#c084fc,stroke-width:2px,color:#ffffff;
classDef terminus fill:#022c22,stroke:#4ade80,stroke-width:2px,color:#ffffff;
class Supervisor,Researcher,Analyst,Critic,Writer agent;
class HumanGate gate;
class START,END,FinalReport terminus;
| Agent | Core Responsibility | Capabilities & Tools |
|---|---|---|
| π§ Supervisor | Dynamic Workflow Orchestration | Task decomposition, 4-phase planning, state routing, and revision cycle tracking. |
| π¬ Researcher | Primary Intelligence Gathering | Web search (search_web), snippet curation, source triangulation, and fact retrieval. |
| π Analyst | Quantitative & Metric Extraction | Financial KPI parsing (extract_metrics), latency/accuracy calculations, and scorecarding. |
| βοΈ Critic | Reflection & Quality Assurance | Multi-source verification (verify_claim), rigor scoring (0-100), and self-correction loops. |
| π‘οΈ Human Gate | Governance & Checkpoint Oversight | Human-in-the-loop interruption via SQLite SqliteSaver checkpoints before publication. |
| βοΈ Writer | Executive Briefing Synthesis | C-suite markdown reporting with TL;DR, methodology, quantitative scorecards, and citations. |
Nexus is pre-instrumented for LangSmith out-of-the-box. Every agent action, tool invocation, token spend, latency metric, and reflection cycle is captured in an auditable trace tree.
Run: nexus-multi-agent-system [Status: SUCCESS]
βββ supervisor [ChatOpenAI] (latency: 142ms, tokens: 380)
β βββ Input: "Analyze enterprise multi-agent adoption..."
β βββ Output: "[Supervisor] Plan initialized: 4 steps..."
βββ researcher (latency: 410ms)
β βββ Tool: search_web(query="...") [HTTP 200 OK]
βββ analyst (latency: 88ms)
β βββ Tool: extract_metrics(...) [4 benchmarks extracted]
βββ critic (latency: 165ms)
β βββ Tool: verify_claim(...) [Quality Score: 96/100, PASSED]
βββ writer [ChatOpenAI] (latency: 520ms, tokens: 1,120)
βββ Output: "# Strategic Intelligence Briefing..."
Run the interactive configuration wizard:
uv run python -m langgraph_multi_agent_system.cli --configureOr set .env:
LANGCHAIN_TRACING_V2=true
LANGCHAIN_ENDPOINT="https://api.smith.langchain.com"
LANGCHAIN_API_KEY=lsv2_pt_your_langsmith_api_key_here
LANGCHAIN_PROJECT="nexus-multi-agent-system"Read the complete LangSmith Observability Guide.
- Python 3.11+
uv(recommended ultra-fast package manager)
git clone https://github.com/phlppgdfry/langgraph-multi-agent-system.git
cd langgraph-multi-agent-system
# Install dependencies in under 2 seconds with uv
uv sync# Run with default enterprise research prompt:
uv run python -m langgraph_multi_agent_system.cli
# Or specify a custom strategic prompt:
uv run python -m langgraph_multi_agent_system.cli "Analyze AI Agent ROI in Multimodal Freight Logistics"
# Enable Human-in-the-Loop checkpoint review before report publication:
uv run python -m langgraph_multi_agent_system.cli "Enterprise Agentic FinOps" --human-approval
# Save the generated markdown briefing:
uv run python -m langgraph_multi_agent_system.cli "LangGraph vs Linear Chains" -o briefing.mduv run streamlit run src/langgraph_multi_agent_system/app.pyOpen http://localhost:8501 to interact with the swarm in real-time, view live node progression, inspect critique scores, and download executive briefings.
Native integration via langgraph.json:
langgraph devNexus implements true checkpoint interruption. When an operator enables --human-approval, execution halts before the executive writer, stores state in SQLite, and can be resumed out-of-process hours later:
# 1. Start pipeline with approval gate
uv run python -m langgraph_multi_agent_system.cli "Evaluate Demurrage Risk" --human-approval
# 2. In a new process or session, inspect and resume:
uv run python -m langgraph_multi_agent_system.cli --resume <THREAD_ID> --approve
# Or request revision:
uv run python -m langgraph_multi_agent_system.cli --resume <THREAD_ID> --reject --feedback "Deepen financial metrics"Objectively compare Single-Agent Direct, Tool-Augmented, Sequential, Parallel Map-Reduce, and Nexus Swarm across latency, token spend, and factual grounding:
uv run python -m langgraph_multi_agent_system.cli --benchmark-compareThe benchmarking suite (src/langgraph_multi_agent_system/evals/comparative_benchmark.py) provides two scientifically separated modes:
- Mode A (Deterministic Simulation): Uses
MockChatModelto isolate pure LangGraph StateGraph engine latency, state routing, checkpoint writing, and reflection cycle overhead from network jitter. - Mode B (Real Agent Performance): Runs live with genuine LLM providers (
gpt-4o-mini,claude-3-5-haiku) and real tools, measuring end-to-end network roundtrips and token spend.
| Architecture Baseline | Avg Engine Latency | Sources Analyzed | KPIs Parsed | Factual Grounding (Objective) | Token Spend | Est. Cost ($) | Architectural Trade-Off Profile |
|---|---|---|---|---|---|---|---|
| Baseline A: Single-Agent Direct | 0.9 ms |
0.0 | 0.0 | 0.0% |
~31 | $0.00006 | Zero citations; high hallucination risk. |
| Baseline B: Single-Agent + Tools | 80.2 ms |
2.0 | 3.3 | 32.7% |
~222 | $0.00045 | Single search pass; no reflection or critique. |
| Baseline C: Sequential Multi-Agent | 5.5 ms |
2.0 | 3.3 | 72.0% |
~609 | $0.00122 | Linear pipeline; errors cascade to writer. |
| Baseline D: Parallel Map-Reduce | 8.8 ms |
6.0 | 7.3 | 85.0% |
~1,475 | $0.00295 | 3x evidence density; lacks self-correction. |
| Baseline F: Nexus Swarm (Reflection) | 26.9 ms |
6.0 | 7.3 | 100.0% | ~2,694 | $0.00539 | 100% grounding & citations; higher token spend. |
(Note: Live LLM execution in Mode B exhibits ~3,500 ms total latency dominated by model inference and search HTTP roundtrips; engine overhead is < 30 ms).
All claims in this repository are backed by 12 independent engineering audits and technical reports:
| Document | Focus & Coverage |
|---|---|
| π¬ Final Principal AI Audit | Independent findings register (AUD-001β015), code references, and objective capability matrix. |
| π Benchmark Methodology Review | Forensic separation of simulation vs live benchmarks and objective grounding formulations. |
| β‘ Real Agent Performance Evaluation | Engine overhead profiling vs live LLM roundtrips and token consumption. |
| πΎ Memory Persistence Audit | Thread-safe RLock, atomic write protocol (NamedTemporaryFile + os.replace), and tenant isolation. |
| π‘οΈ HITL Reliability Report | Out-of-process SQLite interrupt/resume, idempotency verification, and structured JSONL audit trail. |
| π LangSmith Cloud Validation | Live EU endpoint audit across Distributed Tracing, Datasets, Queues, and Prompt Hub. |
| π Agentic Security Threat Model | OWASP Top 10 for LLMs, SSRF private IP validation, and regex prompt injection sanitization. |
| π§ͺ Agent Evaluation Framework | 4-dimensional evaluation rubric: Grounding, Quantitative Density, Structure, and FinOps. |
| π Continuous Improvement Design | Autonomous flywheel connecting flagged low scores, annotation queues, and dynamic prompt templates. |
| π’ Enterprise Reference Scenario | Parametric cost-benefit modeling and feasibility analysis for operational document logistics. |
| πΌ Final Portfolio Readiness | Recruiter and architectural assessment with a 5-minute live demonstration script. |
| Transparent disclosure of technical constraints and prioritized engineering roadmap. | |
| π‘ Observability Architecture | P50/P95 latencies, FinOps token accounting, and alert thresholds. |
| π Production Readiness Runbook | Non-root Docker, health checks, SQLite disaster recovery. |
| π Portfolio Showcase Guide | Narrative for technical directors and hiring managers. |
| πΊοΈ Architectural Roadmap | MCP integration, Command state updates, and semantic caching. |
The repository maintains 100% pass rates across unit tests and linter checks:
# Run full pytest test suite (45 unit & integration tests)
make test
# or
uv run pytest -v
# Run ruff code linter
make lintlanggraph-multi-agent-system/
βββ .github/
β βββ workflows/
β βββ ci.yml # Multi-Python (3.11, 3.12, 3.13) GitHub Actions CI
βββ data/
β βββ swarm_checkpoints.db # SQLite persistence database (thread replay)
βββ docs/
β βββ ARCHITECTURE.md # Deep-dive into StateGraph, routing & memory
β βββ LANGSMITH_GUIDE.md # Tracing setup, eval runs & latency analysis
β βββ HUMAN_IN_THE_LOOP.md # Checkpointing, interruption gates & state rewind
βββ examples/
β βββ reports/ # Pre-generated sample executive briefings
βββ src/
β βββ langgraph_multi_agent_system/
β βββ __init__.py # Package exports
β βββ state.py # TypedDict global state schema (MessagesState)
β βββ tools.py # Search, metric extraction & verification tools
β βββ checkpoint.py # Unified SQLite & MemorySaver checkpointer
β βββ graph.py # StateGraph topology & conditional routers
β βββ cli.py # Interactive Rich terminal runner & config wizard
β βββ app.py # Interactive Streamlit Web UI
β βββ agents/
β β βββ supervisor.py # Master orchestration agent
β β βββ researcher.py # Research & source gathering
β β βββ analyst.py # Quantitative extraction
β β βββ critic.py # Reflection & self-correction scoring
β β βββ human_gate.py # Human-in-the-loop checkpoint gate
β β βββ writer.py # Executive report generator
β βββ evals/
β βββ run_evals.py # Automated LangSmith evaluation suite
βββ tests/
β βββ test_graph.py # Integration, persistence & execution tests
β βββ test_tools.py # Tool unit tests
βββ scripts/
β βββ export_graph.py # Mermaid topology exporter
βββ langgraph.json # LangGraph Studio configuration
βββ pyproject.toml # Modern uv / pip project metadata
βββ .env.example # Environment variable configuration guide
βββ LICENSE # MIT License
βββ README.md # Project documentation
- Stateful Graph Orchestration (
StateGraph): Replaces linear chains with inspectable, cyclical state machines. - Reflection & Self-Correction: Factual scoring that redirects deficient outputs back to researchers before user delivery.
- Deterministic Zero-Key Demo Mode: Built with resilient fallbacks so reviewers can clone and run tests/demos without needing paid API credits.
- State Persistence (
SqliteSaver): Checkpointed state transitions allowing step replay, thread resumption, and human intervention. - Observability First: Deep LangSmith tracing for enterprise auditability and latency profiling.
Philippe Godfroy
- GitHub: @phlppgdfry
- Email: philippe.godfroy@hotmail.com
This project is licensed under the MIT License.