Skip to content

fix(workflow): unblock plugin model selector tools on 1.14.0#35794

Merged
fatelei merged 2 commits into
langgenius:mainfrom
sawyer-shi:big-bug-fix-model-select-error-in-plugin
May 6, 2026
Merged

fix(workflow): unblock plugin model selector tools on 1.14.0#35794
fatelei merged 2 commits into
langgenius:mainfrom
sawyer-shi:big-bug-fix-model-select-error-in-plugin

Conversation

@sawyer-shi
Copy link
Copy Markdown
Contributor

@sawyer-shi sawyer-shi commented May 5, 2026

This fixes a severe 1.14 regression where plugin tools using model-selector params failed before invocation with 'The selector must be a dictionary', blocking LLM/TTS model selection in plugin workflows.

This blocks plugin tools that rely on Dify platform model selection from running at all.
This PR fixes the model selector parameter flow by:
• Preserving model/app selector dictionaries instead of flattening them as primitive tool configuration values.
• Moving legacy selector-shaped tool configurations into tool_parameters, where structured constant values are supported by graph validation.
• Merging tool_parameters into the workflow tool runtime spec so plugin runtime invocation still receives the selected model config.
• Adding regression tests for LLM and TTS model selector payloads.

Summary

resolves #35816

Fixes a severe regression introduced in 1.14 where plugin workflow tools using model-selector parameters fail before the plugin is invoked.

When a plugin tool defines a Dify model selector parameter, such as an LLM or TTS model field, workflow execution can fail with:

Failed to invoke tool: The selector must be a dictionary.

Screenshots

image

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

This fixes a severe 1.14 regression where plugin tools using model-selector params failed before invocation with 'The selector must be a dictionary', blocking LLM/TTS model selection in plugin workflows.
@dosubot dosubot Bot added size:M This PR changes 30-99 lines, ignoring generated files. 🌊 feat:workflow Workflow related stuff. 🔨 feat:tools Tools for agent, function call related stuff. labels May 5, 2026
@sawyer-shi sawyer-shi changed the title fix(workflow): unblock plugin model selector tools fix(workflow): unblock plugin model selector tools on 1.14.0 May 6, 2026
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 6, 2026

Pyrefly Diff

base → PR
--- /tmp/pyrefly_base.txt	2026-05-06 03:10:30.965640898 +0000
+++ /tmp/pyrefly_pr.txt	2026-05-06 03:10:17.273530065 +0000
@@ -1,7 +1,7 @@
 ERROR Object of class `Server` has no attribute `app` [missing-attribute]
    --> app_factory.py:132:5
 ERROR Object of class `App` has no attribute `access_mode` [missing-attribute]
-   --> controllers/console/app/app.py:573:13
+   --> controllers/console/app/app.py:553:13
 ERROR Argument `str | None` is not assignable to parameter `language` with type `str` in function `services.account_service.AccountService.send_email_register_email` [bad-argument-type]
   --> controllers/console/auth/email_register.py:75:108
 ERROR Object of class `MissingRouter` has no attribute `get` [missing-attribute]
@@ -764,8 +764,6 @@
    --> tests/test_containers_integration_tests/core/workflow/test_human_input_resume_node_execution.py:270:29
 ERROR Argument `Literal['owner']` is not assignable to parameter `role` with type `SQLCoreOperations[TenantAccountRole] | TenantAccountRole` in function `models.account.TenantAccountJoin.__init__` [bad-argument-type]
   --> tests/test_containers_integration_tests/helpers/execution_extra_content.py:48:14
-ERROR Returned type `int | str` is not assignable to declared return type `str` [bad-return]
-   --> tests/test_containers_integration_tests/libs/broadcast_channel/redis/test_sharded_channel.py:363:16
 ERROR Object of class `TypeEngine` has no attribute `length` [missing-attribute]
    --> tests/test_containers_integration_tests/models/test_types_enum_text.py:104:16
 ERROR Object of class `NoneType` has no attribute `user_type` [missing-attribute]
