Skip to content

JiuwenSwarm is an intelligent AI Agent built on openJiuwen. It extends the powerful capabilities of large language models directly to your fingertips through various communication apps you use daily.

Python

fix(Prompt Attachment): Move the trusted_dirs_policy section back into the system prompt.

MengHan18df735c2e350e
diff --git a/jiuwenswarm/agents/harness/common/rails/runtime_prompt_rail.py b/jiuwenswarm/agents/harness/common/rails/runtime_prompt_rail.py
index e22896a860..aaff249e0e 100644
--- a/jiuwenswarm/agents/harness/common/rails/runtime_prompt_rail.py
+++ b/jiuwenswarm/agents/harness/common/rails/runtime_prompt_rail.py
@@ -69,6 +69,7 @@ class RuntimePromptRail(DeepAgentRail):
self.system_prompt_builder.remove_section("env")
self.system_prompt_builder.remove_section("browser_tool_policy")
self.system_prompt_builder.remove_section("tui_current_project_policy")
+ self.system_prompt_builder.remove_section("trusted_dirs_policy")
self.system_prompt_builder = None
self.attachment_manager = None
@@ -150,7 +151,8 @@ class RuntimePromptRail(DeepAgentRail):
"language_output",
"env",
"browser_tool_policy",
- "tui_current_project_policy"):
+ "tui_current_project_policy",
+ "trusted_dirs_policy"):
self.system_prompt_builder.remove_section(name)
# ── time ──
@@ -519,17 +521,11 @@ class RuntimePromptRail(DeepAgentRail):
content={"cn": current_project_policy, "en": current_project_policy},
priority=99,
))
- await self._upsert_prompt_attachment(
- ctx,
- section="trusted_dirs_policy",
- content=trusted_dirs_content,
- kind=PromptAttachmentKind.WORKSPACE_DELTA,
+ self.system_prompt_builder.add_section(PromptSection(
+ name="trusted_dirs_policy",
+ content={"cn": trusted_dirs_content, "en": trusted_dirs_content},
priority=90,
- )
- else:
- await self._clear_prompt_attachment(ctx, section="trusted_dirs_policy")
- else:
- await self._clear_prompt_attachment(ctx, section="trusted_dirs_policy")
+ ))
async def _upsert_prompt_attachment(
self,
diff --git a/tests/unit_tests/agentserver/test_system_prompt_restructure.py b/tests/unit_tests/agentserver/test_system_prompt_restructure.py
index ba7ba3b08c..af8c314404 100644
--- a/tests/unit_tests/agentserver/test_system_prompt_restructure.py
+++ b/tests/unit_tests/agentserver/test_system_prompt_restructure.py
@@ -339,13 +339,13 @@ async def test_runtime_prompt_uses_runtime_cwd_over_stale_trusted_dir(tmp_path):
assert "# Current Project Workspace" in prompt
assert "Current project directory" in prompt
assert "Do not call `pwd`, `ls`" in prompt
- rendered = agent.prompt_attachment_manager.render(
- await agent.prompt_attachment_manager.list_by_filter(session_id="sess1")
- )
- assert "Current project directory" in rendered
- assert str(current_dir) in rendered
- assert str(stale_dir) not in rendered
- assert str(extra_dir) in rendered
+ assert "# Working Directory Policy" in prompt
+ assert str(current_dir) in prompt
+ assert str(stale_dir) not in prompt
+ assert str(extra_dir) in prompt
+
+ items = await agent.prompt_attachment_manager.list_by_filter(session_id="sess1")
+ assert [item.id for item in items if item.id.endswith(".trusted_dirs_policy")] == []
@pytest.mark.asyncio