International audienceThis paper presents AgLOTOS as an algebraic language dedicated to the specification of agent plans in ambient systems. AgLOTOS offers two levels of plans: elementary plans which are composed to produce an intention plan; The intention plans which are, in turn, composed to build an agent plan. The composition relies on several operators such as alternative and concurrency. Consequently, the plans can be built automatically as a system of concurrent processes. At the execution level, our approach helps the agent to select an optimal plan preserving the consistency of its intentions. The selection is based on an original and formal construction called contextual planning system (CPS), which presents the potential paths with the associated contexts while removing the inconsistent options. Finally, our CPS is improved by using past-experiences for a better guidance of the agent