Pervasive computing systems execute in dynamic highly variable environments and need software that are context-aware and can adapt at runtime. Mobile agents are viewed as an enabling technology for building software for such environments due to their flexibility, migratory nature and scalability. This paper presents a novel approach which aims to further enhance this advantage by building compositionally adaptive mobile software agents that are also context-driven, component-based and have the ability to exchange their components with peer agents. We present the formal underpinnings of our approach and a decision making model which assists agent adaptation. We also describe our current implementation and experimental results to evaluate the benefits of the proposed approach.