We describe a multi-threaded declarative agent architecture in which an agent's relationships to other agent's is defined by a set of formal contracts, held inside the agent. Some of these contracts determine services that the agent provides, others are outsourcing contracts for services that other agents provide for it. The contracts are declaratively formalised as event calculus rules. At any time point the state of a contractual relationship is determined by the contract rules and the events that have previously happened pertinent to the contract.
The contracts specify which agents are allowed to notify which events. They also specify conditions under which particular events initiate or terminate an obligation on one the agent parties to the contract. Initiated obligations may have deadlines by which they must be discharged. A contract can also specify conditions under which an agent is considered to have violated the contract with respect to some obligation.
An initiated obligation typically results in the selection and execution of a plan to discharge the obligation. Such a plan may in turn query the agent's other contracts to determine if they can be used to outsource some sub-goal of the plan.
For concreteness we sketch the implementation of the architecture in the multi-threaded OO logic programming language QuP++. We also give the rules for a single agent contract for a patrol robot, and the rules for multi-task service contract between a pair of agents in which tasks have maximum completion times and payments related to completion time.