From 465233d4c63c560ae72013a41462c1a00e419787 Mon Sep 17 00:00:00 2001 From: CREDO23 Date: Tue, 24 Feb 2026 12:45:25 +0200 Subject: [PATCH] instruct llm not to retry on insufficient_permissions --- .../app/agents/new_chat/tools/google_drive/create_file.py | 7 +++++-- .../app/agents/new_chat/tools/google_drive/trash_file.py | 2 ++ 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/surfsense_backend/app/agents/new_chat/tools/google_drive/create_file.py b/surfsense_backend/app/agents/new_chat/tools/google_drive/create_file.py index b8490c12b..0dd683f7e 100644 --- a/surfsense_backend/app/agents/new_chat/tools/google_drive/create_file.py +++ b/surfsense_backend/app/agents/new_chat/tools/google_drive/create_file.py @@ -48,8 +48,11 @@ def create_create_google_drive_file_tool( - web_view_link: URL to open the file (if success) - message: Result message - IMPORTANT: If status is "rejected", the user explicitly declined the action. - Respond with a brief acknowledgment and do NOT retry or suggest alternatives. + IMPORTANT: + - If status is "rejected", the user explicitly declined the action. + Respond with a brief acknowledgment and do NOT retry or suggest alternatives. + - If status is "insufficient_permissions", the connector lacks the required OAuth scope. + Inform the user they need to re-authenticate and do NOT retry the action. Examples: - "Create a Google Doc called 'Meeting Notes'" diff --git a/surfsense_backend/app/agents/new_chat/tools/google_drive/trash_file.py b/surfsense_backend/app/agents/new_chat/tools/google_drive/trash_file.py index 660f518c6..45fa52610 100644 --- a/surfsense_backend/app/agents/new_chat/tools/google_drive/trash_file.py +++ b/surfsense_backend/app/agents/new_chat/tools/google_drive/trash_file.py @@ -40,6 +40,8 @@ def create_trash_google_drive_file_tool( acknowledgment and do NOT retry or suggest alternatives. - If status is "not_found", relay the exact message to the user and ask them to verify the file name or check if it has been indexed. + - If status is "insufficient_permissions", the connector lacks the required OAuth scope. + Inform the user they need to re-authenticate and do NOT retry the action. Examples: - "Delete the 'Meeting Notes' file from Google Drive"