mirror of
https://github.com/MODSetter/SurfSense.git
synced 2026-04-27 17:56:25 +02:00
feat: add DedupHITLToolCallsMiddleware to prevent duplicate tool calls
- Introduced DedupHITLToolCallsMiddleware to prevent duplicate HITL tool calls within a single LLM response, ensuring only the first occurrence of each tool call is retained. - Updated the create_surfsense_deep_agent function to include the new middleware, enhancing the efficiency of tool interactions. - Added a new middleware file for better organization and maintainability of the codebase.
This commit is contained in:
parent
744ad1fa79
commit
ff6514a99f
13 changed files with 97 additions and 51 deletions
|
|
@ -22,9 +22,9 @@ def create_trash_gmail_email_tool(
|
|||
email_subject_or_id: str,
|
||||
delete_from_kb: bool = False,
|
||||
) -> dict[str, Any]:
|
||||
"""Move an email to trash in Gmail.
|
||||
"""Move an email or draft to trash in Gmail.
|
||||
|
||||
Use when the user asks to delete, remove, or trash an email.
|
||||
Use when the user asks to delete, remove, or trash an email or draft.
|
||||
|
||||
Args:
|
||||
email_subject_or_id: The exact subject line or message ID of the
|
||||
|
|
@ -47,12 +47,6 @@ def create_trash_gmail_email_tool(
|
|||
to verify the email subject 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 this tool.
|
||||
- ONLY call this tool ONCE per user request. The system automatically picks the
|
||||
most relevant match when multiple emails share the same subject. The user will
|
||||
see the exact email details (sender, date) in the approval card and can reject
|
||||
if it is not the right one. Do NOT call this tool multiple times for the same
|
||||
email subject.
|
||||
|
||||
Examples:
|
||||
- "Delete the email about 'Meeting Cancelled'"
|
||||
- "Trash the email from Bob about the project"
|
||||
|
|
|
|||
|
|
@ -39,7 +39,8 @@ def create_update_gmail_draft_tool(
|
|||
context. The user will review and can freely edit the content in the approval
|
||||
card before confirming.
|
||||
|
||||
IMPORTANT: This tool is ONLY for Gmail drafts, NOT for Notion pages,
|
||||
IMPORTANT: This tool is ONLY for modifying Gmail draft content, NOT for
|
||||
deleting/trashing drafts (use trash_gmail_email instead), Notion pages,
|
||||
calendar events, or any other content type.
|
||||
|
||||
Args:
|
||||
|
|
@ -63,10 +64,6 @@ def create_update_gmail_draft_tool(
|
|||
Respond with a brief 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 draft subject or check if it has been indexed.
|
||||
- ONLY call this tool ONCE per user request. The system automatically picks the
|
||||
most relevant match when multiple drafts share the same subject. The user will
|
||||
see the exact draft details in the approval card and can reject if it is not
|
||||
the right one. Do NOT call this tool multiple times for the same draft subject.
|
||||
- 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.
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue