Handle page not found as informational status instead of error

This commit is contained in:
CREDO23 2026-02-13 13:22:52 +02:00
parent 9411edf057
commit da451ffff7

View file

@ -46,15 +46,20 @@ def create_update_notion_page_tool(
Returns: Returns:
Dictionary with: Dictionary with:
- status: "success", "rejected", or "error" - status: "success", "rejected", "not_found", or "error"
- page_id: Updated page ID (if success) - page_id: Updated page ID (if success)
- url: URL to the updated page (if success) - url: URL to the updated page (if success)
- title: Current page title (if success) - title: Current page title (if success)
- message: Result message - message: Result message
IMPORTANT: If status is "rejected", the user explicitly declined the action. IMPORTANT:
- If status is "rejected", the user explicitly declined the action.
Respond with a brief acknowledgment (e.g., "Understood, I didn't update the page.") Respond with a brief acknowledgment (e.g., "Understood, I didn't update the page.")
and move on. Do NOT ask for alternatives or troubleshoot. and move on. Do NOT ask for alternatives or troubleshoot.
- If status is "not_found", inform the user conversationally using the exact message provided.
Example: "I couldn't find the page '[page_title]' in your indexed Notion pages. [message details]"
Do NOT treat this as an error. Do NOT invent information. Simply relay the message and
ask the user to verify the page title or check if it's been indexed.
Examples: Examples:
- "Add 'New meeting notes from today' to the 'Meeting Notes' page" - "Add 'New meeting notes from today' to the 'Meeting Notes' page"
@ -83,10 +88,19 @@ def create_update_notion_page_tool(
) )
if "error" in context: if "error" in context:
logger.error(f"Failed to fetch update context: {context['error']}") error_msg = context["error"]
# Check if it's a "not found" error (softer handling for LLM)
if "not found" in error_msg.lower():
logger.warning(f"Page not found: {error_msg}")
return {
"status": "not_found",
"message": error_msg,
}
else:
logger.error(f"Failed to fetch update context: {error_msg}")
return { return {
"status": "error", "status": "error",
"message": context["error"], "message": error_msg,
} }
page_id = context.get("page_id") page_id = context.get("page_id")