Skip to content

webup/langgraph-up-monorepo

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

26 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸš€ 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.

Version LangChain LangGraph License PyPI Twitter

✨ 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() and after_model() hooks
  • Compatible with langchain.agents.create_agent middleware system
  • Improved state management and model switching reliability

For detailed documentation on additional features like middleware, tools, and utilities, see:

πŸ›  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:

🀝 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

  1. Fork the repository
  2. Create feature branch (git checkout -b feature/amazing-feature)
  3. Ensure tests pass (make test)
  4. Ensure linting passes (make lint)
  5. Commit changes (git commit -m 'Add amazing feature')
  6. Push to branch (git push origin feature/amazing-feature)
  7. Open Pull Request

πŸ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.

πŸ™ Acknowledgments

Core Frameworks

Development Tools

Model Providers


Built with ❀️ for the LangGraph community

Ready to build production-grade agents? Get started β†’