fix(filesystem): scope pifs chat identity

This commit is contained in:
BukeLy 2026-05-26 16:19:32 +08:00
parent c12c2de65b
commit ec96812e6b
2 changed files with 18 additions and 1 deletions

View file

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

View file

@ -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 <path> --node <node_id>", 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()