Using an agent to find all sibling notes whose $Title contains "QQ"

Here is the relevant part of my current tbx file:

I want this agent (“AGENT TO BE USED…”) to find note “QQ node 3a1” but not the other QQ notes in subcontainers (here, there are two such notes). Thanks!

If you know the name of the note, you don’t really need an agent, so I’ll assume there may be multiple matches.

The agent’s name mentions ‘siblings’. This is helpful as it makes it easier to scope the query, thus:

$Name(parent(original))==$Name(parent(agent)) & $IsAlias==false & $Name.contains("QQ")

This query finds all notes in the same container as the agent, and which are only original notes and which case=sensitively contain the string ‘QQ’ in the note title. A nice thing about this approach is that you can re-use the query in different agents in different containers. Indeed, if you wanted more than one such agent in the same paper container, you can filter out the other agents by amending the query thus (and obviously altering the ‘contains’ pattern in each case):

$Name(parent(original))==$Name(parent(agent)) & $IsAlias==false & $AgentQuery=="" & $Name.contains("QQ")

If this doesn’t work for your scenario please give a more detailed description of not just what you are looking for but additional context. One agent or many? Always at a certain outline depth? Only searching agent siblings? etc., etc., …

Both queries tested in v8.1.0 under macOS 10.14.6