If I edit the last agent's query to:
!inside('container for first alias')you can see why you get the result you do in the original example:

'first' and 'second' are indeed the match. 'not inside' is
everything outside that container.
I too expected your outcome, in that I'd expect query term #2 to work only on the result of term #1. Generally I think this is the caase - certainly with attribute values:
!$Color=="red"
!($Color=="red)The latter form, with parentheses, is informally advised - or certainly so if the first form doesn't work. I tried parentheses on your test with inside() and it made no difference. I also made a separate test where there were on other agents being inspected, i.e. all inside() tests were on containers. No joy. I also looked at other joins like &= as described
here. No joy.
Interestingly I don't find any hard reference for support fot NOT joins for query operators, as opposed to negative attribute value tests.
I'm also less clear after all this on how multiple term queries are tested. I'd always assumed #2 only checked the output of term #1, but maybe this only applies with attribute tests as opposed to (path) queries. By the latter, I mean the hold '#query' type operators pre-v4.6.
If it's any consolation, I'm now as confused as you!