@@ -1807,29 +1805,27 @@
 ERROR Object of class `int` has no attribute `lower` [missing-attribute]
    --> tests/unit_tests/controllers/console/app/test_annotation_security.py:256:35
 ERROR Object of class `ModuleType` has no attribute `console_ns` [missing-attribute]
-  --> tests/unit_tests/controllers/console/app/test_app_response_models.py:72:5
+  --> tests/unit_tests/controllers/console/app/test_app_response_models.py:70:5
 ERROR Object of class `ModuleType` has no attribute `api` [missing-attribute]
-  --> tests/unit_tests/controllers/console/app/test_app_response_models.py:73:5
+  --> tests/unit_tests/controllers/console/app/test_app_response_models.py:71:5
 ERROR Object of class `ModuleType` has no attribute `bp` [missing-attribute]
-  --> tests/unit_tests/controllers/console/app/test_app_response_models.py:74:5
+  --> tests/unit_tests/controllers/console/app/test_app_response_models.py:72:5
 ERROR Object of class `ModuleType` has no attribute `app` [missing-attribute]
-  --> tests/unit_tests/controllers/console/app/test_app_response_models.py:80:5
+  --> tests/unit_tests/controllers/console/app/test_app_response_models.py:78:5
 ERROR Argument `ModuleSpec | None` is not assignable to parameter `spec` with type `ModuleSpec` in function `_frozen_importlib.module_from_spec` [bad-argument-type]
-   --> tests/unit_tests/controllers/console/app/test_app_response_models.py:109:36
+   --> tests/unit_tests/controllers/console/app/test_app_response_models.py:107:36
 ERROR Object of class `NoneType` has no attribute `loader` [missing-attribute]
-   --> tests/unit_tests/controllers/console/app/test_app_response_models.py:112:12
+   --> tests/unit_tests/controllers/console/app/test_app_response_models.py:110:12
 ERROR Object of class `object` has no attribute `exec_module` [missing-attribute]
-   --> tests/unit_tests/controllers/console/app/test_app_response_models.py:113:5
+   --> tests/unit_tests/controllers/console/app/test_app_response_models.py:111:5
 ERROR Argument `SimpleNamespace` is not assignable to parameter `workflow` with type `Workflow` in function `controllers.console.app.workflow._parse_file` [bad-argument-type]
   --> tests/unit_tests/controllers/console/app/test_workflow.py:26:40
 ERROR Argument `SimpleNamespace` is not assignable to parameter `workflow` with type `Workflow` in function `controllers.console.app.workflow._parse_file` [bad-argument-type]
   --> tests/unit_tests/controllers/console/app/test_workflow.py:44:42
 ERROR Object of class `FunctionType` has no attribute `assert_called_once_with` [missing-attribute]
-   --> tests/unit_tests/controllers/console/app/test_workflow.py:406:5
-ERROR Object of class `FunctionType` has no attribute `call_count` [missing-attribute]
-   --> tests/unit_tests/controllers/console/app/test_workflow.py:438:12
+   --> tests/unit_tests/controllers/console/app/test_workflow.py:405:5
 ERROR `in` is not supported between `Literal['Maximum']` and `None` [not-iterable]
-   --> tests/unit_tests/controllers/console/app/test_workflow.py:466:12
+   --> tests/unit_tests/controllers/console/app/test_workflow.py:433:12
 ERROR Argument `dict[str, float | list[Unknown] | str]` is not assignable to parameter `payload` with type `dict[str, object] | None` in function `_patch_payload` [bad-argument-type]
    --> tests/unit_tests/controllers/console/app/test_workflow_comment_api.py:157:29
 ERROR Argument `dict[str, float | str]` is not assignable to parameter `payload` with type `dict[str, object] | None` in function `_patch_payload` [bad-argument-type]
@@ -5425,11 +5421,11 @@
 ERROR Object of class `_InteractiveSurfaceDeliveryConfig` has no attribute `recipients` [missing-attribute]
   --> tests/unit_tests/core/workflow/test_human_input_adapter.py:87:12
 ERROR Argument `Literal[123]` is not assignable to parameter `node_data` with type `BaseModel | Mapping[str, Any]` in function `core.workflow.human_input_adapter.adapt_human_input_node_data_for_graph` [bad-argument-type]
