diff --git a/surfsense_backend/app/agents/new_chat/tools/notion/create_page.py b/surfsense_backend/app/agents/new_chat/tools/notion/create_page.py index 6dcf4d733..4825c2aed 100644 --- a/surfsense_backend/app/agents/new_chat/tools/notion/create_page.py +++ b/surfsense_backend/app/agents/new_chat/tools/notion/create_page.py @@ -50,11 +50,15 @@ def create_create_notion_page_tool( Returns: Dictionary with: - - status: "success" or "error" - - page_id: Created page ID - - url: URL to the created page - - title: Page title - - message: Success or error message + - status: "success", "rejected", or "error" + - page_id: Created page ID (if success) + - url: URL to the created page (if success) + - title: Page title (if success) + - message: Result message + + IMPORTANT: If status is "rejected", the user explicitly declined the action. + Respond with a brief acknowledgment (e.g., "Understood, I didn't create the page.") + and move on. Do NOT ask for parent page IDs, troubleshoot, or suggest alternatives. Examples: - "Create a Notion page titled 'Meeting Notes' with content 'Discussed project timeline'" @@ -80,10 +84,9 @@ def create_create_notion_page_tool( "message": context["error"], } - logger.info("Requesting approval for creating Notion page") + logger.info(f"Requesting approval for creating Notion page: '{title}'") approval = interrupt({ "type": "notion_page_creation", - "message": f"Approve creating Notion page: '{title}'", "action": { "tool": "create_notion_page", "params": { @@ -105,13 +108,14 @@ def create_create_notion_page_tool( } decision = decisions[0] - decision_type = decision.get("decision_type") + decision_type = decision.get("type") or decision.get("decision_type") + logger.info(f"User decision: {decision_type}") if decision_type == "reject": logger.info("Notion page creation rejected by user") return { "status": "rejected", - "message": "Page creation was rejected", + "message": "User declined. The page was not created. Do not ask again or suggest alternatives.", } edited_action = decision.get("edited_action", {}) diff --git a/surfsense_backend/app/services/new_streaming_service.py b/surfsense_backend/app/services/new_streaming_service.py index e2c3f0840..4bb5530ce 100644 --- a/surfsense_backend/app/services/new_streaming_service.py +++ b/surfsense_backend/app/services/new_streaming_service.py @@ -523,19 +523,19 @@ class VercelStreamingService: Handles two interrupt sources: 1. interrupt_on config (Deep Agent built-in): Already has action_requests/review_configs - 2. interrupt() primitive (custom tool code): Has type/message/action/context + 2. interrupt() primitive (custom tool code): Has type/action/context (message is optional) Args: interrupt_value: Raw interrupt payload from Deep Agent Returns: - dict: Normalized payload with action_requests, review_configs, and optional context + dict: Normalized payload with action_requests, review_configs, and optional context/message """ if "action_requests" in interrupt_value and "review_configs" in interrupt_value: return interrupt_value interrupt_type = interrupt_value.get("type", "unknown") - message = interrupt_value.get("message", "Approval required") + message = interrupt_value.get("message") action = interrupt_value.get("action", {}) context = interrupt_value.get("context", {}) @@ -553,9 +553,10 @@ class VercelStreamingService: } ], "interrupt_type": interrupt_type, - "message": message, "context": context, } + if message: + normalized["message"] = message return normalized # ========================================================================= diff --git a/surfsense_web/components/tool-ui/create-notion-page.tsx b/surfsense_web/components/tool-ui/create-notion-page.tsx index f62390e9f..f810343ea 100644 --- a/surfsense_web/components/tool-ui/create-notion-page.tsx +++ b/surfsense_web/components/tool-ui/create-notion-page.tsx @@ -164,19 +164,15 @@ function ApprovalCard({ {/* Context section - account and parent page selection */} {!decided && interruptData.context && (
{interruptData.message}
- )} - {interruptData.context.error ? ({interruptData.context.error}
) : ( <> {accounts.length > 0 && (