samples-python
samples-python copied to clipboard
[Feature Request] Example with LangGraph
Is your feature request related to a problem? Please describe.
How can we use temporal with LangGraph workflows - https://github.com/langchain-ai/langgraph? Could you give a example?
Describe the solution you'd like
LangGraph is typically used in agentic workflows and using temporal would give us the ability to scale execution.
Additional context
None
Temporal does not really care what technology you use inside the activities, but the scaling/distribution of workflows/activities is controlled by Temporal server. https://github.com/temporalio/samples-python/tree/main/langchain sample shows using LangChain in activities and you can do the same for invoking a LangGraph workflow inside an activity. But despite using the same term "workflow", Temporal workflows and LangGraph workflows are unrelated.
Yes, I understand that, but an example would be helpful.
Can you use the LangChain sample, but call LangGraph instead of a LangChain in the activity? (same for any third party library, not specific to LangChain/LangGraph)
Yes, but i am looking for how we can make LangGraph nodes/edges become workflows/activities to make it easier to understand... It would help folks building AI agents use temporal for scaling.
I don't think LangGraph nodes/edges become workflows/activities. I think you interact with the LangGraph library via an activity like interacting with any other library occurs via activity. LangGraph primitives don't integrate in a special way with Temporal ones from what I can see at a quick glance. If there are specific suggestions to how integration could/should occur, that may help.
@cretz I feel like LangGraph users are not necessarily aware of the notion of "durable workflows" yet would be interested by it when they hit scaling issues. LangGraph or even LangChain can help with running computations in parallel or sequence at a certain scale but at some point you might indeed want to convert the nodes and edges to activities to operate workflows at a bigger scale. Temporal feels like a natural solution at this step.
I admit I am not that familiar with LangGraph and how uniquely it can integrate with Temporal vs any other external utility. We will leave this open and our AI efforts may get around to making this sample or it is open for contribution (though design may be worth discussing first).
I built a poc of Temporal + LangGraph, seems technically possible, but too forced and awkward. LangGraph's step execution lacks visibility at the Temporal activity level, which makes observability harder. https://github.com/domainio/temporal-langgraph-poc
Nice, thanks for sharing! Can post in #show-us-what-you-got in Slack if you'd like.
@domainio tysm for sharing this. Given the trade-offs, do you have any recommended alternative paths? I could imagine some dynamic generation of Temporal Activities from the LangGraph output but that seems again like a complexity trap.
Is it an advantageous trade-off to use LangChain directly (not LangGraph) from Temporal, perhaps?
@domainio - I'm trying to do something similar. The concept of "durable execution" mentioned in langgraph isn't really true durability. They need to change the marketing on that.
I believe a more natural solution is to build langgraph type of primitives specific to agent orchestraion natively in temporal.. perhaps a higher level SDK around temporal
Here's an example of how it's done using open AI Agents SDK + Temporal. https://temporal.io/blog/announcing-openai-agents-sdk-integration
The concept of "durable execution" mentioned in langgraph isn't really true durability. They need to change the marketing on that.
@v-y-a-s could you please expand on this? Which durability capabilities are missing? I only began exploring langgraph durability, and on the surface the checkpointing/replay capabilities look good.