-   --> tests/unit_tests/core/workflow/test_human_input_adapter.py:214:47
+   --> tests/unit_tests/core/workflow/test_human_input_adapter.py:279:47
 ERROR Argument `Literal[123]` is not assignable to parameter `node_data` with type `BaseModel | Mapping[str, Any]` in function `core.workflow.human_input_adapter.adapt_node_data_for_graph` [bad-argument-type]
-   --> tests/unit_tests/core/workflow/test_human_input_adapter.py:300:35
+   --> tests/unit_tests/core/workflow/test_human_input_adapter.py:365:35
 ERROR Argument `Literal[123]` is not assignable to parameter `node_config` with type `BaseModel | Mapping[str, Any]` in function `core.workflow.human_input_adapter.adapt_node_config_for_graph` [bad-argument-type]
-   --> tests/unit_tests/core/workflow/test_human_input_adapter.py:305:37
+   --> tests/unit_tests/core/workflow/test_human_input_adapter.py:370:37
 ERROR Argument `_FakeSession` is not assignable to parameter `session` with type `Session | None` in function `core.workflow.human_input_forms.load_form_tokens_by_form_id` [bad-argument-type]
   --> tests/unit_tests/core/workflow/test_human_input_forms.py:37:60
 ERROR Argument `_FakeSession` is not assignable to parameter `session` with type `Session | None` in function `core.workflow.human_input_forms.load_form_tokens_by_form_id` [bad-argument-type]
@@ -5455,23 +5451,23 @@
 ERROR `SimpleNamespace` is not assignable to attribute `graph_runtime_state` with type `GraphRuntimeState` [bad-assignment]
    --> tests/unit_tests/core/workflow/test_node_factory.py:771:39
 ERROR Object of class `ExternalRecipient` has no attribute `reference_id` [missing-attribute]
-  --> tests/unit_tests/core/workflow/test_node_runtime.py:88:12
+  --> tests/unit_tests/core/workflow/test_node_runtime.py:90:12
 ERROR Argument `object` is not assignable to parameter `method` with type `EmailDeliveryMethod | InteractiveSurfaceDeliveryMethod` in function `core.workflow.node_runtime.apply_dify_debug_email_recipient` [bad-argument-type]
-   --> tests/unit_tests/core/workflow/test_node_runtime.py:103:45
+   --> tests/unit_tests/core/workflow/test_node_runtime.py:105:45
 ERROR Argument `SimpleNamespace` is not assignable to parameter `model_instance` with type `ModelInstance` in function `core.workflow.node_runtime.DifyPreparedLLM.__init__` [bad-argument-type]
-   --> tests/unit_tests/core/workflow/test_node_runtime.py:135:32
+   --> tests/unit_tests/core/workflow/test_node_runtime.py:137:32
 ERROR Argument `SimpleNamespace` is not assignable to parameter `model_instance` with type `ModelInstance` in function `core.workflow.node_runtime.DifyPreparedLLM.__init__` [bad-argument-type]
-   --> tests/unit_tests/core/workflow/test_node_runtime.py:170:32
+   --> tests/unit_tests/core/workflow/test_node_runtime.py:172:32
 ERROR Argument `SimpleNamespace` is not assignable to parameter `model_instance` with type `ModelInstance` in function `core.workflow.node_runtime.DifyPreparedLLM.__init__` [bad-argument-type]
-   --> tests/unit_tests/core/workflow/test_node_runtime.py:183:32
+   --> tests/unit_tests/core/workflow/test_node_runtime.py:185:32
 ERROR Argument `SimpleNamespace` is not assignable to parameter `model_instance` with type `ModelInstance` in function `core.workflow.node_runtime.DifyPreparedLLM.__init__` [bad-argument-type]
-   --> tests/unit_tests/core/workflow/test_node_runtime.py:209:32
+   --> tests/unit_tests/core/workflow/test_node_runtime.py:211:32
 ERROR Argument `Literal['chat']` is not assignable to parameter `model_mode` with type `LLMMode` in function `core.workflow.node_runtime.DifyPromptMessageSerializer.serialize` [bad-argument-type]
