Tinderbox Forum

Restricting agent scope to a specific path

(riccardo) #1

I am looking to restrict an Agent scope to a specific path, I am looking for all the people in my tbx (eg. $Prototype==“Person”), but would like to collect only those under a specific path (of the outline).

Thank you!

(Mark Anderson) #2

Look at inside() and descendedFrom().

(riccardo) #3

Thank you.

How would I use it with the item note designator ‘parent’ in order not to hardcode the path?

(Mark Anderson) #4

Not enough info! Are you saying you want to the agent to find items inside the agent’s parent container? That would be a circular reference. Can you explain the relationship of the objects a bit more - bear in mind we can’t see what you see. :slight_smile:

(riccardo) #5

Node A
. . Person 6
. . Node B
. . . Agent collecting all people in node B and below
. . . Person 1
. . . Person 2
. . . . .Node C
. . . . . Person 3
. . . . . Person 4
. . . Node D
. . . . . Person 5

The agent should collect all “person” below Node B (1,2,3,4), it should exclude person (5,6)

I can do it with descendedFrom but only if hardcoding Node B in it, I am trying to avoid that.

(Mark Anderson) #6

How about a query like:

descendedFrom(parent(agent)) & $Prototype=="Person"

However, this will find Person 5 as Node D is descended from Node B. It seems odd that All nodes except Node C descend from other nodes. I’m not sure of the rules of the structure here. Here’s the result of the above query:


I’m not sure quite how you indicate Person 5 isn’t in scope. You might need to rethink your outline structure or add extra metadata.

(riccardo) #7

I think my indents were wrong, I was posting from my phone and it is no easy feat , spaces are stripped, anything with more than three dots is displayed as 3 dots…

Node D was intended to be a sibling of Note B, then your solution should work (I am saying should because I am still working from the phone as of yesterday and I haven’t tried it yet).


(Mark Anderson) #8

Great! I thought that might be the case. So, I hope that helps you once you are back at your Mac.

(Mark Anderson) #9

For later readers, it’s worth noting one thing here. The agent is in-scope of queries based on the agent’s parent. In the above case, the agent is then excluded by the query term matching a specific prototype. However, when using a scenario like this, do take care that the agent isn’t matching itself (or the aliases within it) as it could create a loop and give the app a headache and you the wrong result).

(riccardo) #10

Yep it works just fine! And yes I had taken into account recursive-ity of the query when asking.

I have decided to have one TBX file to rule them all on some work matters, but as a result I need to reduce the scope of agents (for the time being) to a specific outline branch. I will experiment a bit more with this approach, if it proves to be more painful than I thought I am going to revert to one file per major area.


(Mark Anderson) #11

Thanks. My follow-up warning was less for you that later reader of the thread as people often take ideas for old threads and adapt them (as they are encouraged to do!). It just struck me that a new user might easily overlook the fact the agent was within its own query scope, if using only inside() or descendedFrom() as the query. :slight_smile: