AI Safety
New Framework Automates Safety Rules for AI Agents Through Machine Learning
Researchers introduce AutoSpec, a system that evolves safety constraints for language model agents by learning from user feedback and inductive logic programming.
Autonomous AI agents powered by large language models are increasingly trusted with complex tasks, but their ability to act independently creates serious safety challenges. These systems can execute harmful commands, expose confidential information, or ignore critical business rules. Current safeguards struggle with a persistent problem: rigid, human-written rules are easy to understand but inflexible, either blocking legitimate actions or failing to catch dangerous ones.
Researchers have introduced AutoSpec, a system that automatically refines safety rules by learning from examples of safe and unsafe behavior. Rather than relying on static policies or hard-to-interpret neural classifiers, the approach uses inductive logic programming (ILP) to systematically improve expert-authored rules over time.
How AutoSpec Works#
The framework combines two core techniques. It starts with safety rules written by domain experts, then observes a stream of user annotations labeling agent behaviors as safe or unsafe. In each iteration, AutoSpec:
- Evaluates current rules against labeled examples
- Identifies cases where rules fail (false positives that block safe actions, false negatives that miss unsafe ones)
- Uses ILP to find logical conditions that distinguish between these failed cases
- Generates and tests candidate rule revisions
- Selects the best-performing update and repeats
The key innovation is using ILP to intelligently narrow the search space. Rather than exploring all possible rule modifications, ILP highlights predicates—logical conditions—that appear frequently in safety violations but rarely in legitimate behavior (or vice versa), making the search far more efficient.
Performance and Results#
In testing across 291 execution traces from code-execution and robotics domains, AutoSpec achieved F1 scores of 0.98 and 0.93 respectively—a measure of accuracy balancing false alarms against missed detections. The system reduced false positives (incorrect safety blocks) by up to 94% while preserving high recall (catching unsafe actions). The entire refinement process converged in just 4–5 iterations.
When compared to simpler heuristic approaches, the ILP-guided method delivered 4.8 times higher F1 scores, demonstrating the power of structured logical reasoning. Crucially, the resulting rules remained human-readable and auditable—they could be examined and understood by engineers and compliance teams. The learned safety policies also generalized to scenarios unseen during training.

