AIP Logic fails to execute Ontology Writes despite being in an Action context

I have an AIP Logic function which returns Ontology Edits. This function is then run as the rule for an Action type that I have created. However, it fails dramatically, claiming a “Scenario” context despite clearly being run from an Action. I will call the Action type containing this AIP Logic Function “Action A”.

The structure of the AIP Logic function in question is as follows:

Inputs: no inputs

Ontology retrieval (using a TSv2 function)
Loop (id in ...some list) {
  Conditional: if (...) {
    Do Ontology Retrieval
    Make LLM call
    Loop (x in ...some list) {
      Execute Action B with x
    }
  } else { Do nothing }
}
return (all the OntologyEdits from the big loop)

(This should be unrelated but Action B executes another AIP Logic function which has in it a reference to another action, at which point the action tree ends. However, this has never caused us problems before.)

It all type-checks and there are no problems reported. In fact, you can see here in this picture what is roughly going on.

However, when Action A is called and the function within it runs, it crashes and fails with the following errors. This error appears everywhere, even within the AIP Logic Debugger and with no clear reason why. The type-checking is fine, nothing explicit preventing running, definitely NOT being run from a Scenario context (these errors happen whether running Action A from Automate, a Workshop app, etc).

We require this action to be able to perform the requisite Ontology edits.

The problems that this is causing are significant and, in our opinion, completely intractable. Support appreciated.

Update: have heard from other sources that in fact I cannot call a Logic-backed action from within AIP Logic. Documenting here for anyone else who comes across this.

The fact that I can add everything, it then typechecks + compiles, only for the failure to occur at runtime is awful language design (if I consider AIP Logic its own “language”). I’m supposing that part of the issue is some kind of type erasure (i.e. regular actions vs. logic-backed) to turn things into the unified Ontology Action layer. But if the underlying behaviours vary by execution context, then that’s not good, in my opinion.

Furthermore, my workaround involves inlining all the AIP Logic functions that I need into a single “mega” Logic function (I’m not proud of my creation here to be honest).

However, I stumbled across a separate issue, wherein after a certain amount of nesting of loops/conditionals/groups, whatever language server / compiler powering AIP Logic decides to completely break and stop doing anything. Even though, by my calculations, the types I had were perfectly correct. It was only at a nesting level of around ~6 so this really does surprise me that the limits are so low.

My workaround: make it even worse to work with (but at least functional) by removing some conditional bits and using a custom defined tail function.

See pictures for example of error:

Picture 1: we are at the maximum before the compiler explodes. Note that the type hints are visible above blocks.

Picture 2: Kaboom! Everything breaks and I can do nothing anymore. Usually on the bottom tab, there is a nice grey tick saying compilation successful or similar.