From 1461663ae91e5a04d3bc74aa47a13a846c8fbaaa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=9B=90=E7=B2=92=20Yanli?= Date: Wed, 8 Jul 2026 16:24:58 +0800 Subject: [PATCH] Clarify build mode prompt guidance --- api/clients/agent_backend/request_builder.py | 9 ++++----- .../agent_backend/test_request_builder.py | 16 +++------------- .../agent_app/test_runtime_request_builder.py | 16 +++------------- 3 files changed, 10 insertions(+), 31 deletions(-) diff --git a/api/clients/agent_backend/request_builder.py b/api/clients/agent_backend/request_builder.py index 63002e9b433..4c6f336fb2a 100644 --- a/api/clients/agent_backend/request_builder.py +++ b/api/clients/agent_backend/request_builder.py @@ -114,12 +114,11 @@ def _markdown_backtick_fence(text: str) -> str: _BUILD_DRAFT_AGENT_SOUL_PROMPT = """You are running in build mode. Objective: -- Prepare this agent's working environment, configuration, tools, files, notes, and context for later normal runs. +- Improve this agent's working environment, configuration, tools, files, notes, and context so it can handle the intended task well. -Rules: -- Do not complete the intended user task now. -- Do not answer as if this were a normal user-facing run. -- Make setup and configuration changes only when they help later runs complete the intended task. +Guidance: +- Treat the intended task as context for setup work, validation, and configuration decisions. +- Perform concrete investigative or setup steps when they help improve or verify the agent configuration. - Use the installed `dify-agent` CLI when you need to inspect or persist Agent configuration.""" diff --git a/api/tests/unit_tests/clients/agent_backend/test_request_builder.py b/api/tests/unit_tests/clients/agent_backend/test_request_builder.py index 00b35cf150b..b2b77275fa7 100644 --- a/api/tests/unit_tests/clients/agent_backend/test_request_builder.py +++ b/api/tests/unit_tests/clients/agent_backend/test_request_builder.py @@ -155,19 +155,9 @@ def test_agent_app_request_builder_wraps_agent_soul_prompt_for_build_draft(): layers = {layer.name: layer for layer in request.composition.layers} prompt_config = cast(PromptLayerConfig, layers[AGENT_SOUL_PROMPT_LAYER_ID].config) - assert prompt_config.prefix == ( - "You are running in build mode.\n\n" - "Objective:\n" - "- Prepare this agent's working environment, configuration, tools, files, notes, " - "and context for later normal runs.\n\n" - "Rules:\n" - "- Do not complete the intended user task now.\n" - "- Do not answer as if this were a normal user-facing run.\n" - "- Make setup and configuration changes only when they help later runs complete the intended task.\n" - "- Use the installed `dify-agent` CLI when you need to inspect or persist Agent configuration.\n\n" - "Intended task for later normal runs:\n" - "```text\nYou are Iris.\n```" - ) + assert prompt_config.prefix != original_prompt + assert prompt_config.prefix.startswith("You are running in build mode.") + assert "```text\nYou are Iris.\n```" in prompt_config.prefix def test_agent_app_request_builder_uses_longer_fence_for_build_draft_prompt_body(): diff --git a/api/tests/unit_tests/core/app/apps/agent_app/test_runtime_request_builder.py b/api/tests/unit_tests/core/app/apps/agent_app/test_runtime_request_builder.py index e9f873add6e..b3ea05b8a87 100644 --- a/api/tests/unit_tests/core/app/apps/agent_app/test_runtime_request_builder.py +++ b/api/tests/unit_tests/core/app/apps/agent_app/test_runtime_request_builder.py @@ -221,19 +221,9 @@ class TestAgentAppRuntimeRequestBuilder: result = builder.build(_ctx(_soul_with_model(), agent_config_version_kind="build_draft")) prompt_layer = next(layer for layer in result.request.composition.layers if layer.name == "agent_soul_prompt") - assert prompt_layer.config.prefix == ( - "You are running in build mode.\n\n" - "Objective:\n" - "- Prepare this agent's working environment, configuration, tools, files, notes, " - "and context for later normal runs.\n\n" - "Rules:\n" - "- Do not complete the intended user task now.\n" - "- Do not answer as if this were a normal user-facing run.\n" - "- Make setup and configuration changes only when they help later runs complete the intended task.\n" - "- Use the installed `dify-agent` CLI when you need to inspect or persist Agent configuration.\n\n" - "Intended task for later normal runs:\n" - "```text\nYou are Iris.\n```" - ) + assert prompt_layer.config.prefix != _soul_with_model().prompt + assert prompt_layer.config.prefix.startswith("You are running in build mode.") + assert "```text\nYou are Iris.\n```" in prompt_layer.config.prefix def test_build_propagates_draft_version_kind_without_wrapping_prompt(self): builder = AgentAppRuntimeRequestBuilder(