It can be useful for an agent's query or action to refer to the agent itself. This is especially helpful if creating generic agents where the same query/action needs to be applied many times in different contexts.
The 'agent' designator can be used within the agent to refer to its own attributes. This allows some construction of prototype agents. Thus:
Query: descendedFrom($Name(agent))
Or, more usefully:
Query: descendedFrom($TargetValue(agent))
In the prototype agent $TargetVlaue is blank. To use the system make a new agent, set its $TargetValue to the name of the container you wish to analyse, set the agent to use the prototype. This way a generic agent with many attributes can be pre-made and re-used many times.
Note: smart adornments can use the 'adornment' designator in the same way as agents use the 'agent' designator.
Another approach is to set this rule in the prototype:
Rule: if(!$IsPrototype){$AgentQuery|="descendedFrom("+$Name+")";
This time we don't need the 'agent' designator the current note context is already the agent. Also, the if() guard clause stops the code from being executed until in an actual agent using the prototype and not in the prototype itself. We also use a "|=" assignment so the rule runs just once to set the query. Otherwise every agent cycle the query would get re-set and never get to run as the query gets used the next cycle after being set - before which the rule would reset it.
However, the latter approach does allow for a more complex setting where the query pattern must be derived from an expression using several attributes:
Rule: if(!$IsPrototype){$AgentQuery|="descendedFrom("+$TargetValue+" - " $TargetValue(Other note)+")"}
If wanting to set OnAdd code that uses a literal value of an agent's attribute, then the prototype method is needed.
If wanting to set the query/action just the once, besides using |=, you may consider using a self-cancelling code. However, you are better using a "" (empty string ) reset than resetting inheritance - otherwise the note re-inherits from its prototype in a never-ending loop. In the latter case the process won't run away but code will re-run each agent cycle.
