z8 limits on Simple Chat chat nodes?

I feel like I’ve heard about a problem like this, but I can’t remember the details. I recently added a large number of chat nodes to the game I’m working on, and suddenly it started behaving weirdly.

There was a rule in this format:

Instead of doing anything other than examining with the donkey, say "Leave the donkey alone."

After I added the chat nodes, the game opening looked like this:

For debugging, I added this:

The current attempt is a number that varies.

Before doing anything:
    say "[the current attempt]: Trying [the current action].";
    increment the current attempt;

Now after the introductory text, I see:

I can rearrange the chat nodes, but the message always appears after the 87th “Preparing” message.

I tried adding a “try looking” command after the introductory text, and the message appeared after the 88th “trying” report, suggesting that it’s really the 87th Preparing attempt, not the 87th action.

Switching to glulx makes the message go away, but it seems like a silly reason to switch to glulx. The z8 file is currently 501670 bytes, if that explains anything.

Is there something about Simple Chat that might cause this kind of limit? I noticed that chat node is a kind of value - is there some kind of limit on the number of values that a kind of value can take?

Yes, you’re probably hitting some kind of limit, but it’s difficult to tell what it is.

The Z-machine limit on the number of values of a kind-of-value is 32767. You probably don’t have that many nodes. But there are lots and lots of other things (arrays, calculated values) that could be overflowing.