Clarify build mode prompt guidance

This commit is contained in:
盐粒 Yanli
2026-07-08 16:24:58 +08:00
parent 5a167e59d1
commit 1461663ae9
3 changed files with 10 additions and 31 deletions

View File

@ -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."""

View File

@ -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():

View File

@ -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(