This example demonstrates how to use LangGraph's RemoteGraph as a subgraph in a parent graph, including thread-level persistence.
- Create and activate a virtual environment:
python -m venv venv
.\venv\Scripts\activate # On Windows
source venv/bin/activate # On Unix/MacOS
- Install dependencies:
pip install -r requirements.txt
- Configure environment variables:
- Copy
.env.example
to.env
- Update the following variables in
.env
:DEPLOYMENT_URL
: Your LangGraph deployment URLLANGSMITH_API_KEY
: Your LangSmith API key
- Copy
The example demonstrates:
- Using RemoteGraph as a subgraph in a parent graph
- Invoking the graph synchronously
- Streaming outputs from both parent and child graphs
- Thread-level persistence for maintaining state
Run the example:
python remote_graph_example.py
remote_graph_example.py
: Main example coderequirements.txt
: Project dependencies.env
: Environment variables (not in version control)README.md
: This documentation
- Python 3.8+
- LangGraph deployment URL
- LangSmith API key