Infinite loop error when it's actually finite
# 🤝help
e
Hey guys, I have a workflow with several capture cards in a row (origin, destination and stops). The user can answer sequentially or say it all at once in the first prompt. For all inputs, after the user types a value I transition to the Find-City flow to check if the city exists and to disambiguate results. This flow then returns the selected city or cities (if stops) with the state (ex: input: ny / output: New York/NY). However I am getting a infinite loop error when there are several cities mentioned in the input and also when there are several stops, because in these cases I transition nodes and flows several times in a row, and it's indeed a loop, but it ends at some point. Check this example: 🤖 **Bot**: What is your origin? 👤 **User**: NY to LA through Chicago ⚙️ *System *- extracts origin, destination and stops ⚙️ *System *- already informed origin -> goes to Find-City flow -> returns with parsed origin ⚙️ *System *- already informed destination -> goes to Find-City flow -> returns with parsed destination ⚙️ *System *- already informed stops -> goes to Find-City flow with all the stops as input -> returns with parsed stops Then a infinite loop error happens. It's crazy because I have been trying to troubleshoot this error for a week now and then I noticed there is no memory leak anywhere, it's just a transition limitation 🤣 . Maybe I should figure out a way to find all the cities at once instead of going to the Find-City flow everytime, right? But could the system allow more transitions somehow? By noticing that the values are different on each turn or by figuring the end values up ahead. Regards
a
Hey @early-train-33247, I've ran into this error before, too. Behind the scenes, the test for an "infinite loop" is if the flow transitions to and from another workflow two times in a row. A very low bar, IMO! While I can file an internal report to up that limit (I think 3 - 5 would be a good threshold), there are a couple of workarounds for you: 1. As you said, extract all the cities in one turn instead of doing it recursively 2. Duplicate your "Find-City" flow and add that into the rotation so that you're pinging between three flows instead of two
e
Hi @acceptable-kangaroo-64719! I found out the transitions are also very limited for transitions to the same flow, check out these logs
Copy code
14:24:46 error An error occurred in the error handler. Abandoning. [Error, Infinite loop detected. (wf-bab41e486a (nd-ef9ddbf93b) --> wf-bab41e486a (nd-e13c5d7111) --> wf-bab41e486a (nd-f71b22a985) --> wf-bab41e486a (nd-ef9ddbf93b)). Flow: wf-bab41e486a | Node: nd-ef9ddbf93b.
This error should not happen unless your conversation is in a corrupted state (eg. in progress on an older version of the chatbot).
To reset your conversational manually, say "//state/reset" to your chatbot to force the state to reset.
If this error persists, please contact support.]
I am actually extracting all cities and sending them as input to the find-city flow, but I still get this error from whitin the flow ...
a
Huh. I can't say I've seen that error before. Have you, @acceptable-gold-88171 ?
a
@rich-battery-69172 from the error message, it looks like a migration error.
r
OK yeah we have a anti-loop detection algorithm that basically prevents you from having your bot running non-stop and costing you many cloud credits
There isn't an easy solution to circumvent this protection appart from hacking the loop detection – this is dangerous but you could in theory do that with an action reset the stacktraces in the DM:
event.state.__stacktrace
Note that this isn't an official API and might break, but I'm taking a note to add some form of protection removal for those who know what they are doing on specific nodes (ie. increase the anti-loop # on node X)
e
Hey sly! It makes total sense to have this in place
I could try that but I would like a more maintanable and safe approach if possible. That's why I also didn't attempt the second suggestion Gordy gave - duplicating the find city flow. It has AI Tasks and api calls so it would be unpractical.
Alright I appreciate it. For now I am gonna figure out a way to make this loop shorter or not have it at all.
r
I'll try to ship this override for you soon man!
e
nice!! cheers
Hey @rich-battery-69172 just wanted to let you know that I am doing
event.state.__stacktrace = []
and getting the desired behavior. It's a good solution for now, thanks for the tip
s
This loop detection limit is very low. Even 3-5 is a very low bar. I have a use case now where I don't realistically see how I could accomplish the task without looping a few times. Scenario: - I've created "Agent" that will determine if an ability effect has been resolved. The ability will read something like: Subtract 1 from secondaryCharacter Health. If the primaryCharacter has |Darkness| in their Tokens, add 1 to the primaryCharacter Health. - A list of task are created to resolve the the effect. A task is an object with the following values like this: { "instruction": "Subtract 1 from secondaryCharacter Health.", "tools": "healthEffector", "progress": "Task Created.", "isComplete": false } - I grab the first non-completed task in the list. - I grab the first tool in the tools list using GET TOOL NODE and use an expression to go to that workflow - An AI task Completes its job and updates the "Progress" string with what it did, then removes the tool from the list. - Hit the "CHeck If tools Left" condition. If there are any more tools left it marks the isComplete false and goes BACK to the GET TOOL NODE that pulls a new tool from the list and goes to that workflow In the event debugger I can see that once it hits the Get Tool Node a second time it WOULD be going to a new node. It even runs the expresssion. But in background it detects it as a loop and stops it in its tracks. I have hit this problem with multiple use cases and have to come up with a silly workaround to bypass. The bar is set WAY too low and can realistically be hit with any moderatly complex bot. @rich-battery-69172 Is there a way to do this without event.state.__stacktrace = []. In case an actual loop occurs. It seems a much less dangerous solution could be to get the number of loops you hit. And allow the bot creator to determine how many they are willing to have. Once hit, bot creator can raise or determine a better solution
@rich-battery-69172 I was able to bypass using hte event.state.__stacktrace = [] which has solved my current problem so thanks for that!!! But I am worried what will happen if I create an infinite loop.... will the universe implode? As long as the bot doesn't become corrupted in any way i'm good with this 🙂
k
I was also able to bypass it with
event.state.__stacktrace = []
, however that results in the chat restarting itself at the end of the conversation. Are there any plans to fix this without using hacks? Being able to do loops sounds like something very essential for non trivial chatbots
e
hi folks. i am getting the same error here. how did you guys implement this event.state.__stacktrace? not sure i understood it.
b
I managed it by putting an execute code card with
event.state.__stacktrace = []
more or less in the middle of the node that is being repeated.
e
Hey guys we shipped an official feature to increase the amount of times a node can run sequentially, it's called "Node Repetition Limit", available in the Chatbot Settings
The maximum amount is 10
b
@early-train-33247 i need to loop through a table, which could have quite an extensive amount of records. It would be nice to allow a variable in the node repetition limit. also, why is it so low? BTW: Thanks!
c
I am having the same issue. For me the fix with resetting the __stacktrace does not work, because then I get the error that a node does not exist.
I have been trying to get around this for the past couple days but I would much appreciate any pointers.
465 Views