{'fraction_non_alphanumeric': 0.03458374275090072, 'fraction_numerical': 0.01026915592547637, 'mean_word_length': 4.325672070593064, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 8, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 5, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
Be Considerate: Objectives, Side Effects, and Deciding How to Act

Recent work in AI safety has highlighted that in sequential decision making, objectives are often underspecified or incomplete. This gives discretion to the acting agent to realize the stated objective in ways that may result in undesirable outcomes. We contend that to learn to act safely, a reinforcement learning (RL) agent should include contemplation of the impact of its actions on the wellbeing and agency of others in the environment, including other acting agents and reactive processes. We endow RL agents with the ability to contemplate such impact by augmenting their reward based on expectation of future return by others in the environment, providing different criteria for characterizing impact. We further endow these agents with the ability to differentially factor this impact into their decision making, manifesting behavior that ranges from self-centred to self-less, as demonstrated by experiments in gridworld environments.


Introduction
Robust and reliable sequential decision making, whether it is realized via reinforcement learning (RL), supervised learning, or some form of probabilistic or otherwise symbolic planning using models-relies on the specification of an objective -a reward function to be optimized in the case of RL, or a goal to achieve in the case of symbolic planning. Recent work in AI safety has raised the concern that objective specifications are often underspecified or incomplete, neglecting to take into account potential undesirable (negative) side effects of achievement of the specified objective. As Amodei et al. [2016] explain, " [F]or an agent operating in a large, multifaceted environment, an objective function that focuses on only one aspect of the environment may implicitly express indifference over other aspects of the environment." Russell [2019] cites the example of tasking a robot to get coffee from a coffee shop and the robot, in its singular commitment to achieving the stated objective, killing all those in the coffee shop that stood between it and the purchase of coffee. A more benign example is that of a robot breaking a vase that is on the optimal path between two points [Krakovna et al., 2020b]. A range of recent works have presented computational techniques for avoiding or learning to avoid negative side effects in Markov Decision Processes (MDPs) or related models, including for example [Zhang et al., 2018, Krakovna et al., 2019, Turner et al., 2020b, Krakovna et al., 2020b, Saisubramanian et al., 2020.
Our concern in this paper is with how a Reinforcement Learning (RL) agent can learn to act safely in the face of a potentially incomplete specification of the objective. Is avoiding negative side effects the answer? Amodei et al. observe that "avoiding side effects can be seen as a proxy for the things we really care about: avoiding negative externalities. If everyone likes a side effect, there's no need to avoid it." In the spirit of this observation, we contend that to act safely an agent should contemplate the impact of its actions on the wellbeing and agency of others in the environment, including both other acting agents as well as passive or reactive processes such as climate or waterways. Indeed, what may be construed as a positive effect for one agent may be a negative effect for another.
Here we endow RL agents with the ability to consider in their learning the future welfare and continued agency of those that act or react in the environment. This is in contrast to some recent work on side effects that takes into account only how the agent's actions will affect its own future abilities Krakovna et al. [2019], Turner et al. [2020b], Krakovna et al. [2020b]. We do so by augmenting the RL agent's reward with an auxilliary reward that reflects different functions of expected future return. In its most general case, we make no assumptions about the number of agents that exist in the environment, their actions, or their transition functions. However we show how individual or groups of agents can be distinguished and differentially considered in learning. We further endow these agents with the ability to control the degree to which impact on self versus others factors into their learning, resulting in behavior that ranges from self-centred to self-less. Experiments in gridworld environments illustrate qualitative and quantitative properties of the proposed approach.

Preliminaries
In this section, we review relevant definitions and notation.
RL agents learn policies from experience. When the problem is fully-observable, it's standard to model the environment as a Markov Decision Process (MDP) [Sutton and Barto, 2018]. We describe an MDP as a tuple S, A, T, r, γ where S is a finite set of states, A is a finite set of actions, T (s t+1 |s t , a t ) gives the probability of transitioning to state s t+1 when taking action a t in state s t , r : S × A × S → R is the reward function, and γ is the discount factor. Sometimes an MDP can also include a designated initial state s 0 ∈ S.
When the agent takes an action a t ∈ A in a state s t ∈ S, as result it ends up in a new state s t+1 drawn from the distribution T (s t+1 |s t , a t ), and receives the reward r t+1 = r(s t , a t , s t+1 ). A terminal state in an MDP is a state s which can never be exited -i.e., T (s|s, a) = 1 for every action a -and from which no further reward can be gained -i.e., r(s, a, s) = 0 for every action a.
A policy is a (possibly stochastic) mapping from states to actions. Given a policy π, the value of a state s is the expected return of that state, that is, the expected sum of (discounted) rewards that the agent will get by following the policy π starting in s. That can be expressed using the value function V π , defined as V π (s) = E π ∞ k=0 γ k · r t+k+1 | s t = s where the E π notation means that in the expectation, the action in each state s t , s t+1 , . . . is selected according to the policy π. Note that the discount factor γ determines how much less valuable it is to receive rewards in the future instead of the present. An optimal policy will maximize the value of every state. The optimal value function V * is the value function of an optimal policy.
Similarly to with the value function, a value (called a Q-value) can be associated with a state-action pair: Q π (s, a) = E π ∞ k=0 γ k · r t+k+1 | s t = s, a t = a . Note that here, the first action selected is necessarily a, but the policy π is followed afterwards. The optimal Q-function is the Q-function Q * corresponding to an optimal policy. Note also that given the optimal Q-function Q * , an optimal policy can be recovered as follows: for each state s, choose an action a such that Q * (s, a) is maximized.
In RL, the agent is tasked with trying to maximize reward, but is not given complete knowledge about the environment's dynamics (i.e., the transition function T and reward function R). As a result, the agent has to explore to learn how to get reward. We refer the reader to Sutton and Barto's 2018 textbook for further details on RL, but note that Q-learning [Watkins and Dayan, 1992] is an RL algorithm that learns a policy by learning approximations of the optimal Q-values (without ever learning the transition dynamics).

Approach: Considering others
In Section 1, we suggested that to act safely an acting agent should contemplate the impact of its actions on the welfare and continued agency of those that act or react in the environment. In this section, we present several formulations that address this aspiration. To this end, we conceive an environment which may feature various, potentially un-named, agents. We consider a simplified setting in which we assume that first the acting agent acts in isolation, but after its policy leads to a terminal state, other agents can act. Those others are not learning their behavior; rather, they subscribe to some previously learned or acquired policies or behaviors. We assume the acting agent must learn how to act in consideration of others, but with limited knowledge of others in the environment. In the most general case, the acting agent need not know what agents exist in the environment, nor their objectives, actions or transition systems. Rather we assume a distribution over value functions that serves to capture how the world may purposefully evolve in the future, and we use this as a proxy for evaluating the welfare and continued agency of those that act or react in the environment.
In what follows, we present several different formulations for augmenting the reward accrued by the acting agent, by considering its effect on others in the environment. In all cases, this accrued reward is some function of the distribution over value functions, and we present several formulations that optimize for different criteria. These formulations are consistently paired with "caring" coefficients, hyperparameters that control the degree to which the acting agent factors into its decision making its effect on others versus itself. This enables the agent's decision making to range from selfishoblivious to its impact on others -all the way to selfless, where it subjugates its own reward in service of the welfare of others.
In Section 4 we illustrate qualitative behavior manifest by different argumented rewards, and the quantitative impact of the caring coefficients on agents' reward.

Using information about value functions
We wish to augment our acting (RL) agent's reward with an auxiliary reward that reflects the impact of its choice of actions on future agency and wellbeing of others in the environment. We assume the acting agent has access to a distribution over value functions. In particular, suppose that we have a finite set V of possible value functions V : S → R, and a probability distribution P(V ) over that set. Note that we don't have to commit to how many agents there are (or what their actions are). It could be that each V ∈ V corresponds to a different agent, that the set reflects all possible value functions of a unique agent, or anything in between. Also, each V ∈ V could reflect some aggregation of the value functions of all or some of the agents.
We can then modify the acting agent's reward function r 1 to incorporate an auxiliary reward, yielding the new reward function r value below: Note that using this reward with an RL agent requires being able to identify a terminal state s when the agent's in it.
Caring coefficients: The hyperparameters α 1 and α 2 are real numbers that determine the degree to which the aggregate reward, r value (s, a, s ), is informed by the reward of the acting agent (via α 1 ) and the discounted future return of the environment (via α 2 ). As we will see in Section 4, if α 1 = 1 and α 2 = 0, we just get the original reward function where the acting agent only values its own reward. The agent is oblivious to its impact on others in its environment. If α 1 = 0, then the acting agent entirely ignores any reward it garners directly from its actions.
Note that future activity does not have to start in exactly the same state at which the acting agent ended. V can be defined so that V (s ) gives the expected return of future activity considered over a known distribution of starting states, given that the acting agent ended in s .
Observe that the auxiliary reward, V ∈V P(V ) · V (s ), can be written as a function of the form F (V, P, s ), and can be thought of as assessing how good it is to terminate in s . In formulations that follow, we will simply modify F (V, P, s ) to manifest different reward.
Observe that for some possible reward functions for the acting agent and future value functions, the acting agent may have an incentive to avoid terminating states. The acting agent can avoid or delay the penalty for negative future return by not terminating. This incentive would typically be undesirable. However, it can be shown that under some circumstances, the acting agent's optimal policy will be terminating.
Definition 1 (terminating policy). Given an MDP with terminal states, a policy π is terminating if the probability of eventually reaching a terminal state by following π from any state is 1.
The following proposition and proof are similar to [Illanes et al., 2020, Theorem 1]. Proposition 1. Let M = S, A, T, r 1 , γ be an MDP where γ = 1, the reward function r 1 is negative everywhere, and there exists a terminating policy. Suppose r value is the reward function constructed from r 1 according to Equation 1, using some distribution P(V ). Then any optimal policy for the MDP M = S, A, T, r value , γ with the modified reward will terminate with probability 1.
Proof. Suppose for contradiction that there is an optimal policy π * for M that is non-terminating. Then there is some state s ∈ S so that the probability of reaching a terminal state from s by following π * is some value c < 1. Since rewards are negative everywhere, that means that V π * (s) = −∞. On the other hand, any terminating policy gives a finite value to each state. Since there is a terminating policy for M there is one for M , and so π * cannot be an optimal policy.

Considering the worst case
Rewarding the acting agent based on the expected future return isn't the only option. An alternative is to give the acting agent the "worst case" future return, i.e., the return corresponding to the value function (with non-zero probability) that gives the least value to s , i.e., F (V, P, s ) = min V ∈V:P(V )>0 V (s ), and so Using r worst encourages the acting agent to maximize the worst case future return. This may be desirable for avoiding rare disastrous outcomes.

Avoiding negative change
The augmented reward functions we've considered so far don't just encourage the acting agent to avoid harming others, but they can encourage the acting agent to actively help others. We contrast this with the aspiration of avoiding negative side effects as explored by Krakovna et al. [2019Krakovna et al. [ , 2020b and others. In their work, they investigate various "baselines" against which the effects of the acting agent's actions can be compared.
Here we just consider one of the simplest baselines -a comparison with the initial state. Suppose that there is a unique initial state s 0 . We propose augmenting the acting agent's reward function with F (V, P, s ) = V ∈V P(V ) · min(V (s ), V (s 0 )). The ideas is to decrease the acting agent's reward when it decreases the expected future return, but to not increase the acting agent's reward for increasing that same expected return. Formally, the modified reward function would be To interpret this, suppose that α 2 > 0. Note that the auxiliary reward in a terminal state s depends on min(V (s ), V (s 0 )) for each value function V (that has positive probability). So if V (s ) < V (s 0 ), that decreases the acting agent's reward, but if V (s ) > V (s 0 ), that is no better for the acting agent than if V (s ) = V (s 0 ). Intuitively, this seems related to the idea of avoiding negative side effects (though the optimal solution for the acting agent might still involve causing negative side effects and doing just enough good to counterbalance them).

Treating agents differently
To this point, we've utilized a distribution over value functions to capture the expected return on future behavior within the environment. The distribution has made no commitments to the existence of individual agents, their actions or transition functions. Here we assume that we additionally have indices, i = 1, . . . , n, corresponding to different agents (we will assume the acting agent is agent 1).
Furthermore, for each agent i, we suppose we have a finite set of possible value functions {V is the real value function for agent i. We could then have a separate caring coefficient α i for each agent i, and define the following reward function for the acting agent: Considering individual agents raises the possibility of giving the acting agent reward at the end based not on the expected sum of returns of the other agents (which was what we just saw above), but by incorporating some notion of "fairness". For example, we could consider the expected return of the agent who would be worst-off.
This is inspired by the maximin (or "Rawlsian") social welfare function, which measures social welfare in terms of the utility of the worst-off agent [see, e.g., Sen, 1974].
Using information about options: Another related formulation that we have explored is to use preexisting options [Sutton et al., 1999], with or alternatively without associated value functions, to capture skills or capabilities that reflect the purposeful agency of other agents. The initiation sets of options then become desirable terminating states for the acting agent's optimization, to ensure that all options remain executable and thus skills and capabilities in the environment remain executable, or to additionally maximize their return. Further discussion of options in this context can be found in the supplementary material.

Agents acting simultaneously
To this point, the acting agent has been contemplating the impact of its actions on the ability of (other) agents to act in the future, following completion of its policy. Clearly there is also utility in considering the case where multiple agents co-exist in the environment simultaneously. On the one hand, the actions of other agents resulting from execution of their fixed policies could affect the state of the world, effectively making the environment more stochastic from the perspective of the acting agent. Further, the acting agent that is caring may wish to contemplate the impact of its actions on these acting agents during execution of its policy. For example, in our Craft environment, if the acting agent takes a tool from the toolshed and carries it around for its entire shift, even though it long ago ceased to need the tool, then this delays or precludes other agents who might need the tool from completing their tasks until after the acting agent is done. In the formulation that follows, we endow the acting agent with the ability to consider the impact of its actions on other agents during the execution of its policy, rather than in the future, and to factor this into policy construction. In so doing, a caring agent should trade off the ease of keeping the tool from the effort to return it so that it's available for other agents that might wish to use it. We once again use the set up where the acting agent is constructing a policy but other agents are assumed to be executing fixed policies.
One way to extend our models to handle this case is as follows. Instead of assuming a distribution over value functions, we will assume a distribution over reward functions. In particular, for each agent i, we have a set of possible reward functions r (i) j and a probability distribution P(r ij ) which indicates the likelihood that r (i) j is the real reward function for agent i. In addition, we assume that each agent (other than the first, or as we have been calling it, acting agent) follows a fixed policy to ensure that the overall problem is Markovian. With that, we can give the acting agent a fraction of the expected reward that the other agents are believed to have received: If we consider that the acting agent keeps receiving reward until all agents reach a terminal state, then this model can be also used for solving the sequential case. The main difference is that in this formulation, there is an assumption of access to reward functions whereas the previous formulations in this section assumed access to value functions.

Experiments
In the previous section we presented different formulations of reward functions that allow RL agents to contemplate the impact of their actions on the welfare and agency of others. Here, we present quantitative and qualitative results relating to these formulations. In Section 4.1, we show how changes to the caring coefficient manifest in the policies of the acting agent. In Section 4.2 we showcase how these different formulations impact the agent's behavior towards helping others. Finally in Section 3.3, we provide qualitative results for the synchronous case where an acting agent that is contemplating others in the environment will modify its policy to address the impact on and from other agents as it learns its policy.
Craft-World Environment: To evaluate and showcase concepts introduced in this paper, we consider a Minecraft TM inspired gridworld 1 environment depicted in Figure 1a. Agents in this environment use tools such as axes and hammers, and materials such as wood and nails, to construct artifacts such as boxes or bird houses. Tools are stored in a toolshed in the upper right corner of the grid environment. Agents enter and exit the environment through doors in the upper left and lower right. They must collect materials from the appropriate locations and bring them to the factory for construction and assembly. The factory requires a key for entry, and there is only one key, which can be stored in only two locations (denoted by K). When considering other agents, the acting agent may elect to place the key in a position that is convenient for others, or may help other agents by anticipating their need for tools or resources and collect them on their behalf.

Quantitative experiments: Varying the caring coefficient
In this experiment, we investigate the effect of choosing different caring coefficients (α 1 and α 2 ) by monitoring the average reward collected by each of the agents in the Craft-World Environment. The experimental setup is as follows. Two agents enter the environment through the top-left door, shown in Figure 1a. Both agents want to solve the same task, which is to make a box. To do so, they need to collect wood, the hammer, and the key to enter the factory and make the box. Before exiting the environment, the agent can decide whether to leave the key in one of the designed locations (marked with the letter K in Figure 1a) or to exit while holding the key, which would prevent the next agent from solving the task. It is also possible for the first agent to carry extra wood and an extra hammer, and leave them at the factory, so the next agent can directly go to the factory (after getting the key) and make its box. The agents always get a reward of −1 and an extra −12 for leaving extra wood at the factory. In addition, the agents cannot exit the environment until they have made a box.
Both agents learn their policies using Q-learning. The first (caring) agent uses the reward function from (1). Recall that, once the caring agent exits the environment, Equation 1 rewards it by α 2 · V (s ), where V (s ) is the value function of the second agent when it enters the environment. The second agent only optimizes its own reward. Figure 1b shows the reward that each agent gets (after training) as we vary the caring coefficient α 2 . First, note that when α 2 = 0, the first agent is oblivious to the others and exits the environment without returning the key. When α 2 > 0, the agent becomes more considerate and returns the key on its way to the exit. Note that the caring agent helps others to different degrees as we increase the value of α 2 , moving from making small compromises such as returning the key to big sacrifices such as carrying extra materials to the factory and leaving the key close to the door where the next agent will enter.
We have observed the same trend as we vary the caring coefficients under the different formulations described in this paper. When the caring coefficient increases, the total reward that the acting agent gets stays the same or decreases while the reward obtained by the other agents stays the same or increases due to the help provided by the caring agent. There is also a middle value for α where the sum of rewards obtained by all the agents is maximized (as shown by the green line in Figure 1b). By setting α 2 > 0, the agent changes its behaviour with no cost or little cost and this is significantly beneficial for the next agent. However, by increasing α 2 further, first agent makes big sacrifices to help the next agent with its task, while the next agent can do it with an equal or lesser amount of cost.

Qualitative illustrations of optimal behaviours under different notions of safety
In this section we give some qualitative illustrations of how some of the reward functions we've proposed, and the choice of caring coefficients, lead to different behaviours. Figures 2a and 2b show a case concept to illustrate the difference of treating agents differently through the choice of caring coefficients when using the modified reward in Equation 4. There are 3 agents that want to get to the exit from the starting point, they get -1 reward in each time step. Agent 2 has a garden on the shortest path and gets very upset (-20 reward) if someone passes through the garden. The acting agent (agent 1) cares about agent 3 and itself in an equal amount (α 1 = α 3 = 1). In the first case we consider, agent 1 is oblivious to agent 2 (α 2 = 0) and follows the shortest path to the exit, passing through the garden (the red path in the figure). In the second case, agent 1 cares about agent 2 a little (α 2 = 1) and took the longer (blue) path to avoid passing through the garden. These two policies are shown in Figure 2a. In the third case, agent 1 cares about agent 2 a lot (α 2 = 10) and even though there is a cost of -50, agent 1 builds a fence to protect agent 2's garden, and makes agent 3 takes the longer path with an extra cost ( Figure 2b).
Moreover, Figure 2c illustrates the difference between Equations (1), (2) and (3). The goal of the agents is to play with the doll and leave it somewhere in the environment for the next agent; the agents get -1 reward for each time step. The agents are shown at their individual entry points, and the acting agent is agent 1. In this scenario, α 1 = 1, and α 2 = 10. If we modify the acting agent's reward according to Equation 1, the policy is to put the doll to be closer to most of the agents (red line). If we use Equation 2 the policy is to put it so as to minimize the distance to the furthest agent (blue line), and if we use Equation 3 the policy is to leave the doll where it is (green line), as moving it causes negative side effects for agent 6.
(a) (b) (c) Figure 2: Example behaviours that arise as different notions of safety and caring for others are used.

Experiments: Agents acting simultaneously
We ran experiments on the Craft World -described in Section 4.1 -but allowing both agents to execute actions simultaneously. We used the same map from Figure 1a, but removed the option of carrying extra wood or an extra hammer to reduce the state space (which grows considerably when there are two agents acting in the environment). Both agents start at the top-left corner and their goal is to make a box and then exit the environment. To do so, they have to get a hammer, wood, and the key, and then go to the factory to make the box. There is only one key in the environment, which is initially located at the marked location 'K' near the entrance. Since there is only one key, both agents have to cooperate (i.e., use the key and then return it) for the other agent to solve its task.
Our formulation for the simultaneous case considers that the second agent follows a fixed policy. In this experiment, the second agent's policy is as follows. If the agent does not have a box, then it will try to get the key (if available), the hammer, or wood (in that priority order). If the agent does not have a box but it has the key, the hammer, and wood, it will go to the factory to make a box. If the agent has a box and the key, it will leave the key at the 'K' location near the bottom right corner. If the agent has a box and does not have the key, it will exit the environment. Finally, if the agent needs the key but the key is not available (after collecting wood and the hammer), then the agent will go to the 'K' location near the bottom right corner and wait there until the caring agent returns the key. Table 1 shows the rewards that both agents get (after training) when α 1 = 1.0 and α 2 varies from 0 to infinity. There are three scenarios in this experiment. When α 2 ∈ [0, 0.01), the (as we have been calling it) acting agent -here, the 'caring' or 'first' agent -converges to a selfish policy where it exits the environment without returning the key. Note that this gives a -100 reward to the second agent since it cannot complete its task without the key. When α 2 ∈ (0.01, 1), the acting agent decides to pay an extra −1 penalty for returning the key on its way to the exit since doing so allows the second agent to complete its task. Finally, when α 2 > 1, the acting agent lets the second agent pick up the key first and patiently waits until the second agent returns the key before making its own box and exiting the environment. (The identification of 0.01 and 1 as values of α 2 where the transition between optimal policies occurred was calculated manually.) α 2 Acting agent Second agent Total reward 0.00 ≤ α 2 < 0.01 −24 −123 −147 0.01 < α 2 < 1.00 −25 −33 −58 α 2 > 1.00 −33 −25 −58 Table 1: Results on the Craft World for the simultaneous case when α 1 = 1 and α 2 varies.

Related Work
The work presented here is related to several bodies of work in the literature, including work on AI safety and (negative) side effects, work on empathetic planning, work on cooperative AI, and work on multi-agent reinforcement learning. We discuss select related work here, beginning with a discussion of related recent work on side effects.
[2019] considered a number of approaches to avoiding side effects in which the agent's reward function r(s t , a t , s t+1 ) is modified to include a penalty for impacting the environment, so that the new reward function is of the form r(s t , a t , s t+1 ) − β · d(s t+1 , s t+1 ) where β is a hyperparameter (indicating how important the penalty is), d(·, ·) is a "deviation" measure, and s t+1 is a "baseline" state to compare against. They considered several possible baseline states: the initial state, the state resulting from performing no-op actions from the initial state, or the state resulting from performing a no-op action in s t . They also considered a number of deviation measures, and in particular, they proposed a relative reachability deviation measure d RR (s t , s t ), which measures the average reduction in reachability (by the acting agent) of states in s t compared to the baseline s t .
In follow-up related work, Krakovna et al. [2020b] proposed modifying the agent's reward function to add an auxiliary reward based on its own ability to complete possible future tasks. A "task" corresponds to a reward function which gives reward of 1 for reaching a certain goal state, and 0 otherwise. In their simplest definition, the auxiliary reward was i is the optimal value function for task i (when completed by the single agent itself), and β is a hyperparameter which determines the how much weight is given to future tasks. They interpret 1 − γ (where γ is the discount factor) as the probability that agent will terminate its current task and switch to working on the future task, which leads to the (1 − γ) factor in the case where s is not a terminal state. This is a bit different from the two-stage process we've considered, where the first agent runs until it reaches a terminal state. However, note that in the case where the discount factor is 1, then the auxiliary reward is only added to terminal states, and so the modified reward function is a special case of (the undiscounted version of) one of the rewards we've considered. For Krakovna et al. the value functions are restricted to be possible value functions for the agent itself (and so depend on what actions the agent itself can perform). In contrast, in our approach, we consider value functions that may belong to different agents with different abilities. Additionally, they assume the value functions are optimal. The paper also introduced a more complicated auxiliary reward which compares against what tasks could have been completed had a baseline policy been followed in the past.
Attainable Utility Preservation (AUP) [Turner et al., 2020b,a] is another similar approach to side effects. The agent's reward is modified, given a set R of other reward functions, to penalize actions that change the agent's own ability to optimize for the functions in R. By using a set R of randomly selected reward functions, Turner et al. [2020b] were able to have an agent avoid side effects in some simple problems. Later, Turner et al. [2020a] considered using AUP with just a single reward function (computed using an autoencoder), and showed that that worked well in avoiding side effects in the more complicated SafeLife environment [Wainwright and Eckersley, 2020].
Also related to our work is recent work that aspires to build agents that act empathetically in the environment to explain, recognize or act to assist others (e.g., [Shvo, 2019, Shvo and McIlraith, 2019, Freedman et al., 2020, Shvo et al., 2020), but this body of work assumes the existence of a model. In the context of RL, Bussmann et al. [2019] proposed "Empathetic Q-learning", an RL algorithm which learns not just the agent's Q-function, but an additional Q-function, Q emp , which gives a weighted sum of the agent's value from taking an action, and the value that another agent will get. By taking actions to maximize the Q emp -value, the first agent may be able to avoid some side effects that involve harming the other agent. The value the other agent will get is approximated by considering what reward the first agent would get, if their positions were swapped. Note that the approach assumes that the agent being "empathized" with gets at least some of the same rewards. Du et al. [2020] considered the problem of having an AI assist a human in achieving a goal. They proposed an auxiliary reward based on (an estimate of) the human's empowerment in a state. Empowerment in an information-theoretic quantity that measures ability to control the state. They found that in some cases having an agent tried to maximize (approximate) empowerment outperformed methods that tried to infer what the human's goal was and help with that.
Another large area of research, that we will not attempt to review here, but that shares important motivation with our work is the body of work on cooperative multi-agent systems. A recent publications that elaborates on the importance of this area of research in the context of safe AI is [Dafoe et al., 2021]. Similarly, the growing research on multi-agent reinforcement learning (MARL), in which multiple artificial agents learn how to act together [see, e.g., the surveys by Zhang et al., 2021, Busoniu et al., 2008 broadly shares motivation with our work. A critical distinction is that while MARL is related in the sense that we are doing RL in a the presence of multiple agents, here only the acting agent is engaged in RL, while other agents are assumed to be following existing policies and are therefore not engaged in learning.

Concluding Remarks
We suggest that to act safely, an RL agent should contemplate the impact of its actions on the welfare and continued agency of others as well as itself. In this work, we examine how an RL agent can learn a policy that is informed by the impact of its actions on the wellbeing and future agency of others in the environment, including other acting agents and reactive processes operating under fixed policies.
To this end, we endow RL agents with the ability to contemplate such impact by augmenting their reward based on alternative functions of a distribution over value functions in the environment. We propose formulations alternatively using functions of expected average or worst case future return of a state. We also consider only incorporating expected negative change in the future return. Further variants include replacing the distribution over value functions by options, and considering agents that act simultaneously. These formulations are paired with a caring coefficient, hyperparameters that control the degree to which the effect on others and on itself inform policy construction. In its most general case, we allow for environments that make no assumption about the number of agents in the environment, their actions, or their transition functions. We specialize our formulations to show how individual or groups of agents can be distinguished, and treated differentially, thus opening the door to decision making that addresses mathematical fairness criteria, though we do not explore this in great measure here. We conduct experiments in Gridworld environments that serve to illustrate qualitative behavior manifested by different augmented reward formulations, and the quantitative impact of the caring coefficient on all agents. Enabling an RL agent to contemplate the impact of its actions on others, and to incorporate this into its learning, is an important capability for RL agents that aspire to operating safely. This paper makes progress towards realizing this important aspiration.

Limitations
In pursuing this work, our purpose was not to contemplate multi-agent reinforcement learning, but rather to endow the RL agent with the ability to imagine how the policy it was learning in a solo environment might affect the future wellbeing and agency of other potentially un-identified agents that might have cause to act in the environment after the agent. This was realized by contemplating how the RL agent's terminated policy would affect future agents. A limitation is that the real world does not, in general, follow this simplified two-stage sequential process, in which agents complete policies in succession. (Some circumstances, like a household robot operating while the residents are away, may be reasonably approximated by it.) Another limitation is that, as previously noted, in some cases our augmented reward functions can introduce a (probably undesirable) incentive for the acting agent to never reach a terminal state, to avoid being penalized for what effect its actions have had on others.
A further limitation is that we have not attempted to address the issue of how to acquire, represent, or perform computations with a realistic distribution over value functions, options, or reward functions.
Finally, a general problem when dealing with the utilities of different agents is that different agents may gain rewards at very different scales. This is a classic philosophical problem, which has also been noted in the context of AI safety [Russell, 2019]. One might try to normalize the values by setting the caring coefficients, but in general it may be difficult to determine appropriate values for them.

Societal Impact
Incompletely specified objectives will endure for at least as long as humans have a hand in objective specifications, continuing to present threats to AI acting safely (e.g., [Amodei et al., 2016]). We have suggested that acting safely should include contemplation of the impact of an agent's actions on the wellbeing and agency of others in the environment (including, importantly passive or reactive systems in the environment such as climate and waterways). This endeavor is motivated by the greater aspiration of contributing to our collecive understanding of how to build AI that is safe -an aspiration rooted in benefiting society. Nevertheless, like so many AI advances, there are potential malicious or unintended uses of the ideas presented here. In particular, in the same way that the caring coefficient can be set to attend to and to help others, it could be set to attempt to effect change that purposefully diminishes others' wellbeing and/or agency. The caring coefficient also raises the possibility for differential treatment of agents, which presents opportunities to systematize notions of fair (and unfair) decision making, as briefly noted in Section 3. Claims relating to fairness suffer from all the issues that plague this nascent field of study including the limitations of current mathematical metrics for quantifying fairness. Again, the same techniques that have the potential to systematize fair decision making can equally be used to systematize unfair decision making.
As noted in the limitations section, our approach, by design, assumes the acting agent has limited information about the environment or the behaviors of other agents. As such we are using a distribution over value functions as a proxy for future behavior. We are assuming that we could acquire this from watching the environment, from familiarizing ourselves with the environment over time, by simulation, or by crowdsourcing. If we get it wrong we may believe we have a policy that will sustain or enhance wellbeing when it does not. Like all AI systems, we are only as good as the data or models we use to build them.
Finally, our intention is to endow RL agents with the ability to assess and control their impact on others. A further safeguard for this could be to develop a policy using the approaches presented here and then to evaluate it via simulation, varying the environment in a manner that draws on techniques from code testing and software verification. This is not foolproof, but provides another level of safeguarding of resultant policies, akin to techniques used in safety-critical systems. 1999]. The idea is that an agent can follow an option by starting from a state in its initiation set I and following the policy π until it terminates. Options provide a form of macro action that can be used as a temporally abstracted building block in the construction of policies. Options are often used in Hierarchical RL: an agent can learn a policy to choose options to execute instead of actions. Here we will use options to represent skills or tasks that other agents in the environment may wish to perform.

A.1 Formulation
Suppose we have a set O of initiation sets of options, and a probability function P(I) giving the probability that I is the initiation set of the option whose execution will be attempted after the acting agent reaches a terminating state. To try to make the acting agent act so as to allow the execution of that option, we can modify the acting agent's reward function r 1 , yielding the new reward function r option below: where I I : S → {0, 1} is the indicator function for I as a subset of S, i.e., I I (s) = 1 if s ∈ I 0 otherwise .
Note that if O is finite and P is a uniform distribution, then the auxiliary reward given by r option will be proportional to how many options in O can be started in the terminal state. Also note that if O represents a set of options that could have been initiated in the start state of the acting agent, we can interpret r option as encouraging preservation of the capabilities of other agents, which is more related to the idea of side effects.
The hyperparameters α 1 and α 2 determine how much weight is given to the original reward function and to the ability to initiate the option. Given a fixed value of α 1 (and ignoring the discount factor), the parameter α 2 could be understood as a "budget", indicating how much negative reward the acting agent is willing to endure in order to let the option get executed.
Following similar approaches to those used in Section 3, we could consider variants of this approach that further distinguish options with respect to the agent(s) that can realize them, or by specific properties of the options, such as what skill they realize, and we can use such properties to determine how each α is weighted. For example, perhaps the acting agent could negatively weight options which terminate in states that the acting agent doesn't like. To illustrate, imagine that the option's execution involves a deer eating the plants in the vegetable garden. The acting agent might want to prevent that option from being executed by building a fence.
Finally, if we had a distribution over pairs I, V -consisting of an option's initiation set and a value function associated with that option -then yet another possible reward function is This is much like r option but has an extra factor of V (s ) in the sum in the second case.

A.2 Experiments
We give a qualitative illustration of the reward function in Equation 7 and investigate the behavior of the acting agent by fixing α 1 and changing α 2 . Figure 3 depicts a grid-world environment composed of a small mail room in the lower right corner (depicted by the pile of packages), two designated rooms: Room 1 and Room 2, and a Common Area. The mail room requires a key to open it. The key has to be stored at a 'K' location.
In addition to the acting agent, there are 5 other agents (A,B,C,D,E) that may use the environment in the future. The acting agent has access to all areas of the grid, but the other agents' access is restricted. Room 1 is only accessible to agents C and D, while Room 2 is accessible to agents A,B,C and D, but not E. All agents can access the Common Area. Agents A,B,C,D, and E all have options that enable them to collect a package from the mail room, but because the key can only be stored in one of the three designated 'K' locations, the initiation sets for agents' options differ, based on their personal room access.
The acting agent (not depicted) aims to pick up the key, collect a package, and place the key at one of the 'K' locations. It realizes a reward of -1 at each time step. Since agents A,B,C,D, and E all need the key to execute their option, but are restricted in their access to certain rooms where the key could be stored, the acting agent will differ in its behavior depending on how much it is willing to inconvenience itself (incur -1 for each step) to leave the key in a location that is accessible to other agents.
The coloured lines in Figure 3 denote the different policies learned by the acting agent under different settings of α 2 with fixed α 1 = 1. The distribution over initiation sets of options, P(I), is set to a uniform distribution. By setting α 1 = α 2 = 1 the acting agent puts the key in Room 1 as this is the closest place to leave the key (grey + red policy). Recall that Room 1 is only accessible to agents C and D (40% of the agents). When α 2 is changed such that α 2 = 5, the acting agent cares more about the other agents and puts the key at the 'K' location in Room 2 where 80% of the possible future agents can execute their option (grey + blue policy), and by setting α 2 = 25 the acting agent incurs some personal hardship and puts the key at the far-away 'K' location in the Common Area, so that all the agent can execute their options (grey + green policy). B Relation to avoiding side effects [Krakovna et al., 2020b] In this appendix we consider the relation of some of our formulations from the body of the paper to the "future task" approach to avoiding side effects from Krakovna et al. [2020a], which we already introduced in the related work section, in more detail.
Recall that Krakovna et al. [2020b] proposed modifying the agent's reward function to add an auxiliary reward based on its own ability to complete possible future tasks. A "task" corresponds to a reward function which gives reward of 1 for reaching a certain goal state, and 0 otherwise. In their simplest definition (not incorporating a baseline), the modified reward function was r K (s, a, s ) = r 1 (s, a, s ) + r aux (s ) where r 1 is the original reward function 2 and Putting that together, the modified reward function is In the case where γ (the discount factor) is 1, that simplifies to r K (s, a, s ) = r 1 (s, a, s ) if s is not terminal r 1 (s, a, s ) + β i F (i)V * i (s ) if s is terminal Meanwhile, our Equation 1, in the case where γ = 1, can be rewritten as Observe that if γ = 1, α 1 = 1, α 2 = β, and P(V ) = {F (i) | V * i = V } then r K = r value . So in the undiscounted setting r K is a special case of r value (this was already briefly alluded to in the related work section).

B.1 Relationship to baselines
In [Krakovna et al., 2020b]'s more complicated version of the augmented reward function, the auxiliary reward depends on a "baseline" state s t : Their definition of V * i (s , s t ) is somewhat complicated, but (as they note) when the environment is deterministic it is equal to min(V * i (s ), V * i (s t )). Recall that our Equation 3 was r neg (s, a, s ) =    α 1 · r 1 (s, a, s ) if s is not terminal α 1 · r 1 (s, a, s ) + γ · α 2 · V ∈V P(V ) · min(V (s ), V (s 0 )) if s is terminal So, if γ = 1, α 1 = 1, α 2 = β, P(V ) = {F (i) | V * i = V }, and the environment is deterministic, r neg is equal to [Krakovna et al., 2020b]'s modified reward function with a starting state baseline. Krakovna et al. [2020b] actually used a more complicated baseline. Krakovna et al. [2019] considered several different baselines including a "starting state baseline", but they defined augmented rewards somewhat differently. We leave it to future work to incorporate other baselines into our approach.

B.2 Considering different agents
Recall that in Equation 4 we introduced r value , an augmented reward function which considered the possible value functions of different agents: r value (s, a, s ) =    α 1 · r 1 (s, a, s ) if s is not terminal α 1 · r 1 (s, a, s ) + γ This formulation can be compared to the reward r K from Krakovna et al. [2020a] in a different way.
Consider the case where γ = 1, α 1 = 1, and α i = 0 for i > 1 (so only the first agent's future reward is considered -all other agents are ignored). We can then simplify the equation to r value (s, a, s ) = r 1 (s, a, s ) if s is not terminal r 1 (s, a, s ) + j P(V 1j ) · V Observe that this is equal to r K (s, a, s ) where β = 1 (and γ = 1 again) with an appropriate choice of the distributions F and P (e.g., V (1) i = V * i and F (i) = P(V 1i ) for each i).

C Experimental details
In this section, we describe the technical details of experiments. All environments are deterministic, and models are trained using Q-Learning and the -greedy algorithm is used to balance between exploration and exploitation. Experiments are all done on an AMD Ryzen Threadripper 2990WX with 128 GB of RAM, and the training time is measured on the same machine. Each experiment is repeated 10 times. In all the experiments α 1 = 1, γ = 1 and the learning rate = 1. Table 2 provides details of our set up. The top three entries pertain to the four experiments relating to formulations in the main body of the paper. The fourth entry refers to the options formulation in Appendix A and the final entry refers to the the experiment for the simultaneous formulation, Table 1 in subsection 4.3. Our set up for all of our experiments assumes that agents, other than the acting agent, are executing fixed policies (resp. options). In the simultaneous case this policy was given a priori. In the options case, the actual option policies did not need to be defined and we simply encoded the initiation sets for each of those options. In all other cases, the fixed policies of the "other agents" were learned. As such in Table 2, where relevant, the column describing Training Steps distinguishes between the training steps for "acting agent" and "others". The training steps for "others" (the other agents) is done in advance of training the acting agent and serves to establish the fixed policies of those agents and to populate our distribution of value functions. The training steps for the acting agent reflects the training steps for our approach. For the first experiment (Figure 1b 3 × 2 × 10 5 (acting agent), 3 × 10 5 (others) 14.02 ± 0.12 Figure 2c 0.2 3 × 2 × 10 5 (acting agent), 9 × 10 5 (others) 23.16 ± 0.09