Repository navigation
fix(iteration): pass host variable writes to the parent frame - #353
Merged
Merged
Conversation
An Iteration round worked on a deep copy of its parent's variable pool and never wrote updates back, so a conversation variable assigned inside an Iteration reverted once the round finished, and nodes after the Iteration read the stale value. Pass a round's write to its parent frame when the variable's namespace is not the ID of any workflow node, such as conversation, environment, system, or any other host namespace. The same identity check as the Loop handler carries the write through nested containers to the root. Node-owned variables written in a round stay private. Closes #350 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A downstream container may run a separate workflow graph in its own frame, so the root graph config does not list that graph's nodes. An Iteration inside such a graph treated the graph's node variables as host variables and passed their writes out of the round. Collect node IDs from the graph configs of every registered frame. Enclosing frames stay registered while their child frames run, so the graphs that own a round's outer values are always included. Refs #350 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
laipz8200
enabled auto-merge (squash)
October 23, 2026 04:57
WH-2099
approved these changes
Oct 27, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Important
!Related Issue
Closes #350
Summary
An Iteration round worked on a deep copy of its parent's variable pool and never wrote variable updates back. A conversation variable assigned inside an Iteration therefore reverted when the round finished, and nodes after the Iteration read the stale value (reported downstream in langgenius/dify#43312).
IterationContainerHandler.prepare_frame_eventnow passes a round'sNodeRunVariableUpdatedEventto the round's parent frame when the variable's namespace is not the ID of any node and the parent already holds the variable. No namespace is hard-coded:conversation,env,sys, or any other namespace a host adds behave the same. Node-owned variables (node outputs, Loop variables, Iterationitem/index) written in a round stay private, as before.Behavior notes:
appendcan lose updates. The handler docstring records this; shared-write semantics are still open in Clarify the semantics for variable assignment #24.env.*andsys.*inside an Iteration now reach the parent too, under the same rule.prepare_frame_event, so a Graphon upgrade is enough for the downstream report.Docs: corrected the
ContainerHandler.prepare_frame_eventdocstring (an outer frame holds an update only if inner containers passed it on), a Loop handler comment, and two ARCHITECTURE.md evidence links.Tests:
tests/workflows/test_full_engine_events.py:append, forconversationand an arbitrary host namespace.tests/engine/test_dispatch_patterns.py: an Iteration inside a Loop of a workflow that a custom container runs in its own frame keeps writes to that workflow's node variables private, while a conversation write passes up through the Loop round.Validation:
just test(1001 passed) andjust checkpass locally.Checklist
!🤖 Generated with Claude Code