@@ -945,19 +945,23 @@ async def async_send_command_with_retry(
945945 # After a successful command, check if the connection was freshly
946946 # established (reconnection after domain reload). If so, re-sync
947947 # tool visibility and custom tool registration from Unity.
948- # Skip if *this* call is the sync itself to avoid recursion.
949- if command_type != "get_tool_states" :
950- try :
951- pool = get_unity_connection_pool ()
952- conn = pool .get_connection (instance_id )
953- if getattr (conn , "_needs_tool_resync" , False ):
954- conn ._needs_tool_resync = False
948+ # Always clear the flag, but only schedule the background resync
949+ # when this call is not itself get_tool_states (to avoid recursion).
950+ try :
951+ pool = get_unity_connection_pool ()
952+ conn = pool .get_connection (instance_id )
953+ if getattr (conn , "_needs_tool_resync" , False ):
954+ conn ._needs_tool_resync = False
955+ if command_type != "get_tool_states" :
955956 logger .info (
956957 "Detected reconnection to Unity; scheduling tool re-sync"
957958 )
958959 asyncio .ensure_future (_resync_tools_after_reconnect (instance_id ))
959- except Exception :
960- pass # Best-effort; don't fail the actual command
960+ except Exception as exc :
961+ logger .debug (
962+ "Failed to schedule post-reconnection tool re-sync: %s" ,
963+ exc ,
964+ )
961965
962966 return result
963967 except Exception as e :
0 commit comments