mirror of
https://github.com/langchain-ai/langgraph.git
synced 2026-08-24 00:22:25 +02:00
3.4 KiB
3.4 KiB
LangGraph Coding Guide
Build/Test/Lint Commands
- Run all tests:
make test - Run single test:
make test TEST=path/to/test_file.py::test_function - Watch mode tests:
make test_watch - Run tests in parallel:
make test_parallel - Generate coverage report:
make coverage - Format code:
make format - Lint code:
make lint - Check spelling:
make spell_check - Fix spelling:
make spell_fix - Build documentation:
make serve-docs(from repo root) - Run benchmarks:
make benchmarkormake benchmark-fast
Code Style Guidelines
- Follow ruff formatting/linting rules
- Use Google Python Style Guide for docstrings
- Enforce type annotations with mypy (
disallow_untyped_defs = True) - Use double quotes for strings
- Maximum line length of 88 characters
- Follow imports sorting with
ruff - All functions/classes must have proper docstrings with args/returns
- Write comprehensive unit tests for new features
- Keep backward compatibility
- PR scope should be isolated (changes shouldn't affect multiple packages)
- Use descriptive variable names following Python conventions
- Error handling should use appropriate exception types and messaging
Feature Overview
langgraph is an orchestration framework (in the style of airflow or temporal) designed for LLM applications, with a focus on streaming output, cyclical and parallel workflows, and interrupt/resume capabilities. Applications built with langgraph are variously called workflows, graphs, cognitive architectures, agents. Key features:
- Graph-based Architecture: Build directed computation graphs with nodes and edges
- State Management: Type-safe state schema with custom reducers and transformations
- Human-in-the-loop: Support for interrupts, checkpoints, and tool call review
- Persistence: Save and resume execution with in-memory or database storage
- Streaming: Multiple modes (values, updates, custom) for real-time feedback
- Multi-agent Patterns: Support for network, supervisor, and hierarchical architectures
Repository Structure
LangGraph follows a monorepo organization, with the following structure:
docs/contains the source code (markdown and jupyter notebooks) for our documentation (hosted at https://langchain-ai.github.io/langgraph/)libs/langgraphis the main library, published to pypi aslanggraph. This contains the majority of the code for the framework, as well as the majority of the unit tests.libs/checkpoint, published to pypi aslanggraph-checkpointcontains the base classes for the persistence layer of langgraph. The two main abstractions are BaseCheckpointSaver (base class for persistence of workflow runs step-by-step) and BaseStore (base class for "long-term memory" operations, offering a key-value interface combined with semantic search over documents, used for persisting information across distinct workflow runs). This library is a dependency of both the main langgraph library, as well as implementations of these storage interfaces for specific databases. This library also contains reference implementationslibs/checkpoint-postgrespublished to pypi as langgraph-checkpoint-postgres, contains implementations of checkpoint and store backed by postgres. Majority of the test coverage is inlibs/langgraphin the form of tests that run over all storage implementations in the repo.