dify - ✅(Solved) Fix [Refactor/Chore] Gradually remove GraphInitParams from the workflow layer [1 pull requests, 1 comments, 2 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
langgenius/dify#34822Fetched 2026-04-11 06:08:12
View on GitHub
Comments
1
Participants
2
Timeline
5
Reactions
1
Author
Participants
Assignees
Timeline (top)
assigned ×1commented ×1cross-referenced ×1mentioned ×1

GraphInitParams is currently acting as a pass-through container in the workflow stack. It carries a small set of values (workflow_id, graph_config, run_context, and call_depth), but Dify mostly constructs it at workflow entry points and then immediately fans those values back out through the node factory and node base classes.

This refactor should gradually remove direct reliance on GraphInitParams from the Dify workflow layer, then align the upstream graphon API, and finally delete the compatibility path once the new API is stable.

Proposed phased plan:

  1. Phase 1: Dify-side reduction

    • Introduce a Dify-owned explicit graph init context.
    • Route Dify workflow entry points through that explicit context instead of constructing GraphInitParams directly at every production call site.
    • Remove direct read-back usages where code reaches into graph_init_params just to obtain values already exposed elsewhere.
    • Keep the current graphon API unchanged during this phase so the migration remains reviewable and safe.
  2. Phase 2: graphon compatibility release

    • Update graphon node and child-engine APIs to accept explicit init values instead of a GraphInitParams object.
    • Keep a temporary adapter path for compatibility while downstream callers migrate.
    • Move nested workflow, loop, and iteration child-engine creation onto the new explicit API.
  3. Phase 3: cleanup

    • Upgrade Dify to the new graphon API.
    • Remove the Dify compatibility bridge and remaining production references.
    • Delete obsolete helper paths and complete the final cleanup in tests.

This should be executed as a sequence of small, reviewable changes rather than a single graph-engine rewrite.

Root Cause

It should also make future graph initialization and child-graph APIs easier to reason about, because callers will pass explicit values instead of relying on an object whose contents are immediately unpacked again.

Fix Action

Fixed

PR fix notes

PR #34825: refactor(api): reduce Dify GraphInitParams usage

Description (problem / solution / changelog)

Summary

Part of #34822.

This starts Phase 1 of the GraphInitParams removal plan on the Dify side while keeping the current graphon API intact.

  • add a Dify-owned explicit graph init context bridge in the workflow node factory
  • route workflow, pipeline, and single-node entry paths through the explicit context
  • remove the remaining direct run_context read-backs in the touched workflow paths

Screenshots

BeforeAfter
N/A (backend-only refactor)N/A (backend-only refactor)

Checklist

  • 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 make lint and make type-check (backend) and cd web && pnpm exec vp staged (frontend) to appease the lint gods

Changed files

  • api/core/app/apps/pipeline/pipeline_runner.py (modified, +13/-13)
  • api/core/app/apps/workflow_app_runner.py (modified, +30/-24)
  • api/core/workflow/node_factory.py (modified, +39/-0)
  • api/core/workflow/nodes/trigger_webhook/node.py (modified, +1/-1)
  • api/core/workflow/workflow_entry.py (modified, +30/-23)
  • api/services/workflow_service.py (modified, +18/-11)
  • api/tests/unit_tests/core/workflow/test_node_factory.py (modified, +45/-0)
  • api/tests/unit_tests/core/workflow/test_workflow_entry_helpers.py (modified, +23/-15)
  • api/tests/unit_tests/services/test_workflow_service.py (modified, +16/-3)
RAW_BUFFERClick to expand / collapse

Self Checks

  • I have read the Contributing Guide and Language Policy.
  • This is only for refactors or chores; if you would like to ask a question, please head to Discussions.
  • I have searched for existing issues search for existing issues, including closed ones.
  • I confirm that I am using English to submit this report, otherwise it will be closed.
  • 【中文用户 & Non English User】请使用英语提交,否则会被关闭 :)
  • Please do not modify this template :) and fill in all the required fields.

Description

GraphInitParams is currently acting as a pass-through container in the workflow stack. It carries a small set of values (workflow_id, graph_config, run_context, and call_depth), but Dify mostly constructs it at workflow entry points and then immediately fans those values back out through the node factory and node base classes.

This refactor should gradually remove direct reliance on GraphInitParams from the Dify workflow layer, then align the upstream graphon API, and finally delete the compatibility path once the new API is stable.

Proposed phased plan:

  1. Phase 1: Dify-side reduction

    • Introduce a Dify-owned explicit graph init context.
    • Route Dify workflow entry points through that explicit context instead of constructing GraphInitParams directly at every production call site.
    • Remove direct read-back usages where code reaches into graph_init_params just to obtain values already exposed elsewhere.
    • Keep the current graphon API unchanged during this phase so the migration remains reviewable and safe.
  2. Phase 2: graphon compatibility release

    • Update graphon node and child-engine APIs to accept explicit init values instead of a GraphInitParams object.
    • Keep a temporary adapter path for compatibility while downstream callers migrate.
    • Move nested workflow, loop, and iteration child-engine creation onto the new explicit API.
  3. Phase 3: cleanup

    • Upgrade Dify to the new graphon API.
    • Remove the Dify compatibility bridge and remaining production references.
    • Delete obsolete helper paths and complete the final cleanup in tests.

This should be executed as a sequence of small, reviewable changes rather than a single graph-engine rewrite.

Motivation

Removing GraphInitParams will make ownership boundaries clearer and reduce the amount of bag-style context threading in the workflow stack.

It should also make future graph initialization and child-graph APIs easier to reason about, because callers will pass explicit values instead of relying on an object whose contents are immediately unpacked again.

Additional Context

Current direction for the migration:

  • Keep behavior stable while reducing Dify-side coupling first.
  • Avoid broad graph execution refactors until the explicit init path is established.
  • Treat the graphon API change as a separate follow-up step so Dify and graphon can migrate in a controlled order.

extent analysis

TL;DR

Refactor the Dify workflow layer to remove direct reliance on GraphInitParams by introducing an explicit graph init context and updating the graphon API to accept explicit init values.

Guidance

  • Introduce a Dify-owned explicit graph init context to replace GraphInitParams as a pass-through container.
  • Route Dify workflow entry points through the explicit context instead of constructing GraphInitParams directly.
  • Update the graphon node and child-engine APIs to accept explicit init values instead of a GraphInitParams object, while keeping a temporary adapter path for compatibility.
  • Execute the refactor as a sequence of small, reviewable changes, following the proposed phased plan.

Example

No code snippet is provided as the issue does not contain specific code examples.

Notes

The refactor should be executed in a controlled order, with Dify and graphon migrating separately to ensure a stable behavior.

Recommendation

Apply the proposed phased plan to refactor the Dify workflow layer and update the graphon API, as it provides a clear and controlled approach to removing the direct reliance on GraphInitParams.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

dify - ✅(Solved) Fix [Refactor/Chore] Gradually remove GraphInitParams from the workflow layer [1 pull requests, 1 comments, 2 participants]