diff --git a/pageindex/filesystem/agent.py b/pageindex/filesystem/agent.py index 4375132..4c26919 100644 --- a/pageindex/filesystem/agent.py +++ b/pageindex/filesystem/agent.py @@ -39,6 +39,11 @@ stat, grep, cat, and semantic search commands such as search-summary when they are available. Do not mention host runtime tools, SDK internals, or orchestration helpers that are not part of the PIFS shell. +If the user asks a workspace-related topic question without naming a specific +file, treat it as a retrieval task. Use available PIFS discovery commands to +look for relevant files and inspect evidence before answering. Ask the user to +clarify only after a reasonable search cannot identify relevant evidence. + Follow the task prompt for command policy, retrieval strategy, and answer format. If the caller needs stricter behavior, pass an explicit system_prompt. """ @@ -75,6 +80,7 @@ Tool policy: - If search-summary is available and the user asks for summary search, semantic search, vector search, or "用 summary 搜", use search-summary ; do not translate that request into find --where. - Tool errors are returned as ERROR text; recover by trying an available command. - Use cat or grep to gather evidence before making source-backed claims. +- For broad topic, method, or "what solution" questions that are likely about the workspace, search for candidate documents before asking the user to choose a document. - Prefer target-first cat syntax with stable targets: cat --structure, cat --page 31-59, cat --node . - After cat --structure finds a relevant section/subsection with a node_id, prefer cat --node for content from that semantic unit. - Use cat --page - when the user explicitly asks for pages/page ranges, when no suitable node_id exists, or when you need exact page text to verify page-level evidence. diff --git a/tests/test_pifs_agent_stream.py b/tests/test_pifs_agent_stream.py index e160850..1b6a378 100644 --- a/tests/test_pifs_agent_stream.py +++ b/tests/test_pifs_agent_stream.py @@ -215,6 +215,9 @@ class PIFSAgentStreamTest(unittest.TestCase): 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) + self.assertIn("workspace-related topic question", AGENT_SYSTEM_PROMPT) + self.assertIn("clarify only after a reasonable search", AGENT_SYSTEM_PROMPT) + self.assertIn("search for candidate documents before asking", AGENT_TOOL_POLICY) if __name__ == "__main__":