Parameter Extractor Uses Function Call Prompts in Prompt Mode #16486

Closed
opened 2026-02-21 19:26:18 -05:00 by yindo · 1 comment
Owner

Originally created by @ding113 on GitHub (Aug 27, 2025).

Originally assigned to: @ding113 on GitHub.

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.8.0 (also confirmed in 1.4.2)

Cloud or Self Hosted

Self Hosted (Docker)

Steps to reproduce

  1. Create a new workflow with a Parameter Extractor node
  2. Configure the Parameter Extractor with:
    - Reasoning Mode: Select "Prompt" (not "Function Call")
    - Add any parameter (e.g., name: "location", type: "string", description: "Extract location")
  3. Connect to any LLM model (tested with Qwen3 8B and GPT-5)
  4. Provide test input text containing the parameter to extract
  5. Run the workflow and observe the model's output

Expected: Model should output clean JSON format as specified for Prompt mode
Actual: Model receives conflicting instructions and produces inconsistent outputs

In api/core/workflow/nodes/parameter_extractor/parameter_extractor_node.py line 755:

  # BUG: Uses FUNCTION_CALLING_EXTRACTOR_SYSTEM_PROMPT even in Prompt mode
  system_prompt_messages = ChatModelMessage(
      role=PromptMessageRole.SYSTEM,
      text=FUNCTION_CALLING_EXTRACTOR_SYSTEM_PROMPT.format(histories=memory_str, instruction=instruction),
  )

The system prompt incorrectly includes: "Always call the extract_parameters function with the correct parameters"

The _get_prompt_engineering_prompt_template method in parameter_extractor_node.py has a bug where it uses the wrong prompt constant for Chat models in Prompt mode. The correct CHAT_GENERATE_JSON_PROMPT exists in the codebase but is not imported or used.

✔️ Expected Behavior

When Prompt mode is selected in the Parameter Extractor:

  1. The system should use JSON-focused prompts (CHAT_GENERATE_JSON_PROMPT) for Chat models
  2. The model should receive clear instructions to output only JSON format
  3. No Function Call instructions should be present in the system prompt
  4. The model should consistently output structured JSON without attempting function calls
  5. Behavior should be predictable across different model capabilities (both local and cloud models)

Actual Behavior

When Prompt mode is selected:

  1. The system incorrectly uses FUNCTION_CALLING_EXTRACTOR_SYSTEM_PROMPT which contains Function Call instructions
  2. The model receives conflicting signals:
    - System prompt: "Always call the extract_parameters function"
    - Expected output: JSON format
  3. This causes inconsistent behavior:
    - Sometimes the model attempts function calls (especially stronger models like GPT-5)
    - Sometimes the model outputs JSON format
Originally created by @ding113 on GitHub (Aug 27, 2025). Originally assigned to: @ding113 on GitHub. ### 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.8.0 (also confirmed in 1.4.2) ### Cloud or Self Hosted Self Hosted (Docker) ### Steps to reproduce 1. Create a new workflow with a Parameter Extractor node 2. Configure the Parameter Extractor with: - Reasoning Mode: Select "Prompt" (not "Function Call") - Add any parameter (e.g., name: "location", type: "string", description: "Extract location") 3. Connect to any LLM model (tested with Qwen3 8B and GPT-5) 4. Provide test input text containing the parameter to extract 5. Run the workflow and observe the model's output Expected: Model should output clean JSON format as specified for Prompt mode Actual: Model receives conflicting instructions and produces inconsistent outputs In `api/core/workflow/nodes/parameter_extractor/parameter_extractor_node.py` line 755: ```Python # BUG: Uses FUNCTION_CALLING_EXTRACTOR_SYSTEM_PROMPT even in Prompt mode system_prompt_messages = ChatModelMessage( role=PromptMessageRole.SYSTEM, text=FUNCTION_CALLING_EXTRACTOR_SYSTEM_PROMPT.format(histories=memory_str, instruction=instruction), ) ``` The system prompt incorrectly includes: `"Always call the extract_parameters function with the correct parameters"` The `_get_prompt_engineering_prompt_template` method in `parameter_extractor_node.py` has a bug where it uses the wrong prompt constant for Chat models in Prompt mode. The correct `CHAT_GENERATE_JSON_PROMPT` exists in the codebase but is not imported or used. ### ✔️ Expected Behavior When Prompt mode is selected in the Parameter Extractor: 1. The system should use JSON-focused prompts (`CHAT_GENERATE_JSON_PROMPT`) for Chat models 2. The model should receive clear instructions to output only JSON format 3. No Function Call instructions should be present in the system prompt 4. The model should consistently output structured JSON without attempting function calls 5. Behavior should be predictable across different model capabilities (both local and cloud models) ### ❌ Actual Behavior When Prompt mode is selected: 1. The system incorrectly uses `FUNCTION_CALLING_EXTRACTOR_SYSTEM_PROMPT` which contains Function Call instructions 2. The model receives conflicting signals: - System prompt: "Always call the extract_parameters function" - Expected output: JSON format 3. This causes inconsistent behavior: - Sometimes the model attempts function calls (especially stronger models like GPT-5) - Sometimes the model outputs JSON format
yindo added the 🐞 bug label 2026-02-21 19:26:18 -05:00
yindo closed this issue 2026-02-21 19:26:18 -05:00
Author
Owner

