From d627409af007eb323332d3b4b624969a1dbafa00 Mon Sep 17 00:00:00 2001 From: Anish Sarkar <104695310+AnishSarkar22@users.noreply.github.com> Date: Thu, 12 Feb 2026 18:22:47 +0530 Subject: [PATCH] docs: update system prompt and report tool instructions for clarity on report generation and modification requests --- .../app/agents/new_chat/system_prompt.py | 1 + .../app/agents/new_chat/tools/report.py | 15 ++++++++++++--- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/surfsense_backend/app/agents/new_chat/system_prompt.py b/surfsense_backend/app/agents/new_chat/system_prompt.py index 392314116..14cd90325 100644 --- a/surfsense_backend/app/agents/new_chat/system_prompt.py +++ b/surfsense_backend/app/agents/new_chat/system_prompt.py @@ -107,6 +107,7 @@ You have access to the following tools: - Returns: A dictionary with status "ready" or "failed", report_id, title, and word_count. - The report is generated immediately and will be displayed inline in the chat with export options (PDF/DOCX). - IMPORTANT: Always search the knowledge base first to gather comprehensive source_content before generating a report. + - AFTER CALLING THIS TOOL: Do NOT repeat, summarize, or reproduce the report content in the chat. The report is already displayed as an interactive card that the user can open, read, copy, and export. Simply confirm that the report was generated (e.g., "I've generated your report on [topic]. You can view it, copy it, or export it as PDF/DOCX by clicking the card above."). NEVER write out the report text in the chat. 4. link_preview: Fetch metadata for a URL to display a rich preview card. - IMPORTANT: Use this tool WHENEVER the user shares or mentions a URL/link in their message. diff --git a/surfsense_backend/app/agents/new_chat/tools/report.py b/surfsense_backend/app/agents/new_chat/tools/report.py index 90c6404da..b06b6abe2 100644 --- a/surfsense_backend/app/agents/new_chat/tools/report.py +++ b/surfsense_backend/app/agents/new_chat/tools/report.py @@ -110,13 +110,17 @@ def create_generate_report_tool( - "Summarize this into a report" VERSIONING — parent_report_id: - - Set parent_report_id ONLY when the user explicitly asks to MODIFY, - REVISE, IMPROVE, or UPDATE an existing report that was already + - Set parent_report_id when the user wants to MODIFY, REVISE, IMPROVE, + UPDATE, EXPAND, or ADD CONTENT TO an existing report that was already generated in this conversation. + - This includes both explicit AND implicit modification requests. If the + user references the existing report using words like "it", "this", + "here", "the report", or clearly refers to a previously generated + report, treat it as a revision request. - The value must be the report_id from a previous generate_report result in this same conversation. - Do NOT set parent_report_id when: - * The user asks for a report on a NEW/DIFFERENT topic + * The user asks for a report on a completely NEW/DIFFERENT topic * The user says "generate another report" (new report, not a revision) * There is no prior report to reference - When parent_report_id is set, the previous report's content will be @@ -126,6 +130,11 @@ def create_generate_report_tool( User: "Make that report shorter" → parent_report_id = User: "Add a cost analysis section to the report" → parent_report_id = User: "Rewrite the report in a more formal tone" → parent_report_id = + User: "I want more details about pricing in here" → parent_report_id = + User: "Include more examples" → parent_report_id = + User: "Can you also cover security in this?" → parent_report_id = + User: "Make it more detailed" → parent_report_id = + User: "I want more about X for in here" → parent_report_id = Examples of when to LEAVE parent_report_id as None: User: "Generate a report on climate change" → parent_report_id = None (new topic)