Incorporating Behavioral Constraints in Online AI Systems

Avinash Balakrishnan, Djallel Bouneffouf, Nicholas Mattei, Francesca Rossi

Abstract

AI systems that learn through reward feedback about the actions they take are increasingly deployed in domains that have significant impact on our daily life. However, in many cases the online rewards should not be the only guiding criteria, as there are additional constraints and/or priorities imposed by regulations, values, preferences, or ethical principles. We detail a novel online agent that learns a set of behavioral constraints by observation and uses these learned constraints as a guide when making decisions in an online setting while still being reactive to reward feedback. To define this agent, we propose to adopt a novel extension to the classical contextual multi-armed bandit setting and we provide a new algorithm called Behavior Constrained Thompson Sampling (BCTS) that allows for online learning while obeying exogenous constraints. Our agent learns a constrained policy that implements the observed behavioral constraints demonstrated by a teacher agent, and then uses this constrained policy to guide the reward-based online exploration and exploitation. We characterize the upper bound on the expected regret of the contextual bandit algorithm that underlies our agent and provide a case study with real world data in two application domains. Our experiments show that the designed agent is able to act within the set of behavior constraints without significantly degrading its overall reward performance.

Introduction

In the field of reinforcement learning and Multi-Armed Bandits (MAB), agents are typically designed to be "reward-hungry," prioritizing actions that yield the highest payoff. However, in sensitive domains such as healthcare or content recommendation, maximizing reward is insufficient. Agents must also respect "exogenous constraints"—rules derived from ethics, laws, or user preferences.

A significant challenge is that these constraints are often implicit and difficult to formalize as a set of logical rules. This paper introduces the Behavior Constrained Contextual Bandits Problem (BCCBP), where an agent must first learn what is "allowed" by observing a teacher and then respect those boundaries while operating in a live, reward-driven environment.

Methodology: Behavior Constrained Thompson Sampling (BCTS)

The proposed solution, Behavior Constrained Thompson Sampling (BCTS), operates in two integrated phases:

  1. Constraint Learning Phase: The agent interacts with a "teacher agent," observing contexts and receiving binary feedback (allowed/not allowed) for its actions. This data is used to build a "constrained policy" ($\mu^e$) that estimates the probability of an action being permissible.
  2. Online Recommendation Phase: During live operation, the agent receives actual rewards. To select an action, it calculates a weighted score for each arm: $$\text{Score} = \sigma_{online} \cdot (\text{Predicted Reward}) + (1 - \sigma_{online}) \cdot (\text{Predicted Constraint Alignment})$$

The parameter $\sigma_{online}$ serves as a tunable trade-off between safety and reward. A value of $0.0$ forces the agent to prioritize learned rules exclusively, while $1.0$ allows it to focus solely on reward maximization. Theoretically, the authors prove that the algorithm's "regret" (the performance gap relative to an optimal policy) grows sub-linearly over time, ensuring long-term convergence.

Experimental Evaluation

The researchers evaluated BCTS on two real-world datasets modified to include behavioral constraints:

  • MovieLens 20m: A recommendation task where synthetic constraints were added based on age and genre (e.g., restricting horror movies for younger audiences).
  • Warfarin Dataset: A healthcare task for determining drug dosages. A "no dose" constraint was added for patients with specific clinical features to simulate safety restrictions.

Results and Discussion

The experimental results confirm that BCTS effectively balances reward performance with constraint adherence.

Performance metrics for BCTS across MovieLens and Warfarin datasets. Top row (a-c) displays Cumulative Average Regret, while the bottom row (d-f) displays Behavioral Error and Cumulative Regret. The results highlight the impact of the trade-off parameter $\sigma_{online}$.

Key Insights

  • Effective Alignment: In the MovieLens task, setting $\sigma_{online} = 0.25$ allowed the agent to achieve near-zero behavioral errors while maintaining high rewards, even outperforming hard-coded "Masked Agents" in some scenarios.
  • Safety in High-Stakes Tasks: In the Warfarin task, the constraints were found to be "orthogonal" to rewards—meaning the highest-reward clinical doses often violated safety rules. BCTS successfully navigated this conflict, maintaining safety with minimal errors (~75 per 1,000 pulls) compared to standard agents.
  • Exploration Strategy: Interestingly, random exploration during the constraint learning phase often outperformed Thompson Sampling. Random sampling provides more uniform coverage of the behavior space, which is essential for identifying the precise boundaries of permissible actions.

Conclusion

BCTS provides a robust framework for deploying AI agents that must adhere to learned ethical or safety boundaries. By providing a tunable "safety vs. greed" knob, the algorithm allows system designers to align agent behavior with human values without sacrificing significant performance. Future work will explore handling dynamic constraints that evolve over time and learning from imperfect or noisy teachers.

Summary updated

Abstract

AI systems that learn through reward feedback about the actions they take are increasingly deployed in domains that have significant impact on our daily life. However, in many cases the online rewards should not be the only guiding criteria, as there are additional constraints and/or priorities imposed by regulations, values, preferences, or ethical principles. We detail a novel online agent that learns a set of behavioral constraints by observation and uses these learned constraints as a guide when making decisions in an online setting while still being reactive to reward feedback. To define this agent, we propose to adopt a novel extension to the classical contextual multi-armed bandit setting and we provide a new algorithm called Behavior Constrained Thompson Sampling (BCTS) that allows for online learning while obeying exogenous constraints. Our agent learns a constrained policy that implements the observed behavioral constraints demonstrated by a teacher agent, and then uses this constrained policy to guide the reward-based online exploration and exploitation. We characterize the upper bound on the expected regret of the contextual bandit algorithm that underlies our agent and provide a case study with real world data in two application domains. Our experiments show that the designed agent is able to act within the set of behavior constraints without significantly degrading its overall reward performance.
BibTeX
@inproceedings{balakrishnan2019incorporating,
  author = {Avinash Balakrishnan and Djallel Bouneffouf and Nicholas Mattei and Francesca Rossi},
  title = {{Incorporating Behavioral Constraints in Online AI Systems}},
  booktitle = {AAAI Conference on Artificial Intelligence},
  year = {2019},
  doi = {10.1609/aaai.v33i01.33013},
}
Figure