Brokered multi-agent systems can be incapacitated and rendered non-functional when the brokers become inaccessible due to failures that can occur in any distributed software system. We propose that the theory of teamwork can be used to specify robust brokered architectures that can recover from broker failures, and we present the adaptive agent architecture (AAA) to show the feasibility of this approach. The previous teamwork theory based on joint intentions assumes that team members remain in a team as long as the team exists. We extend this theory to allow dynamic broker teams whose members can change with time. We also introduce a theory of restorative maintenance goals that enables the brokers in an AAA broker team to start new brokers and recruit them to the broker team. As a result, an AAA-based multi-agent system can maintain a specified number of functional brokers in the system despite broker failures, thus effectively becoming a self-healing system.