Skip to content

AST Execution, Errors & Limits

This page explains what happens when an AST command runs and how to debug it when something goes wrong.

  1. A command or event triggers the template
  2. Argument placeholders like &p1 and &t are resolved
  3. Execution context is created with user, channel, and event data
  4. Input is tokenized
  5. Tokens are parsed into an AST
  6. The AST is evaluated
  7. Variables are written to memory, cache, or database if needed
  8. Final output is rendered and sent to chat

Understanding the order helps you debug issues like:

  • arguments not showing up where you expect
  • missing variables
  • branches running unexpectedly
  • command references returning surprising results
  • EventSub functions returning blank values in chat
Error PatternMeaning
[Unknown function: name]The function is not registered
[Loop error: invalid loop syntax]The loop syntax is malformed
[Loop error: missing loop body]The loop is missing {}
[Parse error: expr]The parser could not understand the expression
Usage: $(func ...)The function arguments are missing or invalid
PlanMax nesting depthMax iterations
Free225
Premium350
Pro4100
  • max recursion depth: 5
  • cycles are detected and stopped
  • $(delay N) supports up to 60 seconds

Before building the full command, test a minimal version first.

Terminal window
"Hello $(user)!"

Good order:

  1. plain text
  2. arguments
  3. functions
  4. variables
  5. conditionals
  6. loops

If a cache or database value might not exist yet, check it first:

Terminal window
*(^(#wins) ? %(#wins) : "no wins yet")

This is wrong if you want to increment:

Terminal window
%(#wins 1)

This is correct:

Terminal window
%(#wins *(%(#wins) + 1))

Functions like $(cheer.amount) or $(reward.input) only work when the command runs from the matching event type.

If a # or ## variable expired, it comes back blank.

&t must be last. You cannot define new &pN placeholders after it.

If a loop can be replaced by a direct expression or command reference, prefer the simpler option.

Commands using moderation, role, title, game, poll, or trigger actions should not be available to everyone.

When a command breaks, ask these questions in order:

  1. Are my arguments correct?
  2. Did I create the variable before reading it?
  3. Am I assigning or incrementing?
  4. Am I in the right context for this function?
  5. Did I accidentally create recursion or loop complexity?

Build the output first, then add side effects.

For example, test the text and branch logic before you add:

  • $(ban ...)
  • $(vip ...)
  • $(set.title ...)
  • $(start.poll ...)
  • $(trigger.send ...)

That makes it much easier to confirm the logic before the command starts changing real channel state.