-
Hi ! The "issue" is if one parallel branch has more than one steps, 2 executions supersteps will be created (which is normal): But if you want to overcome this you need to add steps "b" and "b2" into a child subgraph: I understand the behavior of the first example, but is there a way to set "d" to wait for the 2 "supersteps" ? Or we need to play around with subgraph for that ? Thanks for your help :) ### Code: class State(TypedDict): from typing import Any class ReturnNodeValue:
builder = StateGraph(State) from IPython.display import Image, display display(Image(graph.get_graph().draw_mermaid_png())) graph.invoke({"aggregate": []}) child_builder = StateGraph(State) builder = StateGraph(State) display(Image(graph.get_graph().draw_mermaid_png()) graph.invoke({"aggregate": []}))` |
Beta Was this translation helpful? Give feedback.
Replies: 4 comments 5 replies
-
Thanks for starting this discussion ,and for the detailed example! This is something @nfcampos and I have debated a bit - will follow up with you on the best recommendations. If I understand correctly, the desired behavior would be something like a "barrier (or in python threading)" rather than the current supersteps. E.g., you'd want fan-out, and then for the fan-in node you'd like for it to wait until all branches converge on that node (or something similar) |
Beta Was this translation helpful? Give feedback.
-
hi @Freezaa9 I think you can achieve what you want with builder = StateGraph(State)
builder.add_node("a", ReturnNodeValue("I'm A"))
builder.set_entry_point("a")
builder.add_node("b", ReturnNodeValue("I'm B"))
builder.add_node("b2", ReturnNodeValue("I'm B2"))
builder.add_node("c", ReturnNodeValue("I'm C"))
builder.add_node("d", ReturnNodeValue("I'm D"))
builder.add_edge("a", "b")
builder.add_edge("a", "c")
builder.add_edge("b", "b2")
builder.add_edge(["b2", "c"], "d")
builder.set_finish_point("d")
graph = builder.compile() |
Beta Was this translation helpful? Give feedback.
-
@Freezaa9 Thanks for asking this issue. I'm facing the same issue and got a lot of help from this thread. @nfcampos 's solution is succinct and worked for my case as well. |
Beta Was this translation helpful? Give feedback.
-
You welcome @minki-j ! May be @jasontjahjono @gambastyle you're looking for the "Stable Sorting" part of the above documentation / notebook ? |
Beta Was this translation helpful? Give feedback.
hi @Freezaa9 I think you can achieve what you want with