How to exclude notes inside() another agent

I think I found a bug. I created a few tasks, one of which is overdue and the other isn’t. Then I added an agent, Overdue, that finds overdue tasks, using the following query:

$Prototype==“Task”&$DueDate<date(today)

This agent works fine. It matches the overdue task.

I added another agent, Non-overdue tasks, with this query:

($Prototype==“Task”)&(inside(“/Overdue”)==false)

This second agent incorrectly matches the overdue task. The overdue task is inside /Overdue, so it should be excluded. It seems like inside(“/Overdue”)==false is not excluding tasks matched by the Overdue agent. I also tried !inside("/Overdue") and a few variations for the path to the Overdue agent, to no avail.

Here is a buggy Tinderbox file to play with.

Am I missing how to do this?

The original notes /Overdue task and /Non-overdue task are each not inside /Overdue. So both original notes match the query.

If you had an agent of /NotOverdue tasks, then inside(/NotOverdue) would be a useful approach.

So, inside(/Overdue) is false for the original note /Overdue task and true for the alias of /Overdue task inside the /Overdue agent. I hadn’t considered how inside() could return different results like that on different occurrences of the same note.

It looks like I need to define /Overdue and /NotOverdue independently. Unless I misunderstood your last sentence?

It looks like I need to define /Overdue and /NotOverdue independently. Unless I misunderstood your last sentence?

That’s what I’m suggesting.

Because of the semantics of aliases, it is possible for one note to be inside(X) and inside(Y) at once, even though X≠Y. This also means the same note may simultaneously be inside(X) and !inside(X). This seems strange in this context, but of course it’s necessary if you want inside(/the/Agent) to be useful.

I’ve been thinking about how to do this… and I think I’ve got it. Here’s the gist:

!$AgentQuery & !(collect(children(agent red), $ID(original)).contains($ID(original)))

The idea is that we look at an agent’s children and collect their original $ID, and then see if the compared note’s original $ID is in that list.

Example doc: not inside agent.tbx (60.1 KB)

@drowsyfervour here is a buggy-fixed version of your original file :slight_smile:

1 Like

Thank you, pat! This is great.