Skip to content

Conversation

@laipz8200
Copy link
Member

@laipz8200 laipz8200 commented Jan 4, 2026

Important

  1. Make sure you have read our contribution guidelines
  2. Ensure there is an associated issue and you have been assigned to it
  3. Use the correct syntax to link this PR: Fixes #<issue number>.

Summary

Screenshots

Before After
... ...

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 dev/reformat(backend) and cd web && npx lint-staged(frontend) to appease the lint gods

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @laipz8200, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request refactors the VariableAssignerNode (v2) to leverage dependency injection for its ConversationVariableUpdater factory dependency. The primary goal is to enhance the modularity and testability of the VariableAssignerNode by allowing its dependencies to be provided at construction time, rather than being hardcoded. This change is carefully implemented to maintain backward compatibility and focuses solely on the specified dependency injection without introducing broader architectural shifts or altering existing VariablePool APIs.

Highlights

  • Dependency Identification: Identified the ConversationVariableUpdater factory as a key non-VariablePool dependency for VariableAssigner v2.
  • Constructor Injection: Implemented constructor-based dependency injection for VariableAssignerNode v2, ensuring backward compatibility with default values.
  • Factory Wiring: Modified the DifyNodeFactory to correctly inject the ConversationVariableUpdater factory when creating instances of VariableAssignerNode v2.
  • Test Coverage: Added a new unit test to verify the correct injection of the ConversationVariableUpdater factory by the node factory.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@laipz8200 laipz8200 changed the title Node DI: VariableAssigner v2 (vibe-kanban) Inject ConversationVariableUpdater into VariableAssigner v2 (refactor) Jan 4, 2026
@laipz8200 laipz8200 changed the title Inject ConversationVariableUpdater into VariableAssigner v2 (refactor) refactor(variable_assigner_v2): Inject ConversationVariableUpdater into VariableAssigner v2 Jan 4, 2026
Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request refactors the VariableAssignerNode and DifyNodeFactory to support dependency injection for the ConversationVariableUpdater. Specifically, DifyNodeFactory's constructor now accepts an optional conv_var_updater_factory callable, which is then passed to the VariableAssignerNode's constructor when an instance of that node type is created. The VariableAssignerNode itself has been updated with a new __init__ method to receive and store this factory. A corresponding unit test has been added to verify that the DifyNodeFactory correctly injects the conv_var_updater_factory into the VariableAssignerNode.

@laipz8200 laipz8200 marked this pull request as ready for review January 4, 2026 12:34
@dosubot dosubot bot added size:M This PR changes 30-99 lines, ignoring generated files. 🌊 feat:workflow Workflow related stuff. labels Jan 4, 2026
@laipz8200 laipz8200 force-pushed the 54a0-node-di-variable branch from c967b20 to a3a1858 Compare January 4, 2026 16:39
@laipz8200 laipz8200 marked this pull request as draft January 4, 2026 17:06
@laipz8200 laipz8200 changed the title refactor(variable_assigner_v2): Inject ConversationVariableUpdater into VariableAssigner v2 Add conversation variable persistence layer (feat) Jan 5, 2026
@laipz8200 laipz8200 changed the title Add conversation variable persistence layer (feat) feat: Add conversation variable persistence layer Jan 5, 2026
… factory to pass the ConversationVariableUpdater factory (the only non-VariablePool dependency), plus a unit test to verify the injection path.

- `api/core/workflow/nodes/variable_assigner/v2/node.py` adds a kw-only `conv_var_updater_factory` dependency (defaulting to `conversation_variable_updater_factory`) and stores it for use in `_run`.
- `api/core/workflow/nodes/node_factory.py` now injects the factory when creating VariableAssigner v2 nodes.
- `api/tests/unit_tests/core/workflow/nodes/variable_assigner/v2/test_variable_assigner_v2.py` adds a test asserting the factory is injected.

Tests not run.

Next steps (optional):
1) `make lint`
2) `make type-check`
3) `uv run --project api --dev dev/pytest/pytest_unit_tests.sh`
…ructor args.

- `api/core/workflow/nodes/node_factory.py` now directly instantiates `VariableAssignerNode` with the injected dependency, and uses a direct call for all other nodes.

