a digital person for bluesky

Improve logging and error handling for mentions

+4 -6
+4 -6
bsky.py
··· 124 124 # Get thread context as YAML string 125 125 thread_context = thread_to_yaml_string(thread) 126 126 127 - print(thread_context) 128 - 129 127 # Create a prompt for the Letta agent with thread context 130 128 prompt = f"""You received a mention on Bluesky from @{author_handle} ({author_name or author_handle}). 131 129 ··· 145 143 - reply_to_cid: {cid}""" 146 144 147 145 # Get response from Letta agent 148 - logger.info(f"Generating reply for mention from @{author_handle}") 146 + logger.info(f"@{author_handle}: {mention_text}") 149 147 logger.debug(f"Prompt being sent: {prompt}") 150 148 151 149 try: ··· 160 158 logger.error(f"Mention text was: {mention_text}") 161 159 logger.error(f"Author: @{author_handle}") 162 160 logger.error(f"URI: {uri}") 163 - 161 + 164 162 # Check for specific error types 165 163 if hasattr(api_error, 'status_code'): 166 164 logger.error(f"API Status code: {api_error.status_code}") 167 165 if api_error.status_code == 524: 168 166 logger.error("524 error - timeout from Cloudflare, will retry later") 169 167 return False # Keep in queue for retry 170 - 168 + 171 169 # Check if error indicates we should remove from queue 172 170 if 'status_code: 524' in error_str: 173 171 logger.warning("524 timeout error, keeping in queue for retry") 174 172 return False # Keep in queue for retry 175 - 173 + 176 174 raise 177 175 178 176 # Extract the reply text from the agent's response