Skip to content

fix(core): preserve stop sequences from model_config entity in easy UI apps (#41460) - #41472

Open
loulanyue wants to merge 1 commit into
langgenius:mainfrom
loulanyue:fix/41460-easy-ui-model-config-stop-sequence
Open

fix(core): preserve stop sequences from model_config entity in easy UI apps (#41460)#41472
loulanyue wants to merge 1 commit into
langgenius:mainfrom
loulanyue:fix/41460-easy-ui-model-config-stop-sequence

Conversation

@loulanyue

Copy link
Copy Markdown
Contributor

Summary

Fixes #41460.

In non-workflow (easy UI based) apps such as Chatbot, Agent, and Completion apps, stop sequences configured in model parameters were never being passed through to the model execution runtime.

Root Cause

  1. ModelConfigManager.convert extracts stop from completion_params and assigns it to ModelConfigEntity.stop:
    completion_params = model_config.get("completion_params") or {}
    stop = []
    if "stop" in completion_params:
        stop = completion_params["stop"]
        del completion_params["stop"]
    
    return ModelConfigEntity(..., parameters=completion_params, stop=stop)
  2. However, downstream ModelConfigConverter.convert previously only inspected model_config.parameters (which no longer contained "stop"), completely ignoring model_config.stop:
    # Previous:
    completion_params = model_config.parameters
    stop = []
    if "stop" in completion_params:
        stop = completion_params["stop"]
        del completion_params["stop"]
    As a consequence, stop was always set to an empty list [] in ModelConfigWithCredentialsEntity, causing the model to generate past configured stop sequences.

Solution

  • Updated ModelConfigConverter.convert to initialize stop from model_config.stop (list(model_config.stop) if getattr(model_config, "stop", None) else []), while still supporting fallback extraction from completion_params["stop"] if present.
  • Avoided in-place mutation of model_config.parameters by taking a dictionary copy completion_params = dict(model_config.parameters).
  • Added unit tests in test_model_config_converter.py covering model_config.stop and end-to-end ModelConfigManager -> ModelConfigConverter conversion.

Verification

  • uv run pytest tests/unit_tests/core/app/app_config/easy_ui_based_app/test_model_config_converter.py (15 passed)
  • uv run pytest tests/unit_tests/core/app/app_config/easy_ui_based_app/test_model_config_manager.py (21 passed)
  • uv run ruff check (0 errors)
  • uv run ruff format --check (2 files already formatted)

@dosubot dosubot Bot added the size:XS This PR changes 0-9 lines, ignoring generated files. label Aug 29, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Pyrefly Diff

base → PR
--- /tmp/pyrefly_base.txt	2026-08-29 14:00:36.662230200 +0000
+++ /tmp/pyrefly_pr.txt	2026-08-29 14:00:28.362198639 +0000
@@ -4192,6 +4192,8 @@
    --> tests/unit_tests/core/app/app_config/easy_ui_based_app/test_dataset_manager.py:205:47
 ERROR Object of class `NoneType` has no attribute `dataset_ids` [missing-attribute]
    --> tests/unit_tests/core/app/app_config/easy_ui_based_app/test_dataset_manager.py:206:16
+ERROR Argument `dict[str, dict[str, str | dict[str, float | list[str]]]]` is not assignable to parameter `config` with type `AppModelConfigDict` in function `core.app.app_config.easy_ui_based_app.model_config.manager.ModelConfigManager.convert` [bad-argument-type]
+   --> tests/unit_tests/core/app/app_config/easy_ui_based_app/test_model_config_converter.py:123:45
 ERROR Missing required key `opening_statement` for TypedDict `AppModelConfigDict` [bad-typed-dict-key]
   --> tests/unit_tests/core/app/app_config/easy_ui_based_app/test_model_config_manager.py:72:40
 ERROR Missing required key `suggested_questions` for TypedDict `AppModelConfigDict` [bad-typed-dict-key]

@github-actions

Copy link
Copy Markdown
Contributor

Pyrefly Type Coverage

Metric Base PR Delta
Type coverage 61.46% 61.46% -0.01%
Strict coverage 61.06% 61.06% -0.01%
Typed symbols 42,528 42,527 -1
Untyped symbols 26,840 26,846 +6
Modules 3277 3277 0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:XS This PR changes 0-9 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Stop sequences configured on non-workflow apps are never sent to the model

1 participant