Facebook has built an artificial intelligence tool to help programmers patch buggy code. It’s called SapFix, and it’s currently being used internally to automatically detect anomalies in code and suggest relevant fixes to coders.

SapFix has already helped the company with shipping more robust code for its Android app. Facebook said at its Scale engineering conference that it will eventually roll out the tool to the developer community.

In the current state, SapFix works on fixing the bugs spotted by Sapienz – Facebook’s intelligent automated software testing tool. However, SapFix will be able to work independently.

SapFix

To fix a bug, it either fully or partly reverts the code that caused it. To handle more complex bugs, it either picks a template from the knowledge base of past, fixes or makes small changes until the bug is fixed. SapFix creates multiple fixes and tests them against three parameters:

Are there compilation errors?

Does the crash persist?

Does the fix introduce new crashes?

Once the tool picks a fix, it sends it to engineers for review and feedback process.

The company said that to its knowledge, this marks the first time that a machine-generated fix — with automated end-to-end testing and repair — has been deployed into a codebase of Facebook’s scale.

The SapFix team is currently working on training the tool to detect crashes before they happen. It said that Sapienz and SapFix both will be released as open sourced tools once the engineering work is complete.

Read next: Trending tools: 10 ways to take advantage of new social media functionalities