Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(workflow): fix answer node stream processing in conditional branches #12510

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

Kevin9703
Copy link
Contributor

@Kevin9703 Kevin9703 commented Jan 8, 2025

Summary

Previously, the _fetch_node_ids_in_reachable_branch method would collect all downstream
answer nodes regardless of branch conditions, causing incorrect stream processing.
This change ensures that only nodes in the current conditional branch are collected
by tracking and matching branch identifiers.

  • Add branch_identify parameter to track current branch context
  • Add condition check to only follow edges matching current branch
  • Skip edges with mismatched branch identifiers

Tip

Close issue syntax: Fixes #<issue number> or Resolves #<issue number>, see documentation for more details.

Fixes #11542
image

Fixes #9560
image

Fixes #10638
image

Fixes #10564
image

Also fixes #11985 (streaming output)

Screenshots

Before After
image image

Checklist

Important

Please review the checklist below before submitting your pull request.

  • This change requires a documentation update, included: Dify Document
  • I understand that this PR may be closed in case there was no previous discussion or issues. (This doesn't apply to typos!)
  • I've added a test for each change that was introduced, and I tried as much as possible to make a single atomic change.
  • I've updated the documentation accordingly.
  • I ran dev/reformat(backend) and cd web && npx lint-staged(frontend) to appease the lint gods

@dosubot dosubot bot added size:S This PR changes 10-29 lines, ignoring generated files. 🐞 bug Something isn't working size:L This PR changes 100-499 lines, ignoring generated files. and removed size:S This PR changes 10-29 lines, ignoring generated files. size:L This PR changes 100-499 lines, ignoring generated files. labels Jan 8, 2025
@Kevin9703 Kevin9703 force-pushed the fix-workflow-if-else branch 2 times, most recently from 882bcbc to e74d523 Compare January 8, 2025 15:00
@crazywoola
Copy link
Member

Please open an issue or link an existing issue first.

@Kevin9703 Kevin9703 force-pushed the fix-workflow-if-else branch from 6dfc1cc to 070b232 Compare January 9, 2025 02:20
@Kevin9703
Copy link
Contributor Author

Please open an issue or link an existing issue first.

Issue linked

@yihong0618
Copy link
Contributor

Nice job, but these kind of workflow has many special case, you can follow the issue link to test them if this patch work well

@Kevin9703
Copy link
Contributor Author

Nice job, but these kind of workflow has many special case, you can follow the issue link to test them if this patch work well

Many thanks, will test all related issues

@crazywoola crazywoola requested a review from laipz8200 January 9, 2025 02:47
# FIXME: because of the code branch can combine directly, so for answer node
# we remove the node maybe shortcut the answer node, so comment this code for now
# there is not effect on the answer node and the workflow, when we have a better solution
# we can open this code. Issues: #11542 #9560 #10638 #10564
Copy link
Member

Choose a reason for hiding this comment

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

Can you keep those comments about related issues, and maybe add more to explain your changes? It will be helpful to others.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Can you keep those comments about related issues, and maybe add more to explain your changes? It will be helpful to others.

Sure, I'll commit them again.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐞 bug Something isn't working size:S This PR changes 10-29 lines, ignoring generated files.
Projects
None yet
4 participants