Regression: ParamsAutoGenerated enum numeric values break MCP Tool parameter handling #19807

Closed
opened 2026-02-21 20:04:12 -05:00 by yindo · 3 comments
Owner

Originally created by @cuixiaojun001 on GitHub (Oct 21, 2025).

Self Checks

  • I have read the Contributing Guide and Language Policy.
  • This is only for bug report, 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.

Dify version

1.9.1

Cloud or Self Hosted

Self Hosted (Source)

Steps to reproduce

  1. In commit chore: adopt StrEnum and auto() for some string-typed enums (#25129),
    the enum ParamsAutoGenerated was modified from:

    class ParamsAutoGenerated(Enum):
        CLOSE = 0
        OPEN = 1
    

    to:

    class ParamsAutoGenerated(IntEnum):
        CLOSE = auto()
        OPEN = auto()
    
  2. After this change, the actual enum values became:

    ParamsAutoGenerated.CLOSE = 1
    ParamsAutoGenerated.OPEN = 2
    
  3. Any code depending on the original numeric values (0,1) now fails.

  4. Specific impact:
    When calling MCP Tool, for non-auto parameters, the tool cannot retrieve the expected fixed value before the model provides a value.
    This leads to incorrect parameters during Call Tool execution.

✔️ Expected Behavior

The enum should retain its original numeric values so that:

ParamsAutoGenerated.CLOSE == 0
ParamsAutoGenerated.OPEN == 1

This ensures MCP Tool correctly handles parameters before the model provides values.

Actual Behavior

The new implementation causes:

ParamsAutoGenerated.CLOSE == 1
ParamsAutoGenerated.OPEN == 2

MCP Tool cannot correctly handle non-auto type parameters → Call Tool uses wrong values.

Originally created by @cuixiaojun001 on GitHub (Oct 21, 2025). ### Self Checks - [x] I have read the [Contributing Guide](https://github.com/langgenius/dify/blob/main/CONTRIBUTING.md) and [Language Policy](https://github.com/langgenius/dify/issues/1542). - [x] This is only for bug report, if you would like to ask a question, please head to [Discussions](https://github.com/langgenius/dify/discussions/categories/general). - [x] I have searched for existing issues [search for existing issues](https://github.com/langgenius/dify/issues), including closed ones. - [x] I confirm that I am using English to submit this report, otherwise it will be closed. - [x] 【中文用户 & Non English User】请使用英语提交,否则会被关闭 :) - [x] Please do not modify this template :) and fill in all the required fields. ### Dify version 1.9.1 ### Cloud or Self Hosted Self Hosted (Source) ### Steps to reproduce 1. In commit chore: adopt StrEnum and auto() for some string-typed enums (#25129), the enum ParamsAutoGenerated was modified from: ```python class ParamsAutoGenerated(Enum): CLOSE = 0 OPEN = 1 ``` to: ```python class ParamsAutoGenerated(IntEnum): CLOSE = auto() OPEN = auto() ``` 2. After this change, the actual enum values became: ```python ParamsAutoGenerated.CLOSE = 1 ParamsAutoGenerated.OPEN = 2 ``` 3. Any code depending on the original numeric values (0,1) now fails. 4. Specific impact: When calling MCP Tool, for non-auto parameters, the tool cannot retrieve the expected fixed value before the model provides a value. This leads to incorrect parameters during Call Tool execution. ### ✔️ Expected Behavior The enum should retain its original numeric values so that: ```python ParamsAutoGenerated.CLOSE == 0 ParamsAutoGenerated.OPEN == 1 ``` This ensures MCP Tool correctly handles parameters before the model provides values. ### ❌ Actual Behavior The new implementation causes: ```python ParamsAutoGenerated.CLOSE == 1 ParamsAutoGenerated.OPEN == 2 ``` MCP Tool cannot correctly handle non-auto type parameters → `Call Tool` uses wrong values.
yindo added the 🐞 bug label 2026-02-21 20:04:12 -05:00
yindo closed this issue 2026-02-21 20:04:12 -05:00
Author
Owner

@dosubot[bot] commented on GitHub (Oct 21, 2025):

Hi @cuixiaojun001! I'm Dosu and I’m helping the dify team.

This regression was caused by changing the ParamsAutoGenerated enum from explicit values (CLOSE=0, OPEN=1) to IntEnum with auto(), which shifted the values to CLOSE=1, OPEN=2 and broke MCP Tool parameter handling that relied on the original values. The fix is merged (PR #26733): MCP Tool logic now checks for both the old value (0) and the new value (ParamsAutoGenerated.CLOSE.value), restoring compatibility.

For future enum changes, always use explicit assignments when downstream code depends on fixed values—avoid auto() in such cases to prevent silent breakages. There are no current contributor guidelines or code comments highlighting this, so adding a note in the code or docs is recommended for maintainability.

To reply, just mention @dosu.


How did I do? Good | Irrelevant | Incorrect | Verbose | Hallucination | Report 🐛 | Other  Chat with Dosu Join Discord Share on X

@dosubot[bot] commented on GitHub (Oct 21, 2025): <!-- Greeting --> Hi @cuixiaojun001! I'm [Dosu](https://go.dosu.dev/dosubot) and I’m helping the dify team. <!-- Answer --> This regression was caused by changing the `ParamsAutoGenerated` enum from explicit values (`CLOSE=0`, `OPEN=1`) to `IntEnum` with `auto()`, which shifted the values to `CLOSE=1`, `OPEN=2` and broke MCP Tool parameter handling that relied on the original values. The fix is merged ([PR #26733](https://github.com/langgenius/dify/pull/26733)): MCP Tool logic now checks for both the old value (`0`) and the new value (`ParamsAutoGenerated.CLOSE.value`), restoring compatibility. For future enum changes, always use explicit assignments when downstream code depends on fixed values—avoid `auto()` in such cases to prevent silent breakages. There are no current contributor guidelines or code comments highlighting this, so adding a note in the code or docs is recommended for maintainability. <!-- Dosu Comment Footer --> *To reply, just mention [@dosu](https://go.dosu.dev/dosubot).* --- <sup>How did I do? [Good](https://app.dosu.dev/response-feedback/aa6985a6-6ecd-45ee-9f81-cc5373ca5f6e?feedback_type=great_response) | [Irrelevant](https://app.dosu.dev/response-feedback/aa6985a6-6ecd-45ee-9f81-cc5373ca5f6e?feedback_type=irrelevant_answer) | [Incorrect](https://app.dosu.dev/response-feedback/aa6985a6-6ecd-45ee-9f81-cc5373ca5f6e?feedback_type=incorrect_sources) | [Verbose](https://app.dosu.dev/response-feedback/aa6985a6-6ecd-45ee-9f81-cc5373ca5f6e?feedback_type=too_verbose) | [Hallucination](https://app.dosu.dev/response-feedback/aa6985a6-6ecd-45ee-9f81-cc5373ca5f6e?feedback_type=hallucination) | [Report 🐛](https://app.dosu.dev/response-feedback/aa6985a6-6ecd-45ee-9f81-cc5373ca5f6e?feedback_type=bug_report) | [Other](https://app.dosu.dev/response-feedback/aa6985a6-6ecd-45ee-9f81-cc5373ca5f6e?feedback_type=other)</sup>&nbsp;&nbsp;[![Chat with Dosu](https://dosu.dev/dosu-chat-badge.svg)](https://app.dosu.dev/6088a4f4-073a-43f3-b3d4-4f06fb0c05a0/ask?utm_source=github)&nbsp;[![Join Discord](https://img.shields.io/badge/join-5865F2?logo=discord&logoColor=white&label=)](https://go.dosu.dev/discord-bot)&nbsp;[![Share on X](https://img.shields.io/badge/X-share-black)](https://twitter.com/intent/tweet?text=%40dosu_ai%20helped%20me%20solve%20this%20issue!&url=https%3A//github.com/langgenius/dify/issues/27251)
Author
Owner

@cuixiaojun001 commented on GitHub (Oct 22, 2025):

PR #26733 works, but checking if param in (CLOSE, 0) feels like a workaround. Explicitly restoring the enum values (CLOSE=0, OPEN=1) keeps backward compatibility clearer and avoids special-case logic in MCP Tool.

@cuixiaojun001 commented on GitHub (Oct 22, 2025): PR #26733 works, but checking if param in (CLOSE, 0) feels like a workaround. Explicitly restoring the enum values (CLOSE=0, OPEN=1) keeps backward compatibility clearer and avoids special-case logic in MCP Tool.
Author
Owner

@dosubot[bot] commented on GitHub (Oct 22, 2025):

You're absolutely right—explicitly restoring the enum values to CLOSE=0, OPEN=1 is the cleanest and most maintainable solution. The current workaround (checking for both the new enum value and 0) was added to quickly restore compatibility, but it does introduce special-case logic that can make the code harder to follow and maintain over time. Best practice is to use explicit assignments for enums when downstream code depends on fixed values, which avoids these kinds of regressions and keeps the logic straightforward. If possible, updating the enum to restore the original values would be preferable for long-term clarity and maintainability source source.

To reply, just mention @dosu.


How did I do? Good | Irrelevant | Incorrect | Verbose | Hallucination | Report 🐛 | Other  Chat with Dosu Join Discord Share on X

@dosubot[bot] commented on GitHub (Oct 22, 2025): <!-- Answer --> You're absolutely right—explicitly restoring the enum values to `CLOSE=0, OPEN=1` is the cleanest and most maintainable solution. The current workaround (checking for both the new enum value and `0`) was added to quickly restore compatibility, but it does introduce special-case logic that can make the code harder to follow and maintain over time. Best practice is to use explicit assignments for enums when downstream code depends on fixed values, which avoids these kinds of regressions and keeps the logic straightforward. If possible, updating the enum to restore the original values would be preferable for long-term clarity and maintainability [source](https://github.com/langgenius/dify/blob/26ff59172eb2605a206997b7eb8b15f8b31c31a7/api/core/workflow/nodes/agent/entities.py) [source](https://github.com/langgenius/dify/pull/26733). <!-- Dosu Comment Footer --> *To reply, just mention [@dosu](https://go.dosu.dev/dosubot).* --- <sup>How did I do? [Good](https://app.dosu.dev/response-feedback/efca7b7a-dceb-42dc-a2ac-4b400a84004d?feedback_type=great_response) | [Irrelevant](https://app.dosu.dev/response-feedback/efca7b7a-dceb-42dc-a2ac-4b400a84004d?feedback_type=irrelevant_answer) | [Incorrect](https://app.dosu.dev/response-feedback/efca7b7a-dceb-42dc-a2ac-4b400a84004d?feedback_type=incorrect_sources) | [Verbose](https://app.dosu.dev/response-feedback/efca7b7a-dceb-42dc-a2ac-4b400a84004d?feedback_type=too_verbose) | [Hallucination](https://app.dosu.dev/response-feedback/efca7b7a-dceb-42dc-a2ac-4b400a84004d?feedback_type=hallucination) | [Report 🐛](https://app.dosu.dev/response-feedback/efca7b7a-dceb-42dc-a2ac-4b400a84004d?feedback_type=bug_report) | [Other](https://app.dosu.dev/response-feedback/efca7b7a-dceb-42dc-a2ac-4b400a84004d?feedback_type=other)</sup>&nbsp;&nbsp;[![Chat with Dosu](https://dosu.dev/dosu-chat-badge.svg)](https://app.dosu.dev/6088a4f4-073a-43f3-b3d4-4f06fb0c05a0/ask?utm_source=github)&nbsp;[![Join Discord](https://img.shields.io/badge/join-5865F2?logo=discord&logoColor=white&label=)](https://go.dosu.dev/discord-bot)&nbsp;[![Share on X](https://img.shields.io/badge/X-share-black)](https://twitter.com/intent/tweet?text=%40dosu_ai%20helped%20me%20solve%20this%20issue!&url=https%3A//github.com/langgenius/dify/issues/27251)
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langgenius/dify#19807