Multiagent systems for mobile and pervasive computing should extensively exploit contextual information both to adapt to user needs and to enable autonomic behavior. This raises the problem of how to represent, organize, aggregate, and make available such data so as to have it become meaningful and usable knowledge, facilitating the design and development of agents, and enabling them to acquire high-degrees of context awareness at limited efforts. In this paper, we identify the key software engineering challenges introduced by the need of accessing and exploiting huge amount of heterogeneous contextual information. Following, we survey the relevant proposals in the area of context-aware pervasive computing, data mining and granular computing discussing their potentials and limitations. On these bases, we propose the W4 model for contextual data and show how it can represent an effective model to enable flexible general-purpose management of contextual knowledge, to facilitate agents in...