Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
59 commits
Select commit Hold shift + click to select a range
662053d
Add LangGraph Hello World sample
mfateev Dec 27, 2025
18b995a
Add README for react_agent sample
mfateev Dec 27, 2025
f8f51a0
LangGraph: Use ClientConfig for client initialization in all samples
mfateev Dec 27, 2025
6b96e09
LangGraph: Add react_agent and approval_workflow sample files
mfateev Dec 27, 2025
2e5c82e
LangGraph: Add README for approval_workflow and update react_agent RE…
mfateev Dec 27, 2025
0432967
LangGraph: Add notification activity and CLI response tool to approva…
mfateev Dec 27, 2025
ca793bf
LangGraph: Wrap model with temporal_model for durable LLM calls in re…
mfateev Dec 27, 2025
5adef7d
LangGraph: Update react_agent sample to use create_durable_react_agent
mfateev Dec 27, 2025
3b62683
LangGraph: Update react_agent to use new activity_options API
mfateev Dec 27, 2025
1fb4682
LangGraph: Use native create_react_agent instead of wrappers
mfateev Dec 27, 2025
c18f9cb
LangGraph: Update SAMPLES_PROPOSAL.md to reflect simplified API
mfateev Dec 27, 2025
d3fe116
LangGraph: Use create_agent from langchain.agents (create_react_agent…
mfateev Dec 27, 2025
771b46a
LangGraph: Update react_agent sample to demonstrate multi-step agenti…
mfateev Dec 28, 2025
f579c0d
LangGraph: Add RAG sample and update documentation
mfateev Dec 28, 2025
57110cf
LangGraph: Update README with branch installation instructions
mfateev Dec 28, 2025
0302320
LangGraph: Remove unnecessary hasattr check in agentic_rag
mfateev Dec 28, 2025
e82d0a5
LangGraph samples: Use create_agent instead of deprecated create_reac…
mfateev Dec 29, 2025
3475e6f
langgraph-supervisor dependency added
mfateev Dec 29, 2025
7db14fe
LangGraph: Add deep research, plan-and-execute, and reflection samples
mfateev Dec 29, 2025
0beeb3c
LangGraph samples: Standardize usage instructions in READMEs
mfateev Dec 29, 2025
3e6df8f
LangGraph: Deep research sample uses real DuckDuckGo web search
mfateev Dec 29, 2025
d772f0a
LangGraph samples: Flatten directory structure to single level
mfateev Dec 29, 2025
fe7134d
LangGraph samples: Update README run commands for flattened structure
mfateev Dec 29, 2025
58516c1
Fix lint errors in langgraph samples
mfateev Dec 30, 2025
9b17b34
Add unit tests for hello_world LangGraph sample
mfateev Dec 30, 2025
6e320fa
Add tests for all LangGraph samples and fix serialization bugs
mfateev Dec 30, 2025
3b54795
Add activity_from_node sample demonstrating run_in_workflow
mfateev Dec 30, 2025
d097a07
Split approval workflow into two samples demonstrating different appr…
mfateev Dec 30, 2025
982f75a
Move approval workflow samples to human_in_the_loop directory
mfateev Dec 30, 2025
76162db
Rename human_in_the_loop samples for clarity
mfateev Dec 30, 2025
b083bfe
Update samples README with human_in_the_loop samples
mfateev Dec 30, 2025
cc9480c
Add README for human_in_the_loop samples
mfateev Dec 30, 2025
fa7f1bb
Add tests for human_in_the_loop samples and fix wait_condition graph
mfateev Dec 30, 2025
faf4dce
Add Serena consultation instruction to CLAUDE.md
mfateev Dec 30, 2025
c7f240a
Rename langgraph_samples to langgraph_plugin
mfateev Dec 31, 2025
c95ddac
Fix pyproject.toml reference to langgraph_plugin
mfateev Dec 31, 2025
bb536f0
Add graph visualization queries to approval workflow samples
mfateev Dec 31, 2025
2a313c1
Add get_graph_state query to approval workflow samples
mfateev Dec 31, 2025
a68e14c
Return typed GraphStateResponse from get_graph_state query
mfateev Dec 31, 2025
bb741b3
Add Available Queries section to human_in_the_loop README
mfateev Dec 31, 2025
d69f011
Add LangGraph Functional API Temporal integration proposal
mfateev Jan 1, 2026
4013b7b
LangGraph Functional API: Entrypoints run in workflow sandbox
mfateev Jan 2, 2026
f06c6a1
LangGraph: Reorganize samples into graph_api and functional_api
mfateev Jan 2, 2026
d3ce31e
Add functional API samples matching graph API examples
mfateev Jan 2, 2026
7030c84
Fix test isolation: clear functional entrypoint registry between tests
mfateev Jan 2, 2026
4788ea7
Add functional API tests and update CLAUDE.md with lint and test guid…
mfateev Jan 2, 2026
67b0e51
Fix functional API test assertions to match entrypoint return keys
mfateev Jan 2, 2026
c15f496
Add comprehensive usage documentation for Graph and Functional APIs
mfateev Jan 2, 2026
4fc7d31
Add migration guide for adapting LangGraph Functional API to Temporal
mfateev Jan 2, 2026
de57b8b
Add README documentation for each Functional API sample
mfateev Jan 3, 2026
9df7258
Fix configuration options documentation to use correct SDK parameters
mfateev Jan 3, 2026
d435497
Add activity_options to all graph_api samples
mfateev Jan 3, 2026
dde6e5b
LangGraph Functional API: Add activity_options() to all samples
mfateev Jan 3, 2026
54a557b
LangGraph: Update samples to use unified LangGraphPlugin API
mfateev Jan 3, 2026
d864d2a
Add continue-as-new sample for Functional API
mfateev Jan 5, 2026
e3c5257
Add continue_as_new sample to README
mfateev Jan 5, 2026
1b57043
Update Functional API continue-as-new to use should_continue callback
mfateev Jan 8, 2026
f421461
Update Graph API README paths to new directory structure
mfateev Jan 9, 2026
6118979
Add architecture diagrams for Temporal + LangGraph integration
mfateev Jan 9, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Add LangGraph Hello World sample
- Add langgraph_samples/basic/hello_world/ demonstrating basic
  Temporal + LangGraph integration with a single-node graph
- Add langgraph dependency group to pyproject.toml
- Update langchain dependency group to 0.3.x for compatibility
  with langgraph (requires langchain-core>=0.2.27)
  • Loading branch information
mfateev committed Dec 27, 2025
commit 662053d2d003d491e68ecd6b02d48ed27cbcabed
24 changes: 24 additions & 0 deletions langgraph_samples/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Temporal LangGraph Samples

These samples demonstrate the [Temporal LangGraph integration](https://github.com/temporalio/sdk-python/blob/main/temporalio/contrib/langgraph/README.md) - combining LangGraph's agent framework with Temporal's durable execution.

See the [module documentation](https://github.com/temporalio/sdk-python/blob/main/temporalio/contrib/langgraph/README.md) for more information.

## Overview

The integration combines:
- **Temporal workflows** for orchestrating agent control flow and state management
- **LangGraph** for defining agent graphs with conditional logic, cycles, and state

This approach ensures that AI agent workflows are durable, observable, and can handle failures gracefully.

## Prerequisites

- Temporal server [running locally](https://docs.temporal.io/cli/server#start-dev)
- Required dependencies installed via `uv sync --group langgraph`

## Examples

Each directory contains complete examples with their own README for detailed instructions:

- **[Basic Examples](./basic/README.md)** - Simple examples including a hello world agent demonstrating basic plugin setup and graph registration.
349 changes: 349 additions & 0 deletions langgraph_samples/SAMPLES_PROPOSAL.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,349 @@
# Temporal LangGraph Samples Proposal

This document proposes sample applications demonstrating the [Temporal LangGraph integration](https://github.com/temporalio/sdk-python/blob/main/temporalio/contrib/langgraph/README.md) - combining LangGraph's agent framework with Temporal's durable execution.

## Design Principles

Each sample should demonstrate:
1. **Durability** - Agents that survive failures and can resume from checkpoints
2. **Production Readiness** - Proper timeout/retry configuration, error handling
3. **Temporal Features** - Leveraging signals, queries, child workflows where appropriate

Samples are organized by complexity and use case, inspired by [OpenAI Agents samples](../openai_agents/README.md) structure.

---

## Proposed Samples

### 1. Basic Examples (`basic/`)

#### 1.1 Hello World Agent
**Description:** Minimal LangGraph agent with Temporal integration. Single-node graph that processes a query.

**Demonstrates:**
- Basic plugin setup and graph registration
- Simple workflow invocation
- Activity-based node execution

**Original Reference:** N/A (custom introductory example)

---

#### 1.2 ReAct Agent with Tools
**Description:** Classic ReAct (Reasoning + Acting) agent that can use tools to answer questions. Implements the think-act-observe loop.

**Demonstrates:**
- `temporal_model()` for durable LLM calls
- `temporal_tool()` for durable tool execution
- `create_react_agent` integration
- Automatic retries on LLM/tool failures

**Original Reference:** [LangGraph ReAct Agent Template](https://github.com/langchain-ai/react-agent)

---

### 2. Human-in-the-Loop (`human_in_loop/`)

#### 2.1 Approval Workflow
**Description:** Agent that pauses for human approval before taking actions. Uses LangGraph's `interrupt()` with Temporal signals.

**Demonstrates:**
- `interrupt()` for pausing execution
- Temporal signals for receiving human input
- Workflow queries for checking pending approvals
- Timeout handling for approval deadlines

**Original Reference:** [LangGraph Human-in-the-Loop Guide](https://langchain-ai.github.io/langgraph/how-tos/human_in_the_loop/)

---

#### 2.2 Document Review Agent
**Description:** Agent that drafts documents and requests human review/edits before finalizing. Supports iterative refinement cycles.

**Demonstrates:**
- Multi-step interrupt/resume cycles
- State preservation across interrupts
- Combining AI drafting with human editing

**Original Reference:** [LangGraph Human Feedback Discussion](https://github.com/langchain-ai/langgraph/discussions/1137)

---

### 3. Multi-Agent Systems (`multi_agent/`)

#### 3.1 Supervisor Agent
**Description:** Supervisor that coordinates specialized worker agents (researcher, writer, critic). The supervisor routes tasks to appropriate agents and aggregates results.

**Demonstrates:**
- Multi-agent orchestration patterns
- Supervisor decision-making logic
- Agent handoffs and communication
- Parallel agent execution with `Send`

**Original Reference:** [LangGraph Supervisor Library](https://github.com/langchain-ai/langgraph-supervisor-py) | [Multi-Agent Blog Post](https://blog.langchain.com/langgraph-multi-agent-workflows/)

---

#### 3.2 Hierarchical Agent Teams
**Description:** Two-level hierarchy with a top supervisor managing team supervisors (research team + writing team), each with their own worker agents.

**Demonstrates:**
- Child workflows for team isolation
- Hierarchical agent coordination
- Complex routing logic
- Cross-team communication

**Original Reference:** [LangGraph Hierarchical Agent Teams Tutorial](https://langchain-ai.github.io/langgraph/tutorials/multi_agent/hierarchical_agent_teams/)

---

### 4. RAG and Research (`rag/`)

#### 4.1 Agentic RAG
**Description:** RAG agent that decides when to retrieve documents vs. respond directly. Includes document relevance grading and query rewriting.

**Demonstrates:**
- Conditional retrieval decisions
- Document grading nodes
- Query rewriting for better retrieval
- Combining retrieval with generation

**Original Reference:** [LangGraph Agentic RAG Tutorial](https://github.com/langchain-ai/langgraph/blob/main/examples/rag/langgraph_agentic_rag.ipynb) | [Agentic RAG Docs](https://docs.langchain.com/oss/python/langgraph/agentic-rag)

---

#### 4.2 Corrective RAG
**Description:** Self-correcting RAG that validates retrieved documents and falls back to web search when needed. Includes hallucination detection.

**Demonstrates:**
- Document relevance validation
- Fallback to web search
- Self-correction loops
- Multiple retrieval strategies

**Original Reference:** [Corrective RAG Guide](https://www.analyticsvidhya.com/blog/2024/07/building-agentic-rag-systems-with-langgraph/)

---

#### 4.3 Deep Research Agent
**Description:** Multi-step research agent that performs iterative web searches, evaluates results, and synthesizes findings into a comprehensive report.

**Demonstrates:**
- Long-running research workflows (minutes to hours)
- Parallel search execution
- Result evaluation and iteration
- Continue-as-new for large histories
- Report generation

**Original Reference:** [LangGraph Deep Research Agent](https://towardsdatascience.com/langgraph-101-lets-build-a-deep-research-agent/) | [Exa Research System](https://blog.langchain.com/exa/)

---

### 5. Customer Service (`customer_service/`)

#### 5.1 Customer Support Agent
**Description:** Interactive customer service agent that handles inquiries, accesses knowledge bases, and escalates to humans when needed.

**Demonstrates:**
- Conversational state management
- Knowledge base integration
- Escalation workflows with `interrupt()`
- Session continuity across interactions

**Original Reference:** [LangGraph Customer Support Tutorial](https://github.com/langchain-ai/langgraph/blob/main/docs/docs/tutorials/customer-support/customer-support.ipynb)

---

#### 5.2 Email Triage Agent
**Description:** Agent that processes incoming emails, categorizes them, drafts responses using RAG for policy questions, and routes to appropriate handlers.

**Demonstrates:**
- Email classification
- RAG for policy/knowledge lookup
- Conditional routing based on email type
- Draft review before sending

**Original Reference:** [Agentic RAG Customer Support](https://blog.lancedb.com/agentic-rag-using-langgraph-building-a-simple-customer-support-autonomous-agent/)

---

### 6. Planning and Execution (`planning/`)

#### 6.1 Plan-and-Execute Agent
**Description:** Agent that first creates a plan, then executes steps sequentially, with the ability to replan based on results.

**Demonstrates:**
- Separation of planning and execution
- Dynamic replanning
- Step-by-step execution with checkpointing
- Plan validation

**Original Reference:** [LangGraph Plan-and-Execute Tutorial](https://github.com/langchain-ai/langgraph/blob/main/examples/plan-and-execute/plan-and-execute.ipynb)

---

#### 6.2 Travel Planning Agent
**Description:** Agent that plans trips by coordinating flight searches, hotel bookings, and itinerary creation with user preferences.

**Demonstrates:**
- Multi-tool coordination
- User preference handling
- Complex planning with constraints
- Real API integration patterns

**Original Reference:** [LangGraph Travel Planning Tutorial](https://www.projectpro.io/article/langgraph/1109)

---

### 7. Code and Development (`code/`)

#### 7.1 Code Assistant
**Description:** Agent that helps with code-related tasks: explaining code, generating code, debugging, and answering programming questions.

**Demonstrates:**
- Code-aware prompting
- Multi-turn coding conversations
- Tool use for code execution/testing
- Context management for large codebases

**Original Reference:** [LangGraph Code Assistant Tutorial](https://github.com/langchain-ai/langgraph/blob/main/examples/code_assistant/langgraph_code_assistant.ipynb)

---

### 8. Advanced Patterns (`advanced/`)

#### 8.1 Reflection Agent
**Description:** Agent that generates output, reflects on it, and iteratively improves until quality criteria are met.

**Demonstrates:**
- Self-critique and improvement loops
- Quality evaluation nodes
- Iterative refinement patterns
- Loop termination conditions

**Original Reference:** [LangGraph Reflection Tutorial](https://github.com/langchain-ai/langgraph/tree/main/docs/docs/tutorials/reflection)

---

#### 8.2 Tree of Thoughts
**Description:** Agent that explores multiple reasoning paths in parallel and selects the best solution.

**Demonstrates:**
- Parallel exploration with `Send`
- Solution evaluation and ranking
- Branch pruning logic
- Complex graph patterns

**Original Reference:** [LangGraph Tree of Thoughts Tutorial](https://github.com/langchain-ai/langgraph/tree/main/docs/docs/tutorials/tot)

---

#### 8.3 Long-Running Workflow with Checkpointing
**Description:** Demonstrates continue-as-new for workflows that may run for extended periods and generate large event histories.

**Demonstrates:**
- `should_continue` callback for checkpointing
- State serialization and restoration
- Continue-as-new pattern
- Store API for cross-workflow data

**Original Reference:** N/A (Temporal-specific pattern)

---

## Implementation Priority

### Phase 1 - Core Examples (Recommended First)
1. **Basic: Hello World Agent** - Entry point for new users
2. **Basic: ReAct Agent with Tools** - Most common agent pattern
3. **Human-in-the-Loop: Approval Workflow** - Key differentiator for Temporal
4. **RAG: Agentic RAG** - Popular production use case

### Phase 2 - Multi-Agent and Research
5. **Multi-Agent: Supervisor Agent** - Popular advanced pattern
6. **RAG: Deep Research Agent** - Showcases long-running durability
7. **Customer Service: Support Agent** - Business-relevant example

### Phase 3 - Advanced Patterns
8. **Planning: Plan-and-Execute** - Structured agent execution
9. **Advanced: Reflection Agent** - Self-improvement pattern
10. **Multi-Agent: Hierarchical Teams** - Complex orchestration

---

## Directory Structure

```
langgraph/
├── README.md # Overview and getting started
├── __init__.py
├── basic/
│ ├── README.md
│ ├── hello_world/
│ │ ├── README.md
│ │ ├── run_worker.py
│ │ └── run_workflow.py
│ └── react_agent/
│ ├── README.md
│ ├── agent.py
│ ├── tools.py
│ ├── run_worker.py
│ └── run_workflow.py
├── human_in_loop/
│ ├── README.md
│ ├── approval_workflow/
│ └── document_review/
├── multi_agent/
│ ├── README.md
│ ├── supervisor/
│ └── hierarchical_teams/
├── rag/
│ ├── README.md
│ ├── agentic_rag/
│ ├── corrective_rag/
│ └── deep_research/
├── customer_service/
│ ├── README.md
│ ├── support_agent/
│ └── email_triage/
├── planning/
│ ├── README.md
│ ├── plan_and_execute/
│ └── travel_planner/
├── code/
│ ├── README.md
│ └── code_assistant/
└── advanced/
├── README.md
├── reflection/
├── tree_of_thoughts/
└── long_running_workflow/
```

---

## References

### Official LangGraph Resources
- [LangGraph Documentation](https://docs.langchain.com/oss/python/langgraph/overview)
- [LangGraph GitHub Repository](https://github.com/langchain-ai/langgraph)
- [LangGraph Tutorials](https://github.com/langchain-ai/langgraph/tree/main/docs/docs/tutorials)
- [LangChain Academy - Intro to LangGraph](https://academy.langchain.com/courses/intro-to-langgraph)

### Multi-Agent Resources
- [LangGraph Multi-Agent Concepts](https://github.com/langchain-ai/langgraph/blob/main/docs/docs/concepts/multi_agent.md)
- [LangGraph Supervisor Library](https://github.com/langchain-ai/langgraph-supervisor-py)
- [Hierarchical Agent Teams Tutorial](https://langchain-ai.github.io/langgraph/tutorials/multi_agent/hierarchical_agent_teams/)

### RAG and Research
- [Agentic RAG Documentation](https://docs.langchain.com/oss/python/langgraph/agentic-rag)
- [RAG Research Agent Template](https://github.com/langchain-ai/rag-research-agent-template)
- [Deep Research Agent Article](https://towardsdatascience.com/langgraph-101-lets-build-a-deep-research-agent/)

### Human-in-the-Loop
- [Human-in-the-Loop How-To](https://langchain-ai.github.io/langgraph/how-tos/human_in_the_loop/)
- [Human Feedback Discussion](https://github.com/langchain-ai/langgraph/discussions/1137)

### Courses and Tutorials
- [DeepLearning.AI - AI Agents in LangGraph](https://www.deeplearning.ai/short-courses/ai-agents-in-langgraph/)
- [Real Python - LangGraph Tutorial](https://realpython.com/langgraph-python/)
1 change: 1 addition & 0 deletions langgraph_samples/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# Temporal LangGraph Samples
18 changes: 18 additions & 0 deletions langgraph_samples/basic/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Basic LangGraph Examples

Simple examples to get started with LangGraph integrated with Temporal workflows.

Before running these examples, be sure to review the [prerequisites and background on the integration](../README.md).

## Examples

### Hello World Agent

Minimal LangGraph agent with Temporal integration. A single-node graph that processes a query.

**Demonstrates:**
- Basic plugin setup and graph registration
- Simple workflow invocation
- Activity-based node execution

See [hello_world/README.md](./hello_world/README.md) for details.
1 change: 1 addition & 0 deletions langgraph_samples/basic/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# Basic LangGraph Examples
Loading