-   --> tests/unit_tests/core/workflow/test_node_runtime.py:220:20
+   --> tests/unit_tests/core/workflow/test_node_runtime.py:222:20
 ERROR Argument `SimpleNamespace` is not assignable to parameter `file_reference_factory` with type `FileReferenceFactoryProtocol` in function `core.workflow.node_runtime.DifyRetrieverAttachmentLoader.__init__` [bad-argument-type]
-   --> tests/unit_tests/core/workflow/test_node_runtime.py:255:32
+   --> tests/unit_tests/core/workflow/test_node_runtime.py:257:32
 ERROR Object of class `NoneType` has no attribute `storage_key` [missing-attribute]
-   --> tests/unit_tests/core/workflow/test_node_runtime.py:266:12
+   --> tests/unit_tests/core/workflow/test_node_runtime.py:268:12
 ERROR Argument `list[VariableBase]` is not assignable to parameter `variables` with type `Sequence[Variable]` in function `core.workflow.variable_pool_initializer.add_variables_to_pool` [bad-argument-type]
    --> tests/unit_tests/core/workflow/test_variable_pool.py:94:13
 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]

@fatelei
Copy link
Copy Markdown
Contributor

fatelei commented May 6, 2026

style check failed

Cast validated selector payloads after plugin model selector normalization so Python Style passes while preserving the severe 1.14 regression fix.
@sawyer-shi
Copy link
Copy Markdown
Contributor Author

style check failed

fixed,please help to recheck

@sawyer-shi
Copy link
Copy Markdown
Contributor Author

style check failed

@fatelei fixed,please help to recheck

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 6, 2026

Pyrefly Diff

base → PR
--- /tmp/pyrefly_base.txt	2026-05-06 04:24:44.008366591 +0000
+++ /tmp/pyrefly_pr.txt	2026-05-06 04:24:30.456293337 +0000
@@ -5425,11 +5425,11 @@
 ERROR Object of class `_InteractiveSurfaceDeliveryConfig` has no attribute `recipients` [missing-attribute]
   --> tests/unit_tests/core/workflow/test_human_input_adapter.py:87:12
 ERROR Argument `Literal[123]` is not assignable to parameter `node_data` with type `BaseModel | Mapping[str, Any]` in function `core.workflow.human_input_adapter.adapt_human_input_node_data_for_graph` [bad-argument-type]
-   --> tests/unit_tests/core/workflow/test_human_input_adapter.py:214:47
+   --> tests/unit_tests/core/workflow/test_human_input_adapter.py:279:47
 ERROR Argument `Literal[123]` is not assignable to parameter `node_data` with type `BaseModel | Mapping[str, Any]` in function `core.workflow.human_input_adapter.adapt_node_data_for_graph` [bad-argument-type]
-   --> tests/unit_tests/core/workflow/test_human_input_adapter.py:300:35
+   --> tests/unit_tests/core/workflow/test_human_input_adapter.py:365:35
 ERROR Argument `Literal[123]` is not assignable to parameter `node_config` with type `BaseModel | Mapping[str, Any]` in function `core.workflow.human_input_adapter.adapt_node_config_for_graph` [bad-argument-type]
-   --> tests/unit_tests/core/workflow/test_human_input_adapter.py:305:37
+   --> tests/unit_tests/core/workflow/test_human_input_adapter.py:370:37
 ERROR Argument `_FakeSession` is not assignable to parameter `session` with type `Session | None` in function `core.workflow.human_input_forms.load_form_tokens_by_form_id` [bad-argument-type]
   --> tests/unit_tests/core/workflow/test_human_input_forms.py:37:60
 ERROR Argument `_FakeSession` is not assignable to parameter `session` with type `Session | None` in function `core.workflow.human_input_forms.load_form_tokens_by_form_id` [bad-argument-type]
@@ -5455,23 +5455,23 @@
 ERROR `SimpleNamespace` is not assignable to attribute `graph_runtime_state` with type `GraphRuntimeState` [bad-assignment]
    --> tests/unit_tests/core/workflow/test_node_factory.py:771:39
 ERROR Object of class `ExternalRecipient` has no attribute `reference_id` [missing-attribute]
