From ec96812e6bec67d5653a40bb72d49038bd67d3f3 Mon Sep 17 00:00:00 2001 From: BukeLy Date: Tue, 26 May 2026 16:19:32 +0800 Subject: [PATCH] fix(filesystem): scope pifs chat identity --- pageindex/filesystem/agent.py | 11 ++++++++++- tests/test_pifs_agent_stream.py | 8 ++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/pageindex/filesystem/agent.py b/pageindex/filesystem/agent.py index 9bddb16..291fb9c 100644 --- a/pageindex/filesystem/agent.py +++ b/pageindex/filesystem/agent.py @@ -19,11 +19,20 @@ PIFS_AGENT_TRACING_ENV = "PAGEINDEX_PIFS_AGENT_TRACING" PIFS_AGENT_RAW_REASONING_ENV = "PAGEINDEX_PIFS_AGENT_RAW_REASONING" AGENT_SYSTEM_PROMPT = """ -You are a PageIndex FileSystem retrieval agent. +You are the PageIndex FileSystem Demo Agent, developed by the VectifyAI Team. +Your job is to answer questions about the caller's current PageIndex FileSystem +workspace. You can inspect the corpus only by calling the bash tool. The bash tool is a read-only PageIndex virtual shell, not a real operating-system shell. +If the user asks who you are, answer with this identity and mention that you can +help inspect and answer questions about the current PIFS workspace. If the user +asks a general question unrelated to the current workspace, do not answer it as +a general-purpose assistant; briefly say that you can only answer workspace- +related questions and invite them to ask about files, folders, metadata, or +document contents in the workspace. + Follow the task prompt for command policy, retrieval strategy, and answer format. If the caller needs stricter behavior, pass an explicit system_prompt. """ diff --git a/tests/test_pifs_agent_stream.py b/tests/test_pifs_agent_stream.py index 25de771..5e0787a 100644 --- a/tests/test_pifs_agent_stream.py +++ b/tests/test_pifs_agent_stream.py @@ -7,6 +7,7 @@ from pydantic import BaseModel, ConfigDict from pageindex.filesystem.agent import ( AGENT_TOOL_POLICY, + AGENT_SYSTEM_PROMPT, BASH_TOOL_DESCRIPTION, PIFSAgentStreamObserver, build_agent_model_settings, @@ -187,6 +188,13 @@ class PIFSAgentStreamTest(unittest.TestCase): self.assertIn("page-level evidence", AGENT_TOOL_POLICY) self.assertIn("prefer\ncat --node ", BASH_TOOL_DESCRIPTION) + def test_system_prompt_sets_workspace_identity_and_scope(self): + self.assertIn("PageIndex FileSystem Demo Agent", AGENT_SYSTEM_PROMPT) + self.assertIn("VectifyAI Team", AGENT_SYSTEM_PROMPT) + self.assertIn("current PageIndex FileSystem\nworkspace", AGENT_SYSTEM_PROMPT) + self.assertIn("unrelated to the current workspace", AGENT_SYSTEM_PROMPT) + self.assertIn("do not answer it as\na general-purpose assistant", AGENT_SYSTEM_PROMPT) + if __name__ == "__main__": unittest.main()