Service-based systems have many applications, such as collaborative research and development, e-business, health care, environmental control, military applications, and homeland security. In dynamic service-oriented computing environment, situation awareness (SAW) is needed for system monitoring, adaptive service coordination and flexible security policy enforcement. Furthermore, various application software systems in such environments often need to reuse situational information for providing better quality of service. Hence, to greatly reduce the development effort of situation-aware application software in service-based systems as well as supporting runtime system adaptation, it is necessary to automate the development of reusable and autonomous software components, called SAW agents, for context acquisition, situation analysis and reactive behavior of the systems. In this paper, an automated agent synthesis approach for SAW in service-based systems is presented. This approach is based on AS calculus and logic, and our declarative model for SAW