No tests run.
Add a new command for GraphEngine to update a group of variables. This command takes a group of variable selectors and new values. When the engine receives the command, it will update the corresponding variable in the variable pool. If it does not exist, it will add it; if it does, it will overwrite it. Both behaviors should be treated the same and do not need to be distinguished.
…be-kanban 0941477f)

Create a new persistence layer for the Graph Engine. This layer receives a ConversationVariableUpdater upon initialization, which is used to persist the received ConversationVariables to the database. It can retrieve the currently processing ConversationId from the engine's variable pool. It captures the successful execution event of each node and determines whether the type of this node is VariableAssigner(v1 and v2). If so, it retrieves the variable name and value that need to be updated from the node's outputs. This layer is only used in the Advanced Chat. It should be placed outside of Core.Workflow package.
…rs/conversation_variable_persist_layer.py` to satisfy SIM118

- chore(lint): run `make lint` (passes; warnings about missing RECORD during venv package uninstall)
- chore(type-check): run `make type-check` (fails: 1275 errors for missing type stubs like `opentelemetry`, `click`, `sqlalchemy`, `flask`, `pydantic`, `pydantic_settings`)
…tType validation and casting

- test(graph-engine): update VariableUpdate usages to include value_type in command tests
… drop common_helpers usage

- refactor(variable-assigner-v2): inline updated variable payload and drop common_helpers usage

Tests not run.
…n and remove value type validation

- test(graph-engine): update UpdateVariablesCommand tests to pass concrete Variable instances
- fix(graph-engine): align VariableUpdate values with selector before adding to VariablePool

Tests not run.
@laipz8200 laipz8200 force-pushed the 54a0-node-di-variable branch from 930b896 to 5ebc87a Compare January 5, 2026 05:25
…e handling for v1/v2 process_data

- refactor(app-layer): read updated variables from process_data in conversation variable persistence layer
- test(app-layer): adapt persistence layer tests to use common_helpers updated-variable payloads

Tests not run.
@laipz8200 laipz8200 force-pushed the 54a0-node-di-variable branch from 0327749 to 8505033 Compare January 5, 2026 06:00
…fter venv changes)

- chore(type-check): run `make type-check` (fails: 1275 missing type stubs across dependencies)

Details:
- `make lint` fails with `ModuleNotFoundError: No module named 'dotenv_linter.cli'`.
- `make type-check` fails with missing stubs for `opentelemetry`, `click`, `sqlalchemy`, `flask`, `pydantic`, `pydantic_settings`, etc.
@laipz8200 laipz8200 force-pushed the 54a0-node-di-variable branch from 07c105b to 36b4a6e Compare January 5, 2026 06:03
…ableUnion and remove value type validation"

This reverts commit 5ebc87a.
…h SegmentType validation and casting"

This reverts commit 3edd525.
…y out of core.workflow into `api/services/conversation_variable_updater.py`

- refactor(app): update advanced chat app runner and conversation service to import the new updater factory

Tests not run.
…-linter module missing)

- chore(type-check): run `make type-check` (fails: 1275 missing type stubs)

Details:
- `make lint` reports: `No matches for ignored import core.workflow.nodes.variable_assigner.common.impl -> extensions.ext_database` and ends with `ModuleNotFoundError: No module named 'dotenv_linter.cli'`.
- `make type-check` fails with missing type stubs for `opentelemetry`, `click`, `sqlalchemy`, `flask`, `pydantic`, `pydantic_settings`, etc.
@laipz8200 laipz8200 marked this pull request as ready for review January 5, 2026 07:15
@dosubot dosubot bot added size:L This PR changes 100-499 lines, ignoring generated files. 💪 enhancement New feature or request and removed size:M This PR changes 30-99 lines, ignoring generated files. labels Jan 5, 2026
QuantumGhost
QuantumGhost previously approved these changes Jan 6, 2026
@dosubot dosubot bot added the lgtm This PR has been approved by a maintainer label Jan 6, 2026
@QuantumGhost QuantumGhost merged commit d6e9c33 into main Jan 6, 2026
24 of 28 checks passed
@QuantumGhost QuantumGhost deleted the 54a0-node-di-variable branch January 6, 2026 06:05
@dosubot dosubot bot mentioned this pull request Jan 21, 2026
6 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

💪 enhancement New feature or request 🌊 feat:workflow Workflow related stuff. lgtm This PR has been approved by a maintainer size:L This PR changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Refactor/Chore] Add graph-layer conversation variable persistence handling

3 participants