The paper describes a software architecture for autonomous excavation tasks. For this, it uses a behaviour based approach which allows adaption to the changing environment and unexpected events. Inside of the presented architecture, basic primitives are defined which solve spatially limited motions of the excavator arm. These primitives can be activated as and when required, and it is possible to have multiple of them running in parallel. Normally, an excavation task can be split up in several different phases. In these phases, the primitives will be activated as needed. To be reusable, the primitives are designed in a very general way. Thus, it is possible that the same primitive is used in different phases of the excavation process. Inside of a phase a so called action unit gets active, which contains the actually implementation of the phase and enables the primitives which are necessary to solve the phase target. This makes it also very easy to exchange or adapt a solving strategy for any subtask by using another action unit for one of the phases of the process. Due to the fact that the architecture uses a behaviour based design it is possible that the primitives can influence each other with inhibition and stimulation. Using this, a safety layer is desgined which can block the execution of a primitive to prevent undesired events like hitting obstacles. With this mechanism it is also possible to react on unexpected events and adapt the solving strategy of the current task. Another advantage of the approach is the possibility to easily expand the task. To do this it is possible to use a sequence of phases as an subroutine to solve a bigger task. For example one excavation strategy can be used as an subroutine while digging a trench which also includes the dumping of the soil. To show the performance of the presented architecture, an example application is built up which can be used to dig a trench. This application is implemented on a system running on a real backhoe loader. On this machine, it is demonstrated that the approach can be used to implement a solution which let the used excavator dig a trench in a fully autonomous way. The trenching process uses the phases in a cyclic way which includes the digging and dumping as well as the moving in between of the both.