From 1e670142b7b57a938af8ffef24c55ea671c6b497 Mon Sep 17 00:00:00 2001 From: Cameron Pfiffer Date: Tue, 10 Jun 2025 00:29:49 -0700 Subject: [PATCH] Improve error handling for 524 timeout errors in bsky.py MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add specific handling for Cloudflare 524 timeout errors to keep notifications in the queue for retry instead of removing them. This prevents losing notifications during temporary service interruptions. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude --- bsky.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/bsky.py b/bsky.py index 2acc9a7..66c2f6f 100644 --- a/bsky.py +++ b/bsky.py @@ -149,8 +149,25 @@ Use the bluesky_reply tool to send a response less than 300 characters.""" messages = [{"role":"user", "content": prompt}] ) except Exception as api_error: + error_str = str(api_error) logger.error(f"Letta API error: {api_error}") + logger.error(f"Error type: {type(api_error).__name__}") logger.error(f"Mention text was: {mention_text}") + logger.error(f"Author: @{author_handle}") + logger.error(f"URI: {uri}") + + # Check for specific error types + if hasattr(api_error, 'status_code'): + logger.error(f"API Status code: {api_error.status_code}") + if api_error.status_code == 524: + logger.error("524 error - timeout from Cloudflare, will retry later") + return False # Keep in queue for retry + + # Check if error indicates we should remove from queue + if 'status_code: 524' in error_str: + logger.warning("524 timeout error, keeping in queue for retry") + return False # Keep in queue for retry + raise # Extract the reply text from the agent's response -- 2.51.2