@dosubot[bot] commented on GitHub (Aug 27, 2025):

You've correctly identified a bug: in Prompt mode, the Parameter Extractor node uses FUNCTION_CALLING_EXTRACTOR_SYSTEM_PROMPT for Chat models, which includes function call instructions and causes inconsistent outputs. The codebase defines a JSON-focused prompt (CHAT_GENERATE_JSON_PROMPT), but it isn't used in this context. To fix this, update the _get_prompt_engineering_prompt_template method to use CHAT_GENERATE_JSON_PROMPT for Chat models in Prompt mode instead of the function call prompt. This will ensure the model receives clear instructions to output only JSON, avoiding function call confusion and producing consistent results across models. No existing issues or merged PRs address this bug yet, so a manual code patch is the best workaround for now.
See supporting code details

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 (Aug 27, 2025): <!-- Answer --> You've correctly identified a bug: in Prompt mode, the Parameter Extractor node uses `FUNCTION_CALLING_EXTRACTOR_SYSTEM_PROMPT` for Chat models, which includes function call instructions and causes inconsistent outputs. The codebase defines a JSON-focused prompt (`CHAT_GENERATE_JSON_PROMPT`), but it isn't used in this context. To fix this, update the `_get_prompt_engineering_prompt_template` method to use `CHAT_GENERATE_JSON_PROMPT` for Chat models in Prompt mode instead of the function call prompt. This will ensure the model receives clear instructions to output only JSON, avoiding function call confusion and producing consistent results across models. No existing issues or merged PRs address this bug yet, so a manual code patch is the best workaround for now. [See supporting code details](https://github.com/langgenius/dify/blob/34b041e9f0c371b1d15cfa1e0d119d023f4fc8fa/api/core/workflow/nodes/parameter_extractor/parameter_extractor_node.py) <!-- 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/b02edef5-5ede-460d-a1b6-ba11760e83ab?feedback_type=great_response) | [Irrelevant](https://app.dosu.dev/response-feedback/b02edef5-5ede-460d-a1b6-ba11760e83ab?feedback_type=irrelevant_answer) | [Incorrect](https://app.dosu.dev/response-feedback/b02edef5-5ede-460d-a1b6-ba11760e83ab?feedback_type=incorrect_sources) | [Verbose](https://app.dosu.dev/response-feedback/b02edef5-5ede-460d-a1b6-ba11760e83ab?feedback_type=too_verbose) | [Hallucination](https://app.dosu.dev/response-feedback/b02edef5-5ede-460d-a1b6-ba11760e83ab?feedback_type=hallucination) | [Report 🐛](https://app.dosu.dev/response-feedback/b02edef5-5ede-460d-a1b6-ba11760e83ab?feedback_type=bug_report) | [Other](https://app.dosu.dev/response-feedback/b02edef5-5ede-460d-a1b6-ba11760e83ab?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/24629)
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langgenius/dify#16486