+24
-5
bsky.py
+24
-5
bsky.py
···
657
ignored_notification = False
658
ignore_reason = ""
659
ignore_category = ""
660
-
661
for message in message_response.messages:
662
-
if hasattr(message, 'tool_call_id') and hasattr(message, 'status') and hasattr(message, 'name'):
663
if message.name == 'add_post_to_bluesky_reply_thread':
664
tool_call_results[message.tool_call_id] = message.status
665
logger.debug(f"Tool result: {message.tool_call_id} -> {message.status}")
···
686
export_agent_state(CLIENT, void_agent, skip_git=SKIP_GIT)
687
logger.info("=== BOT TERMINATED DUE TO DEPRECATED TOOL USE ===")
688
exit(1)
689
-
690
# Second pass: process messages and check for successful tool calls
691
for i, message in enumerate(message_response.messages, 1):
692
# Log concise message info instead of full object
···
785
elif message.tool_call.name == 'add_post_to_bluesky_reply_thread':
786
tool_call_id = message.tool_call.tool_call_id
787
tool_status = tool_call_results.get(tool_call_id, 'unknown')
788
-
789
if tool_status == 'success':
790
try:
791
args = json.loads(message.tool_call.arguments)
792
reply_text = args.get('text', '')
793
reply_lang = args.get('lang', 'en-US')
794
-
795
if reply_text: # Only add if there's actual content
796
reply_candidates.append((reply_text, reply_lang))
797
logger.debug(f"Found successful add_post_to_bluesky_reply_thread candidate: {reply_text[:50]}... (lang: {reply_lang})")
···
801
logger.debug(f"Skipping failed add_post_to_bluesky_reply_thread tool call (status: error)")
802
else:
803
logger.warning(f"⚠️ Skipping add_post_to_bluesky_reply_thread tool call with unknown status: {tool_status}")
804
805
# Handle archival memory deletion if any were flagged (only if no halt was received)
806
if flagged_memories:
···
657
ignored_notification = False
658
ignore_reason = ""
659
ignore_category = ""
660
+
661
+
logger.debug(f"Processing {len(message_response.messages)} messages from agent")
662
+
663
for message in message_response.messages:
664
+
# Log detailed message attributes for debugging
665
+
msg_type = getattr(message, 'message_type', 'unknown')
666
+
has_tool_call_id = hasattr(message, 'tool_call_id')
667
+
has_status = hasattr(message, 'status')
668
+
has_name = hasattr(message, 'name')
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}")
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}")
674
+
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}")
···
698
export_agent_state(CLIENT, void_agent, skip_git=SKIP_GIT)
699
logger.info("=== BOT TERMINATED DUE TO DEPRECATED TOOL USE ===")
700
exit(1)
701
+
702
+
logger.debug(f"First pass complete. Collected {len(tool_call_results)} tool call results")
703
+
logger.debug(f"tool_call_results: {tool_call_results}")
704
+
705
# Second pass: process messages and check for successful tool calls
706
for i, message in enumerate(message_response.messages, 1):
707
# Log concise message info instead of full object
···
800
elif message.tool_call.name == 'add_post_to_bluesky_reply_thread':
801
tool_call_id = message.tool_call.tool_call_id
802
tool_status = tool_call_results.get(tool_call_id, 'unknown')
803
+
804
+
logger.debug(f"Found add_post_to_bluesky_reply_thread tool call: id={tool_call_id}, status={tool_status}")
805
+
logger.debug(f"Available tool_call_results: {tool_call_results}")
806
+
807
if tool_status == 'success':
808
try:
809
args = json.loads(message.tool_call.arguments)
810
reply_text = args.get('text', '')
811
reply_lang = args.get('lang', 'en-US')
812
+
813
if reply_text: # Only add if there's actual content
814
reply_candidates.append((reply_text, reply_lang))
815
logger.debug(f"Found successful add_post_to_bluesky_reply_thread candidate: {reply_text[:50]}... (lang: {reply_lang})")
···
819
logger.debug(f"Skipping failed add_post_to_bluesky_reply_thread tool call (status: error)")
820
else:
821
logger.warning(f"⚠️ Skipping add_post_to_bluesky_reply_thread tool call with unknown status: {tool_status}")
822
+
logger.warning(f" Tool call ID '{tool_call_id}' not found in tool_call_results dict")
823
824
# Handle archival memory deletion if any were flagged (only if no halt was received)
825
if flagged_memories: