DEV Community

The Unmeshed Team
The Unmeshed Team

Posted on

260 McNuggets and the Loop That Wouldn't Stop

Two friends pull up to an AI drive-thru and order some McNuggets. The AI adds more. They say stop. It adds more. They’re both yelling “Stop!” at the speaker, and the count on the screen keeps climbing until the order hits 260 McNuggets.

Another customer asked for ice cream and got butter and ketchup.

These clips went viral during McDonald’s AI drive-thru test with IBM, and in 2024 McDonald’s ended the pilot. It’s easy to laugh at the nuggets, but there’s a real engineering lesson here, and it isn’t really about AI.

A loop with no way out just keeps going

Whatever went wrong inside that system, the result looked like a loop that couldn’t stop. It kept adding items, and nothing in it said “that’s enough.”

The same thing happens in ordinary software all the time. A workflow polls an API until a job is “ready,” but the job failed and will never be ready. A retry loop keeps retrying a request that will never succeed. An AI agent keeps calling a tool because it never gets the answer it’s looking for. Each repeat looks reasonable on its own. Together, they burn money, hammer other systems or pile up an order nobody wanted.

The fix isn’t smarter logic inside the loop. It’s a rule outside it that says “stop here,” no matter what’s happening inside.

How Unmeshed builds the exit in

In Unmeshed, a While step repeats until its condition says stop. That’s the normal exit, for when the job is done.

It also counts every lap. So even if the condition never turns false, you can cap the loop at three attempts, or ten, or whatever makes sense, and stop there.

And a timeout can fail a step that runs too long. If one lap hangs, the workflow doesn’t wait on it forever.

That gives you three exits: the condition, a limit on laps and a limit on time. You don’t need all three every time, but every loop needs at least one you can trust.

Build the exit before you build the loop.

See how the While step works in Unmeshed.

Top comments (0)