langgraph-up-monorepo
langgraph-up-monorepo copied to clipboard
A batteries-included monorepo framework for building sophisticated LangGraph applications
๐ LangGraph-UP Monorepo
LangGraph-UP Monorepo showcases how to build production-ready LangGraph agents using the latest LangChain & LangGraph V1 ecosystem, organized in a clean monorepo structure with shared libraries and multiple agent applications.
โจ Key Features
- ๐ Universal Model Loading - OpenRouter, Qwen, QwQ, SiliconFlow with automatic registration
- ๐ค Multi-Agent Orchestration - Supervisor & deep research patterns with specialized sub-agents
- ๐ LangChain v1.0 Middleware - Model switching, file masking, summarization with v1.0 pattern
- ๐ฌ Deep Research Agent - Advanced research workflow with deepagents integration
- ๐งช Developer Experience - Hot reload, comprehensive testing, strict linting, PyPI publishing
- ๐ Deployment Ready - LangGraph Cloud configurations included
- ๐ Global Ready - Region-based provider configuration (PRC/International)
๐ Quick Start
Installation
# Install UV package manager
curl -LsSf https://astral.sh/uv/install.sh | sh
# Clone and setup
git clone https://github.com/webup/langgraph-up-monorepo.git
cd langgraph-up-monorepo
uv sync --dev
30-Second Demo
from langgraph_up_devkits import load_chat_model
# Zero-setup model loading across providers
model = load_chat_model("openrouter:anthropic/claude-sonnet-4")
# model = load_chat_model("qwen:qwen-flash")
# model = load_chat_model("siliconflow:Qwen/Qwen3-8B")
# Start building your agent
from sample_agent import make_graph
app = make_graph()
result = await app.ainvoke({"messages": [{"role": "user", "content": "What's 25 * 4?"}]})
Sample Agents
This monorepo includes two complete agent examples demonstrating different patterns:
๐ค sample-agent: Supervisor Pattern
Multi-agent system with a coordinator that delegates to specialized sub-agents.
make dev sample-agent
Features:
- Supervisor-based coordination
- Math expert (add, multiply operations)
- Research expert (web search capabilities)
- Cross-agent handoffs
๐ฌ sample-deep-agent: Deep Research Pattern
Advanced research workflow with virtual file system and structured planning.
make dev sample-deep-agent
Features:
- Deep web search with content extraction
- Virtual file system for document management
- Think tool for strategic TODO planning
- Research & critique sub-agents
- FileSystemMaskMiddleware to optimize token usage
๐ Architecture
Monorepo Structure
langgraph-up-monorepo/
โโโ libs/
โ โโโ shared/ # Shared utilities
โ โโโ common/ # Common helper functions
โ โโโ langgraph-up-devkits/ # ๐ฏ Core framework (published to PyPI)
โ โโโ utils/providers.py # โ Multi-provider model loading
โ โโโ middleware/ # โ Custom middleware (model, file, summary)
โ โโโ tools/ # โ Web search, deep search, MCP integration
โ โโโ context/ # โ Context schemas & aware prompts
โโโ apps/
โ โโโ sample-agent/ # ๐ค Supervisor pattern (math + research agents)
โ โ โโโ src/sample_agent/
โ โ โ โโโ graph.py # โ Main supervisor graph
โ โ โ โโโ subagents/ # โ Math & research experts
โ โ โ โโโ tools/ # โ Agent-specific tools
โ โ โโโ langgraph.json # โ Deployment config
โ โโโ sample-deep-agent/ # ๐ฌ Deep research pattern (VFS + think tool)
โ โโโ src/sample_deep_agent/
โ โ โโโ graph.py # โ Deep agent with research workflow
โ โ โโโ subagents.py # โ Research & critique experts
โ โ โโโ prompts.py # โ Structured TODO planning prompts
โ โโโ langgraph.json # โ Deployment config
โโโ pyproject.toml # Root dependencies
โโโ Makefile # Development commands
โโโ PUBLISHING.md # PyPI publishing guide
โโโ .github/workflows/ # CI/CD pipeline
Core Components
๐ Universal Model Loading
Automatic provider registration with fallback support:
from langgraph_up_devkits import load_chat_model
# Anthropic via OpenRouter (preferred)
model = load_chat_model("openrouter:anthropic/claude-sonnet-4")
# Qwen models (PRC/International regions)
model = load_chat_model("qwen:qwen-flash")
# SiliconFlow models
model = load_chat_model("siliconflow:Qwen/Qwen3-8B")
# With configuration
model = load_chat_model(
"openrouter:anthropic/claude-sonnet-4",
temperature=0.7,
max_tokens=1000
)
๐ค Multi-Agent Patterns
from sample_agent.subagents import math, research
from sample_agent.tools import create_handoff_tool
# Create specialized agents
math_agent = math.make_graph()
research_agent = research.make_graph()
# Enable handoffs between agents
math_to_research = create_handoff_tool("research_expert")
research_to_math = create_handoff_tool("math_expert")
๐ง Custom Middleware (LangChain v1.0)
Built-in middleware for dynamic model switching, state management, and behavior modification using the LangChain v1.0 middleware pattern:
from langchain.agents import create_agent
from langgraph_up_devkits.middleware import (
ModelProviderMiddleware,
FileSystemMaskMiddleware,
)
from langgraph_up_devkits import load_chat_model
# Model provider middleware for automatic switching
model_middleware = ModelProviderMiddleware()
# File system middleware to mask large file content from LLM context
fs_middleware = FileSystemMaskMiddleware()
agent = create_agent(
model=load_chat_model("openrouter:gpt-4o"), # Fallback model
tools=[web_search, deep_web_search],
middleware=[model_middleware, fs_middleware]
)
# Context specifies different model - middleware switches automatically
context = {"model": "siliconflow:Qwen/Qwen3-8B"}
result = await agent.ainvoke(messages, context=context)
Available Middleware (v1.0 Compatible):
-
ModelProviderMiddleware- Dynamic model switching based on context -
FileSystemMaskMiddleware- Masks virtual file systems from LLM to save tokens -
SummarizationMiddleware- Automatic message summarization for long conversations
Key Changes in v1.0:
- Migrated to LangChain v1.0 middleware pattern with
before_model()andafter_model()hooks - Compatible with
langchain.agents.create_agentmiddleware system - Improved state management and model switching reliability
For detailed documentation on additional features like middleware, tools, and utilities, see:
-
Framework Documentation:
libs/langgraph-up-devkits/README.md -
Agent Examples:
apps/sample-agent/README.md
๐ Development
Commands
See the Makefile for complete command reference.
# Testing
make test # Run all tests
make test_libs # Test libraries only
make test_apps # Test applications only
make unit sample-agent # Test specific app
# Code Quality
make lint # Run linters (ruff + mypy)
make format # Format code
# Development
make dev sample-agent # Start dev server with browser
make dev sample-agent -- --no-browser # Start without browser
make dev sample-agent -- --host 0.0.0.0 --port 3000 # Custom host/port
# Publishing (langgraph-up-devkits)
make build_devkits # Build distribution packages
make check_devkits # Validate package
make release_test_devkits # Build and publish to Test PyPI
make release_devkits # Build and publish to PyPI
See PUBLISHING.md for detailed publishing guide.
Project Structure Guidelines
-
libs/- Reusable packages shared across agents -
apps/- Individual agent implementations -
Shared dependencies - Managed in root
pyproject.toml -
Agent-specific deps - In app-level
pyproject.toml
Creating New Agents
# Copy sample agent structure
cp -r apps/sample-agent apps/my-agent
# Update configuration
# Edit apps/my-agent/langgraph.json
# Edit apps/my-agent/pyproject.toml
# Implement apps/my-agent/src/my_agent/graph.py
๐งช Testing
# Run all tests (126+ tests in libs, 10+ in apps)
make test
# Run tests for specific components
make test_libs # Test libraries only
make test_apps # Test applications only
make unit sample-agent # Test specific app
๐ง Troubleshooting
Common issues and detailed troubleshooting guides are available in:
-
Setup Issues:
libs/langgraph-up-devkits/README.md#troubleshooting -
Agent Issues:
apps/sample-agent/README.md#troubleshooting
๐ค Contributing
Development Setup
git clone https://github.com/your-org/langgraph-up-monorepo.git
cd langgraph-up-monorepo
uv sync
make lint # Ensure code quality
make test # Run test suite
Code Standards
- Type Safety - Strict mypy checking enabled
- Code Style - Ruff formatting and linting
- Testing - High test coverage required
- Documentation - Comprehensive docstrings
Submission Process
- Fork the repository
- Create feature branch (
git checkout -b feature/amazing-feature) - Ensure tests pass (
make test) - Ensure linting passes (
make lint) - Commit changes (
git commit -m 'Add amazing feature') - Push to branch (
git push origin feature/amazing-feature) - Open Pull Request
๐ License
This project is licensed under the MIT License - see the LICENSE file for details.
๐ Acknowledgments
Core Frameworks
Development Tools
- UV - Fast Python package management
- langchain-dev-utils - Development utilities for LangChain
Model Providers
- OpenRouter - Multi-provider model access
Built with โค๏ธ for the LangGraph community
Ready to build production-grade agents? Get started โ