-  --> tests/unit_tests/core/workflow/test_node_runtime.py:88:12
+  --> tests/unit_tests/core/workflow/test_node_runtime.py:90:12
 ERROR Argument `object` is not assignable to parameter `method` with type `EmailDeliveryMethod | InteractiveSurfaceDeliveryMethod` in function `core.workflow.node_runtime.apply_dify_debug_email_recipient` [bad-argument-type]
-   --> tests/unit_tests/core/workflow/test_node_runtime.py:103:45
+   --> tests/unit_tests/core/workflow/test_node_runtime.py:105:45
 ERROR Argument `SimpleNamespace` is not assignable to parameter `model_instance` with type `ModelInstance` in function `core.workflow.node_runtime.DifyPreparedLLM.__init__` [bad-argument-type]
-   --> tests/unit_tests/core/workflow/test_node_runtime.py:135:32
+   --> tests/unit_tests/core/workflow/test_node_runtime.py:137:32
 ERROR Argument `SimpleNamespace` is not assignable to parameter `model_instance` with type `ModelInstance` in function `core.workflow.node_runtime.DifyPreparedLLM.__init__` [bad-argument-type]
-   --> tests/unit_tests/core/workflow/test_node_runtime.py:170:32
+   --> tests/unit_tests/core/workflow/test_node_runtime.py:172:32
 ERROR Argument `SimpleNamespace` is not assignable to parameter `model_instance` with type `ModelInstance` in function `core.workflow.node_runtime.DifyPreparedLLM.__init__` [bad-argument-type]
-   --> tests/unit_tests/core/workflow/test_node_runtime.py:183:32
+   --> tests/unit_tests/core/workflow/test_node_runtime.py:185:32
 ERROR Argument `SimpleNamespace` is not assignable to parameter `model_instance` with type `ModelInstance` in function `core.workflow.node_runtime.DifyPreparedLLM.__init__` [bad-argument-type]
-   --> tests/unit_tests/core/workflow/test_node_runtime.py:209:32
+   --> tests/unit_tests/core/workflow/test_node_runtime.py:211:32
 ERROR Argument `Literal['chat']` is not assignable to parameter `model_mode` with type `LLMMode` in function `core.workflow.node_runtime.DifyPromptMessageSerializer.serialize` [bad-argument-type]
-   --> tests/unit_tests/core/workflow/test_node_runtime.py:220:20
+   --> tests/unit_tests/core/workflow/test_node_runtime.py:222:20
 ERROR Argument `SimpleNamespace` is not assignable to parameter `file_reference_factory` with type `FileReferenceFactoryProtocol` in function `core.workflow.node_runtime.DifyRetrieverAttachmentLoader.__init__` [bad-argument-type]
-   --> tests/unit_tests/core/workflow/test_node_runtime.py:255:32
+   --> tests/unit_tests/core/workflow/test_node_runtime.py:257:32
 ERROR Object of class `NoneType` has no attribute `storage_key` [missing-attribute]
-   --> tests/unit_tests/core/workflow/test_node_runtime.py:266:12
+   --> tests/unit_tests/core/workflow/test_node_runtime.py:268:12
 ERROR Argument `list[VariableBase]` is not assignable to parameter `variables` with type `Sequence[Variable]` in function `core.workflow.variable_pool_initializer.add_variables_to_pool` [bad-argument-type]
    --> tests/unit_tests/core/workflow/test_variable_pool.py:94:13
 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]

@dosubot dosubot Bot added the lgtm This PR has been approved by a maintainer label May 6, 2026
@fatelei fatelei added this pull request to the merge queue May 6, 2026
Merged via the queue into langgenius:main with commit 5753979 May 6, 2026
27 checks passed
@sawyer-shi sawyer-shi deleted the big-bug-fix-model-select-error-in-plugin branch May 8, 2026 07:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🔨 feat:tools Tools for agent, function call related stuff. 🌊 feat:workflow Workflow related stuff. lgtm This PR has been approved by a maintainer size:M This PR changes 30-99 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Big-Bug-on 1.14.0 with model select in plugin

2 participants