Developer Tools

AI Coding Assistant Now Checks Inputs, Fewer Program Crashes

Your AI-generated software could stop breaking when given bad input.

Deep Dive

When you ask an AI to write code, it usually solves the main problem you describe. But it often forgets to verify that the inputs it receives actually make sense. For example, a function that calculates monthly payments might happily divide by zero if you pass in a loan amount of zero. That leads to crashes, confusing errors, or worse, silently wrong results.

Researchers from three institutions introduced SLICE, a clever way to fix this. Their method reads the original problem description and separates it into two parts: the "what to do" and the "what conditions must be true about the inputs." Then it generates the function's logic first, and adds input-validation checks afterwards. It's like hiring a cashier who not only scans your items but also checks that your payment card isn't expired.

SLICE builds a graph of the problem description to keep track of all the input requirements. This prevents the AI from either accepting bad inputs it should reject, or rejecting good ones it should accept. It generates multiple possible versions of the function, picks the best one, and then attaches the appropriate safety checks. The result is code that is more reliable and less likely to fail in real-world use.

In tests across four different AI models and six competing methods, SLICE improved the number of programs that satisfied both the main task and the input requirements by an average of 6.58%. It's not a perfect fix, but it's a meaningful step toward AI that writes software you can actually trust with your data.

Key Points
  • AI-generated code often forgets to check whether user inputs are valid, causing crashes.
  • SLICE splits the job into separate steps: writing the main logic, then adding input checks.
  • The method improved correctness by 6.58% on average across four AI models and six alternatives.

Why It Matters

As AI writes more of our apps, this means fewer crashes, less debugging, and safer software for everyone.

📬 Get the top 10 AI stories daily