fix: preserve context during child graph init#38140
Open
mturac wants to merge 1 commit into
Open
Conversation
Contributor
Pyrefly Diffbase → PR--- /tmp/pyrefly_base.txt 2026-06-29 10:15:24.675149800 +0000
+++ /tmp/pyrefly_pr.txt 2026-06-29 10:15:13.665100222 +0000
@@ -6226,7 +6226,7 @@
ERROR Object of class `object` has no attribute `tool` [missing-attribute]
--> tests/unit_tests/core/workflow/test_node_runtime.py:654:12
ERROR Argument `TestWorkflowEntry.test_single_step_run_injects_code_limits.StubWorkflow` is not assignable to parameter `workflow` with type `Workflow` in function `core.workflow.workflow_entry.WorkflowEntry.single_step_run` [bad-argument-type]
- --> tests/unit_tests/core/workflow/test_workflow_entry.py:145:22
+ --> tests/unit_tests/core/workflow/test_workflow_entry.py:241:22
ERROR Object of class `_FakeModelNodeMixin` has no attribute `node_data` [missing-attribute]
--> tests/unit_tests/core/workflow/test_workflow_entry_helpers.py:73:35
ERROR Object of class `_FakeModelNodeMixin` has no attribute `node_data` [missing-attribute]
|
Contributor
Pyrefly Type Coverage
|
bfd4d70 to
92cf6d1
Compare
92cf6d1 to
3cec973
Compare
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.
Summary
Fixes #34511.
Child workflow engines inherit the parent
GraphRuntimeState.execution_context, but the childGraph.init(...)call creates node instances before the engine starts running. LLM node construction can load model/provider configuration during that init step, which requires the captured Flask app context.This wraps child graph initialization in the inherited execution context so node factories and subsequent child engine execution use the same context boundary.
Screenshots
Not applicable; backend workflow runtime change.
Validation
uv run --project api --dev pytest api/tests/unit_tests/core/workflow/test_workflow_entry.py::TestWorkflowEntry::test_child_engine_enters_execution_context_while_initializing_graph -quv run --project api --dev pytest api/tests/unit_tests/core/workflow/test_workflow_entry.py -quv run --project api --dev pytest api/tests/unit_tests/core/workflow/nodes/iteration/test_iteration_child_engine_errors.py -quv run --project api --dev pytest api/tests/unit_tests/core/workflow/test_workflow_entry_helpers.py::TestWorkflowChildEngineBuilder::test_build_child_engine_constructs_graph_engine_with_quota_layer_only -quv run --project api --dev pytest api/tests/unit_tests/core/workflow/test_workflow_entry.py api/tests/unit_tests/core/workflow/test_workflow_entry_helpers.py api/tests/unit_tests/core/workflow/nodes/iteration/test_iteration_child_engine_errors.py -quv run --project api --dev ruff check api/core/workflow/workflow_entry.py api/tests/unit_tests/core/workflow/test_workflow_entry.py api/tests/unit_tests/core/workflow/test_workflow_entry_helpers.pyuv run --project api --dev ruff format --check api/core/workflow/workflow_entry.py api/tests/unit_tests/core/workflow/test_workflow_entry.py api/tests/unit_tests/core/workflow/test_workflow_entry_helpers.py./dev/pyrefly-check-local api/core/workflow/workflow_entry.pygit diff --checkChecklist
make lint && make type-check(backend) andcd web && pnpm exec vp staged(frontend) to appease the lint gods