samples-python icon indicating copy to clipboard operation
samples-python copied to clipboard

[Feature Request] Example with LangGraph

Open nitin302 opened this issue 1 year ago • 5 comments

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

nitin302 avatar Oct 10 '24 13:10 nitin302

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.

cretz avatar Oct 10 '24 14:10 cretz

Yes, I understand that, but an example would be helpful.

nitin302 avatar Oct 10 '24 14:10 nitin302

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)

cretz avatar Oct 10 '24 15:10 cretz

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.

nitin302 avatar Oct 10 '24 17:10 nitin302

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 avatar Oct 10 '24 18:10 cretz

@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.

eric-burel avatar Apr 02 '25 14:04 eric-burel

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).

cretz avatar Apr 02 '25 16:04 cretz

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

domainio avatar May 31 '25 20:05 domainio

Nice, thanks for sharing! Can post in #show-us-what-you-got in Slack if you'd like.

cretz avatar Jun 02 '25 13:06 cretz

@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?

ms-ati avatar Jul 12 '25 16:07 ms-ati

@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

vyasraos avatar Aug 13 '25 07:08 vyasraos

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.

gukoff avatar Sep 05 '25 12:09 gukoff