Repository navigation
fix(workflow): propagate delegated child output to parent context in use_as_output - #8185
Open
utkarshpatwa393-sys wants to merge 1 commit into
Conversation
…use_as_output When a node runs a child with use_as_output=True without explicitly returning its result (e.g. await ctx.run_node(child, use_as_output=True)), the child's output was emitted to the event stream but never set on the parent's ctx.output. Consequently, downstream workflow steps and graph successors received None. This patch: - Sets ctx.output = child_ctx.output on the parent context when use_as_output=True finishes. - Permits idempotent assignment of equivalent values in Context.output.setter so that explicit returns do not raise Output already set. - Adds regression test covering downstream node input propagation in test_workflow_dynamic_nodes.py. Closes google#8183 Signed-off-by: Utkarsh patwa <utkarshpatwa393@gmail.com>
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.
Please ensure you have read the contribution guide before creating a pull request.
Link to Issue or Description of Change
1. Link to an existing issue (if applicable):
Problem:
When a workflow node executes a child node dynamically with
await ctx.run_node(child, use_as_output=True)without an explicit return statement (or returningNone), the child node's output is properly emitted to the session event stream, but was never set on the calling parent'sctx.output.As a result, subsequent workflow steps connected to that node receive
Noneasnode_input, and terminal workflow nodes fail to pass the delegated output to the workflow result.Solution:
_dynamic_node_scheduler.py, after a dynamic step completes withuse_as_output=Trueon a non-Workflow caller, setctx.output = child_ctx.outputifctx.output is None.Context.output.setter, allow idempotent assignment of equivalent values (self._output_value is valueorself._output_value == value), preventing spuriousValueError: Output already setif a node also explicitly returnsawait ctx.run_node(...).test_workflow_dynamic_nodes.pyverifying that downstream nodes receive the delegated output.Testing Plan
Unit Tests:
pytest tests/unittests/workflow/test_workflow_dynamic_nodes.pypasses cleanly (27 passed, 1 xfailed):Manual End-to-End (E2E) Tests:
Executed the minimal reproduction script from #8183:
Final Output: Packed: MISSING_ORDERFinal Output: Packed: 10 foldersChecklist