← Latest papers
💻 computer science

Fail-Fast, Restart-Smart: Early Failure Prediction and Restart for SWE Agentic Tasks

The paper introduces FailFast-RestartSmart, a two-stage controller that uses a lightweight monitor to predict and terminate failing SWE agent trajectories early to save tokens, while employing a smart restart mechanism that leverages partial edits from the interrupted run to significantly improve task resolution rates compared to cold restarts.

Original authors: Chenyu Wang, Yunbo Lyu, Junda He, Zhou Yang, Chenxing Zhong, Yaniv Harel, David Lo

Published 2026-08-05
📖 7 min read🧠 Deep dive

Original authors: Chenyu Wang, Yunbo Lyu, Junda He, Zhou Yang, Chenxing Zhong, Yaniv Harel, David Lo

Original paper licensed under CC BY 4.0 (http://creativecommons.org/licenses/by/4.0/). This is an AI-generated explanation of the paper below. It is not written or endorsed by the authors. For technical accuracy, refer to the original paper. Read full disclaimer

Imagine you are teaching a very smart, but sometimes overly enthusiastic, robot to fix a broken machine in a giant factory. This robot, an "AI agent," doesn't just snap its fingers to fix things; it has to walk around, read manuals, grab tools, try to tighten a bolt, check if it worked, and then move to the next step. This process is called a "trajectory." Sometimes, the robot gets stuck in a loop, trying the same broken idea over and over, or it wanders down a path that leads nowhere. Because the robot has to remember every single step it took to keep its place in the factory, these long, failed trips get incredibly expensive in terms of computer power and time. It's like a student who keeps re-reading the same wrong chapter of a textbook for three hours instead of realizing they're studying the wrong subject and switching books.

The big question researchers have been asking is: Can we teach the robot to realize, "Hey, I'm going down the wrong path," before it wastes hours of time? And if we stop it, can we save the useful parts of what it tried to do so it doesn't have to start from absolute zero? This paper tackles that exact problem. It introduces a system that acts like a smart supervisor, watching the robot's progress in real-time. If the supervisor sees the robot is about to fail, it hits the brakes early to save energy. But instead of just telling the robot to "forget everything and start over," it hands the robot a "magic clipboard" containing the useful code changes it made, allowing the robot to try again with a fresh mind but keeping the good work it already did.

The Problem: The "Token Snowball" and the Wasted Loop

Software engineering agents are like detectives solving a mystery. They look at a code problem, think about a solution, type out some code, run a test, and see if it works. If it doesn't, they try again. The problem is that these detectives often get stuck in "redundant exploration." They might keep trying the same wrong fix, or they might wander around the codebase in circles. As they do this, they have to carry their entire history of thoughts and actions in their memory. This creates a "token snowball effect," where the longer the robot runs, the more expensive every single step becomes.

When a robot fails, it usually runs longer than a successful one. It's like a car driving in circles until it runs out of gas. The researchers noticed that these failures often show warning signs early on—repetitive loops or redundant steps—long before the robot finally gives up. The challenge is that stopping a robot too early is risky. If you stop it when it was actually on the verge of a breakthrough, you've wasted a good run. But if you let it run until it fails completely, you've wasted even more resources.

The Solution: Fail-Fast and Restart-Smart

The authors propose a two-part system called Fail-Fast–Restart-Smart. Think of it as a team of two: a tiny, super-fast watchdog named FailFast, and a clever recovery guide named RestartSmart.

FailFast: The Tiny Watchdog
FailFast is a very small, lightweight AI monitor (only 0.6 billion parameters, which is tiny compared to the main robot). Its job is to watch the robot's "thoughts" and "actions" as they happen. It doesn't need to see the robot's internal brain waves; it just reads the text the robot is generating.

To learn how to spot a failure, FailFast was trained on thousands of examples where it learned to recognize the difference between a robot that is making progress and one that is spinning its wheels. It looks for specific signs, like a lack of progress in fixing the code tests. If FailFast sees the robot is likely to fail, it sounds an alarm. Crucially, this alarm is calibrated so that it rarely stops a robot that was actually going to succeed (keeping "false alarms" low).

RestartSmart: The Magic Clipboard
When FailFast sounds the alarm, the robot stops. But here is where the magic happens. In the past, if a robot failed, you would just tell it to "start over" from scratch. This is called a "cold restart," and it's inefficient because the robot has to re-discover everything it already figured out.

RestartSmart changes the game. When the robot is stopped, the system takes all the code edits the robot made before it was stopped and saves them as a "diff" (a list of changes). It then starts a brand new, fresh run of the robot. This new robot has no memory of the old, confused thoughts that led to the failure. However, it is given access to the "Magic Clipboard" containing the code changes.

The new robot can look at the clipboard and say, "Oh, this code change looks good, I'll keep it," or "This part is wrong, I'll throw it away." It has the freedom to accept, modify, or discard the previous work. This allows the robot to skip the boring part of re-discovering the solution while avoiding the trap of the bad reasoning that caused the failure in the first place.

What They Found: Saving Time and Getting Better Results

The researchers tested this system on a famous benchmark called SWE-bench Verified, which involves fixing real-world software bugs. They used a powerful AI model (Qwen3.6-27B) as the main robot and the tiny FailFast monitor to watch it.

Saving the "Gas"
The results showed that FailFast is incredibly good at spotting trouble early. At a strict setting where they only wanted to accidentally stop a successful robot 5% of the time, FailFast managed to save 20.4% of the total computer power (tokens) used. This is a huge win. For comparison, other methods that just count how many steps a robot takes saved only about 11.4%, and a more complex method called AgentStop saved 12.5%. The tiny monitor was able to save more resources than methods that required much more complex data to work.

The Power of the "Magic Clipboard"
When they combined FailFast with RestartSmart, the results were even better. By stopping the failing runs and letting the robot try again with the "Magic Clipboard," they improved the success rate of the Qwen3.6-27B robot from 66.6% to 71.8%.

This is a significant jump. If they had just used a "cold restart" (starting over with no help), the success rate would have only gone up to 66.8%. This proves that simply stopping isn't enough; you need to preserve the useful parts of the work. The "Magic Clipboard" allowed the robot to recover from mistakes it would have otherwise failed at, without getting stuck in the bad reasoning that caused the mistake.

It Works on Other Robots Too
One of the coolest findings is that this system is very flexible. The FailFast monitor was trained using data from just one type of robot (Qwen3.6-27B), but it worked just as well on three other different types of robots, including one that is a closed, proprietary system (Gemini 3 Flash). This suggests that the "signs of failure" are universal across different AI models, not just specific to one.

Why This Matters

This paper suggests that we don't need to rely on massive, expensive AI models to fix the mistakes of other massive models. A tiny, cheap monitor can save a lot of money and energy by stopping bad runs early. Furthermore, it shows that when an AI fails, it often leaves behind a trail of useful breadcrumbs. Instead of burning that trail down, we can save it and let the AI try again with a fresh perspective, keeping the good parts and dropping the bad ones.

The researchers are careful to note that this was tested in a specific environment (SWE-bench) and might need more work to apply to all types of software tasks. However, the results strongly suggest that "Fail-Fast, Restart-Smart" is a promising way to make AI agents more efficient and effective, turning wasted effort into a second chance at success.

Drowning in papers in your field?

Get daily digests of the most novel papers matching your research keywords — with technical summaries, in your language.

Try Digest →