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

Merged
merged 1 commit into from
Jan 13, 2025

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
@Kevin9703 Kevin9703 force-pushed the fix-workflow-if-else branch from d654631 to c50f434 Compare January 12, 2025 16:31
@dosubot dosubot bot added the lgtm This PR has been approved by a maintainer label Jan 13, 2025
@crazywoola crazywoola merged commit 54b5b80 into langgenius:main Jan 13, 2025
6 checks passed
Scorpion1221 added a commit to yybht155/dify that referenced this pull request Jan 14, 2025
* commit '6e0fb055d18969eb923e719ad92ecac3a5c5d534': (42 commits)
  chore: bump version to 0.15.1 (langgenius#12690)
  feat: add table of contents to Knowledge API doc (langgenius#12688)
  [fix] support feature restore (langgenius#12563)
  api tool support multiple env url (langgenius#12249)
  Add new integration with Opik Tracking tool (langgenius#11501)
  fix: add type hints for App model and improve error handling in audio services (langgenius#12677)
  fix: Update variable handling in VariableAssignerNode and clean up app_dsl_service (langgenius#12672)
  Revert "Feat/new saas billing" (langgenius#12673)
  fix(workflow): fix answer node stream processing in conditional branches (langgenius#12510)
  fix: ruff with statements (langgenius#12578)
  fix: ruff check for True if ... else (langgenius#12576)
  chore: Adjust translations to align with Taiwanese Mandarin conventions (langgenius#12633)
  Fix pandas indexing method for knowledge base imports (langgenius#12637) (langgenius#12638)
  Feat/new saas billing (langgenius#12591)
  improve the readability of the function generate_api_key (langgenius#12552)
  chore: translate i18n files (langgenius#12543)
  Feat/add knowledge include all filter (langgenius#12537)
  fix: Add datasets list access control and fix datasets config display issue (langgenius#12533)
  fix: sum costs return error value on overview page (langgenius#12534)
  feat: show workflow running status (langgenius#12531)
  ...

# Conflicts:
#	api/poetry.lock
@Kevin9703 Kevin9703 deleted the fix-workflow-if-else branch January 14, 2025 16:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐞 bug Something isn't working lgtm This PR has been approved by a maintainer size:S This PR changes 10-29 lines, ignoring generated files.
Projects
None yet
4 participants