Skip to content

Conversation

@Domenic-MZS
Copy link

@Domenic-MZS Domenic-MZS commented Dec 2, 2025

fix(runtime): resolve deadlock on converging conditional paths

Fixes #5501

📝 The Deadlock Problem

The issue described by @Sohorev is a classic "deadlock" in graph-based systems, specifically in Directed Acyclic Graphs (DAGs) that incorporate conditional branching.

When there was a condition (IF/Condition Node) that split the flow into Path A and Path B, and then both paths later converged into a single Node C, the following occurred:

  • The condition chose Path A.
  • The system marked Path B to be "skipped" (ignored).
  • Node C (the converging node) was prepared and detected that it had two dependencies: one coming from A and one from B.
  • Node C waited for inputs from both.
  • The input from A arrived correctly.
  • The input from B never arrived because Node B was ignored and never executed.
  • Node C was stuck waiting eternally in waitingNodes.
  • The execution queue (nodeExecutionQueue) emptied, and the process terminated silently because no active nodes remained, but Node C was never executed.
    ...

To avoid this, the processNodeOutputs function was modified, so that when the system determines which nodes should be ignored (ignoreNodeIds), it also "notifies" the nodes depending on them (the descendant nodes) that the specific input would not arrive, so that they would stop waiting for it.

This was achieved by simulating a null value to propagate within the ignored nodes to its dependents. This satisfied the dependency and allows the convergence node to execute using only the data from the active branch. (Ignore null value is already implemented so this works like a charm).

TL;DR

Previously, when conditional branches merged into a single node, execution would silently halt. The merging node would wait indefinitely for input from the "skipped" branch.
image
image

This fix propagates the ignored status to downstream dependencies by injecting null inputs. This satisfies the waiting condition (hasReceivedRequiredInputs) and allows the flow to proceed using data from the active branch only.
image

Previously, when conditional branches merged into a single node, execution would silently halt. The merging node would wait indefinitely for input from the "skipped" branch.

This fix propagates the ignored status to downstream dependencies by injecting `null` inputs. This satisfies the waiting condition (`hasReceivedRequiredInputs`) and allows the flow to proceed using data from the active branch only.
@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @Domenic-MZS, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request resolves a critical deadlock issue in the runtime execution of graph-based systems, particularly in Directed Acyclic Graphs (DAGs) that utilize conditional branching. Previously, when a conditional path was skipped, any downstream node that converged from both the active and skipped paths would become stuck, waiting indefinitely for an input that would never arrive. The implemented solution modifies the processNodeOutputs function to actively notify dependent nodes of skipped paths by propagating null values, thereby allowing converging nodes to correctly satisfy their input requirements and continue execution using only the valid data from active branches.

Highlights

  • Deadlock Resolution: Addresses a critical deadlock scenario in Directed Acyclic Graphs (DAGs) with conditional branching, where converging nodes would previously wait indefinitely for inputs from skipped paths.
  • Skipped Path Propagation: Introduces a mechanism to actively propagate the 'skipped' status of an ignored node to its downstream dependencies by simulating a null value input.
  • Dependency Satisfaction: Ensures that converging nodes correctly receive a null input from skipped branches, thereby satisfying their dependencies and allowing execution to proceed using only valid data from active branches.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request effectively resolves a deadlock issue in conditional graph paths by propagating a null signal down the skipped branches. The implementation is clear and directly addresses the problem described. I have one suggestion to improve the efficiency of finding downstream nodes, but overall this is a great fix.

This refactoring improves efficiency by using the graph object for a direct lookup of downstream nodes, instead of filtering the entire edges array in each loop iteration. This avoids an O(E) operation (where E is the number of edges) inside the loop, making the code cleaner and more performant, especially for larger graphs.

Co-authored-by: @gemini-code-assist
@Domenic-MZS
Copy link
Author

Does not work when:

A: If block
B: Human in the loop
C: Text Node

A-------B----|
|-------------C

Where
A->B
B->C
A->C

After resuming the execution from B, C is not executed...

@HenryHengZJ
Copy link
Contributor

ah I see the reason now, thanks for pointing out the Human In the Loop part as well

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Flow execution stops at Condition node when multiple branches converge into single LLM node

2 participants