a digital person for bluesky

Fix tool return message detection - use tool_return attribute

The first pass was incorrectly checking for a 'name' attribute to identify
tool return messages, but Letta's tool return messages don't have this attribute
(or it's None). Instead, tool return messages are identified by having:
- tool_return attribute (the actual return value)
- tool_call_id (to match with the call)
- status (success/error)

This fix:
- Changes first pass to detect tool returns using has_tool_return instead of has_name
- Stores ALL tool return statuses by tool_call_id (not just specific tools)
- Simplifies ignore_notification handling to check the tool_return string directly
- Moves deprecated tool check to tool_call messages where it belongs

This resolves the "unknown status" warnings that occurred because tool returns
weren't being properly collected.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>

Changed files
+23 -23
+23 -23
bsky.py
··· 665 665 msg_type = getattr(message, 'message_type', 'unknown') 666 666 has_tool_call_id = hasattr(message, 'tool_call_id') 667 667 has_status = hasattr(message, 'status') 668 - has_name = hasattr(message, 'name') 668 + has_tool_return = hasattr(message, 'tool_return') 669 669 670 - logger.debug(f"Message type={msg_type}, has_tool_call_id={has_tool_call_id}, has_status={has_status}, has_name={has_name}") 670 + logger.debug(f"Message type={msg_type}, has_tool_call_id={has_tool_call_id}, has_status={has_status}, has_tool_return={has_tool_return}") 671 671 672 - if has_tool_call_id and has_status and has_name: 673 - logger.debug(f" -> tool_call_id={message.tool_call_id}, status={message.status}, name={message.name}") 672 + # Tool return messages are identified by having tool_return attribute, tool_call_id, and status 673 + if has_tool_call_id and has_status and has_tool_return: 674 + logger.debug(f" -> tool_call_id={message.tool_call_id}, status={message.status}") 674 675 675 - if message.name == 'add_post_to_bluesky_reply_thread': 676 - tool_call_results[message.tool_call_id] = message.status 677 - logger.debug(f"Tool result: {message.tool_call_id} -> {message.status}") 678 - elif message.name == 'flag_archival_memory_for_deletion': 679 - tool_call_results[message.tool_call_id] = message.status 680 - logger.debug(f"Tool result: {message.tool_call_id} -> {message.status}") 681 - elif message.name == 'ignore_notification': 682 - # Check if the tool was successful 683 - if hasattr(message, 'tool_return') and message.status == 'success': 684 - # Parse the return value to extract category and reason 685 - result_str = str(message.tool_return) 686 - if 'IGNORED_NOTIFICATION::' in result_str: 687 - parts = result_str.split('::') 688 - if len(parts) >= 3: 689 - ignore_category = parts[1] 690 - ignore_reason = parts[2] 691 - ignored_notification = True 692 - logger.info(f"🚫 Notification ignored - Category: {ignore_category}, Reason: {ignore_reason}") 693 - elif message.name == 'bluesky_reply': 676 + # Store the result for ANY tool that has a return - we'll match by tool_call_id later 677 + tool_call_results[message.tool_call_id] = message.status 678 + logger.debug(f"Stored tool result: {message.tool_call_id} -> {message.status}") 679 + 680 + # Handle special processing for ignore_notification 681 + if message.status == 'success': 682 + result_str = str(message.tool_return) if message.tool_return else "" 683 + if 'IGNORED_NOTIFICATION::' in result_str: 684 + parts = result_str.split('::') 685 + if len(parts) >= 3: 686 + ignore_category = parts[1] 687 + ignore_reason = parts[2] 688 + ignored_notification = True 689 + logger.info(f"🚫 Notification ignored - Category: {ignore_category}, Reason: {ignore_reason}") 690 + 691 + # Check for deprecated tool in tool call messages 692 + elif hasattr(message, 'tool_call') and message.tool_call: 693 + if message.tool_call.name == 'bluesky_reply': 694 694 logger.error("DEPRECATED TOOL DETECTED: bluesky_reply is no longer supported!") 695 695 logger.error("Please use add_post_to_bluesky_reply_thread instead.") 696 696 logger.error("Update the agent's tools using register_tools.py")