How to get smart rule to act on tags created on documents

I replaced my script with a simple script:

on PerformSmartRule(theRecords)
	tell application id "DNtp"
		local theResult
		repeat with theRecord in theRecords
			display dialog "Name of record: " & name of theRecord
		end repeat
	end tell
end PerformSmartRule

Now, when create a new tag on a document, it displays the name of the tag. This means I was wrong – the selected record IS the tag (I’m realizing that I shouldn’t use the term ‘selected record’ — I meant the record that the script is acting on in the smart rule, I just don’t know the terminology as well as I should). However, now, I can’t figure out why the script doesn’t do anything when I create a new tag, but it works when I apply the smart rule on demand to the tag in the /Tags/ group.

It seems the problem is actually because I am trying to trigger a python script using the PyDT3 repository. My actual smart rule script is:

on PerformSmartRule(theRecords)
	
	do shell script "/Library/Frameworks/Python.framework/Versions/3.12/bin/python3 /Users/samrose/PycharmProjects/addPersonTag/addPersonTag.py"
	
	
end PerformSmartRule

and then in the python script, I am trying to access the record via dt3.selected_records:

dt3 = DEVONthink3()

#Gather selected Records
if len(dt3.selected_records) == 0:
    try:
        selected_records = [dt3.viewer_windows[0].root]
        #if not (selected_records): dt3.display_dialog("No Records Selected")
        if not(selected_records[0]):
            print("No Records Selected")
            sys.exit(0)
    except:
        #dt3.display_dialog("No Records Selected")
        print("No Records Selected")
        sys.exit(0)
else: selected_records = dt3.selected_records

I’m not proficient enough to know how to pass theRecords from the applescript wrapper into the python script and I don’t know if the PyDT3 API has a mechanism to access theRecords from the smart rule. I am trying to do this in python because I am trying to learn python and I’ve been frustrated with applescript, which becomes too bulky and gives me memory overload errors when I try to run my longer scripts. However, I know you don’t support the PyDT3 API. If anyone proficient can suggest a path to access theRecords within the python script, that would be great. However, that may be asking for too much… I didn’t realize this was the issue until now.