mirror of
https://github.com/langgenius/dify.git
synced 2026-09-24 23:22:26 +08:00
fix(agent): preserve plugin-declared model parameters through Agent Soul (#40163)
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
This commit is contained in:
co-authored by
autofix-ci[bot]
parent
e09eee8fd1
commit
7522ae14b2
@@ -119,6 +119,29 @@ def test_request_builder_separates_agent_soul_and_workflow_job_prompt():
|
||||
assert dumped["composition"]["layers"][2]["config"]["user"] == "Summarize the report."
|
||||
|
||||
|
||||
def test_request_builder_forwards_plugin_specific_model_settings_via_extra_body():
|
||||
run_input = _run_input().model_copy(
|
||||
update={
|
||||
"model": AgentBackendModelConfig(
|
||||
plugin_id="langgenius/tongyi",
|
||||
model_provider="tongyi",
|
||||
model="qwen-plus-latest",
|
||||
credentials={"api_key": "secret-key"},
|
||||
model_settings={"temperature": 0.7, "enable_thinking": True, "thinking_budget": 4096},
|
||||
)
|
||||
}
|
||||
)
|
||||
|
||||
request = AgentBackendRunRequestBuilder().build_for_workflow_node(run_input)
|
||||
layers = {layer.name: layer for layer in request.composition.layers}
|
||||
model_config = cast(DifyPluginLLMLayerConfig, layers[DIFY_AGENT_MODEL_LAYER_ID].config)
|
||||
|
||||
assert model_config.model_settings == {
|
||||
"temperature": 0.7,
|
||||
"extra_body": {"enable_thinking": True, "thinking_budget": 4096},
|
||||
}
|
||||
|
||||
|
||||
@pytest.mark.parametrize("agent_config_version_kind", ["snapshot", "draft"])
|
||||
def test_agent_app_request_builder_keeps_agent_soul_prompt_for_snapshot_and_draft(
|
||||
agent_config_version_kind: str,
|
||||
|
||||
@@ -2,6 +2,7 @@ import pytest
|
||||
|
||||
from core.workflow.file_reference import build_file_reference
|
||||
from models.agent_config_entities import (
|
||||
AgentSoulModelSettings,
|
||||
DeclaredArrayItem,
|
||||
DeclaredOutputChildConfig,
|
||||
DeclaredOutputConfig,
|
||||
@@ -9,6 +10,22 @@ from models.agent_config_entities import (
|
||||
)
|
||||
|
||||
|
||||
def test_agent_soul_model_settings_preserves_plugin_declared_parameters() -> None:
|
||||
settings = AgentSoulModelSettings.model_validate(
|
||||
{
|
||||
"temperature": 0.7,
|
||||
"enable_thinking": True,
|
||||
"thinking_budget": 4096,
|
||||
}
|
||||
)
|
||||
|
||||
dumped = settings.model_dump(mode="json", exclude_none=True)
|
||||
|
||||
assert dumped["temperature"] == 0.7
|
||||
assert dumped["enable_thinking"] is True
|
||||
assert dumped["thinking_budget"] == 4096
|
||||
|
||||
|
||||
def test_file_default_value_accepts_canonical_reference_mapping() -> None:
|
||||
reference = build_file_reference(record_id="tool-file-1")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user