AgentSpeak(L) was originally proposed by Rao [Rao, 1996] as a programming language for BDI agents, with an elegant notation based on logic programming. It was inspired by the PRS architecture (Georgeff & Lansky), dMARS (Kinny), and BDI Logics (Rao & Georgeff), and was conceived as an abstract programming language aimed at theoretical results — bridging the gap between BDI specification logics (complex, hard to compute) and implemented BDI systems (which used the three attitudes as data structures).
An AgentSpeak plan has the general structure:
triggering event : context <- body.
Plans are context-sensitive, event-invoked recipes that allow hierarchical decomposition of goals as well as execution of actions — syntactically similar to definite clauses of logic programming, but different in behaviour. At run time, an agent consists of a set of beliefs, a set of plans, a set of intentions, a set of events, a set of actions, and a set of selection functions; the interpreter’s operational semantics was formalized as a labelled transition system, giving the language a proof theory directly related to its execution.
Jason is a BDI agent programming language and platform implementing the operational semantics of a variant of AgentSpeak(L) — a Java-based interpreter, nowadays one of the most used agent programming technologies. It has various extensions aimed at making it a more practical programming language (definition of the MAS, communication, customisation hooks), and is highly customised to simplify extension and experimentation. The reference monograph is Bordini, Hübner and Wooldridge, Programming Multi-Agent Systems in AgentSpeak Using Jason (Wiley, 2007).
The main runtime structures: a belief base (where beliefs are stored), a set of events (to keep track of events the agent will have to handle), a plan library (all plans currently known by the agent), and a set of intentions (each intention keeps track of the goals the agent is committed to and the courses of action it chose, for one of various foci of attention).
The Jason interpreter’s basic reasoning cycle:
Beliefs are represented by annotated literals of first-order logic: functor(term1,…,termn)[annot1,…,annotm]. Beliefs are updated by perception (source(percept)), by intention (the operators + and - add/remove mental notes with source(self)), and by communication (a tell message adds a belief annotated with the sender, e.g. .send(tom,tell,lier(alice))).
Goals have the same syntax as beliefs but are prefixed by ! (achievement goal: goal to do) or ? (test goal: goal to know); they can be added by intentions, or by communication (achieve, askOne/askAll messages). Triggering events happen as consequences of changes in beliefs or goals: +b, -b, +!g, -!g, +?g, -?g.
Plan bodies may contain belief operators (+, -, -+), goal operators (!, ?, !!), internal actions (jia.get(X)), constraints, and external actions (close(door)). Internal actions do not change the environment — they are code executed as part of the agent reasoning cycle, used to invoke legacy code elegantly; standard ones include .print, .send, .my_name, .intend, .drop_intention.
Failure handling is first-class: plans can react to goal failure events (e.g. -!g : true <- !g. retries a goal), and meta-programming allows an agent to ask for plans on demand (askHow) and add them dynamically — plan failure is an event like any other, which is exactly what makes BDI programming robust in dynamic environments.
Agent-oriented programming was originally proposed by Shoham [Shoham, 1993] as a new computational framework — a specialization of object-oriented programming — based on the use of mentalistic notions and a societal view of computation (anthropomorphism), in line with the Knowledge Level philosophy. The state of an agent consists of components such as beliefs, decisions, capabilities, and obligations; for this reason it is called its mental state, described formally in an extension of standard epistemic logics (temporalized knowledge/belief operators, plus operators for obligation, decision and capability). Agents are controlled by agent programs that include primitives for communicating with other agents: in the spirit of speech act theory, each communication primitive is of a certain type — informing, requesting, offering, and so on.
Programming languages for agents have developed a lot since then, but still do not constitute a fully mature paradigm; most of them are based on the BDI model/architecture and reactive planning. Examples of agent and MAS technologies: JADE, Jason, GOAL, 2APL, SARL, JaCaMo; historical languages include Agent0, AgentSpeak(L), MetateM, 3APL, Golog.
Multi-agent programming (MAP) extends AOP from the single agent to the MAS perspective: communication, coordination and organisation. Programming a MAS means programming along multiple dimensions, each with its own data structures and programming instructions:
Multi-agent oriented programming (MAOP) exploits multiple dimensions in modelling complex systems and designing multi-agent systems [BBHR]: the agent, environment and organisation dimensions as first-class, integrated programming abstractions — the subject of Section 9 with JaCaMo.
The environment is intrinsically related to the notions of agent and multi-agent system (an agent is situated in an environment). Environment programming accounts for conceiving the computational environment where agents are situated as a first-class abstraction for programming MAS — a part of the system that can be designed and programmed, aside from agents, to encapsulate functionalities exploited by agents at runtime [Ricci, Piunti, Viroli 2011]. This improves modularity, extensibility and reusability of the MAS as a software system. The A&A (Agents & Artifacts) meta-model [Omicini, Ricci, Viroli 2008] makes the environment first-class:
A basic taxonomy of artifacts:
CArtAgO (Common ARtifact infrastructure for AGent Open environments) is the computational framework/infrastructure to implement and run artifact-based environments: a Java-based programming model for defining artifacts, a set of basic APIs for agent platforms to work within artifact-based environments, distributed and open MAS support (workspaces distributed on Internet nodes, Role-Based Access Control), and open-source technology.
The interaction model:
Each workspace contains by default a predefined set of artifacts: the workspace artifact (makeArtifact, lookupArtifact, focus, security), the node artifact (createWorkspace, joinWorkspace), a console (println), a blackboard/tuple space (out, in, rd), and more — a pre-defined repertoire of actions available to every agent.
The example shows the pattern: an @OPERATION annotated method updates an observable property and emits a signal; a user agent creates and uses the artifact, while observer agents focus it and react to property changes (+count(V)) and signals (+tick). Long-term operations with await/guards support coordination artifacts like a bounded buffer, and internal operations implement controllable processes such as a clock.
In open MAS we do not know what kind of agent will enter the system; the organisation is a set of behavioural constraints that a group of agents adopts to control the agents’ autonomy and easily achieve their global purposes — based on how human societies use social roles for globally coherent behaviour. The Moise+ organisational model (Model of Organisation for multI-agent SystEms) unifies three dimensions in an Organisational Specification (OS):
S-Moise+ is the middleware that fills the gap between organisational constraints and agent autonomy: it ensures that all agents follow the organisation without requiring that they are developed in a specific language or architecture — an exogenous, organisation-centred approach suitable for heterogeneous and open systems. When a set of agents adopts an OS they form an Organisational Entity (OE), whose history runs through events like agents entering/leaving, group creation, role adoption, and mission commitment.
JaCaMo [Boissier, Bordini, Hübner, Ricci, Santi 2013] brings together agent-oriented programming, organisation-oriented programming and environment-oriented programming into a single programming model and platform — multi-agent oriented programming. It builds upon three existing platforms, one per dimension:
The integrated programming meta-model defines the synergies among the dimensions, which come for free (transparently, without extra programming):
The Building-a-House example (from the JaCaMo distribution) shows all three dimensions working together: Giacomo runs auctions through auction artifacts (agent–environment), winners join the house-building organisation adopting roles such as site_prep_contractor (agent–organisation), and the scheme creates obligations — e.g. obligation(companyB, achieved(s1, site_prepared), “4/1/2011”) — which the agents perceive and adopt as individual goals. Changing the scheme specification changes the behaviour of the whole agent team without changing a single line of agent code: the scheme is the program for social coordination, and the SchemeBoard artifact is its interpreter.
Learning is a key aspect also for cognitive architectures, with different kinds of approaches in the literature: “chunking” (learning from experience), Reinforcement Learning (as sub-symbolic learning), Bayesian learning (uncertainty), … and an open research line on integrating symbolic and sub-symbolic approaches. From an engineering point of view this is the question of programming vs learning — Software 2.0 (and now 3.0).
The cognitive era narrative (IBM, 2015): from the Tabulating Era (1900s–1940s) through the Programming Era (1950s–present) to the Cognitive Era (2011–), “cognitive computing as a necessary and natural evolution of programmable computing”. And Software 2.0 (Karpathy, 2018): the modern form of software alchemy where instead of writing programs we train them — requiring “a radical rethinking of the ancestral software engineering and programming practices” (Meijer, PLDI 2018). Yet the debate is open: Software 2.0 so far misses qualities essential for software engineering — robustness, understandability/explainability, modularity (Parnas, 2017).
The module frames the programming–learning segment: from fully-designed, programmed agents (e.g. BDI) to purely trained agents (e.g. RL agents), exploring learning as a core/enabling feature integrated in the full engineering process, supported by the agent interpreter and possibly by the agent programming languages. A recent approach: BDI agents with soft + hard plans [Bosello & Ricci 2019] — hard plans are programmed/classic, soft plans are learnt during development (“education”) and possibly refined/adapted at runtime.
And the provocations: “the end of agent programming?” — not really, but triggering/renewing interesting directions (Bordini, El-Fallah Segrouchni, Logan, Hindriks, Ricci, JAAMAS 2020; Ricci, EMAS 2021 invited). Agent development as an education process (metaphor): set up an agent with a first designed/programmed part, then grow the agent through an education-like process based on learning techniques — objective, technique/method, assessment, monitoring, integration. From Software 2.0 to “Software 3.0”: “the hottest new programming language is English” (Karpathy) — vibe coding and full-fledged agentic-based software development (Replit Agent 3, Google Antigravity).
Finally, hybrid cognitive architectures: agentic AI lacks solid engineering foundations; open research lines include hybrid agent architectures — (Cognitive) Language Agents + BDI Architecture — and empowering the standards emerging in agentic AI with concepts and results from Autonomous Agents and MAS: the notion of “tool” (and MCP) vs. the notion of artifacts (and A&A), and the A2A protocol vs. agent communication languages.
The closing reading of the module [Ricci, Burattini, Ciortea, Castellucci, 2024] explores the bi-directional interaction between DDD (Chapters 6–10 of this course) and Agent-Oriented Software Engineering. The two communities tackle complexity from different perspectives: DDD mainly concerns structural complexity (inherent complexity of entities within a domain), while AOSE mainly concerns dynamic complexity (autonomy, reactivity, adaptability, distribution).
Empowering DDD with agent-oriented modelling happens at two levels:
keep_temperature(Min,Max), beliefs from sensors, actions on the HVAC — with the hexagonal/clean architecture preserved: percept/action ports and adapters keep the domain model decoupled); as a single agent plus environment (artifacts for the temperature sensor, user preference subsystem, HVAC — artifacts as DDD aggregate roots of the environment); or as a multi-agent system (multiple communicating agents sharing the environment).Note that agent and artifact concepts are used here first of all as modelling abstractions for the domain — Bounded Contexts modelled as agents can be implemented with mainstream technologies such as (micro)services.
Chapter 9 closed with microservices as the DDD-inspired runtime shape; Chapter 11 generalized the microservice discipline into a reactive metamodel of encapsulated modules; Chapters 12–15 have added the autonomous dimension: agents as intentional, goal-directed entities (Chapter 12), agent programs from reflex to learning and LLM agents (Chapter 13), the knowledge level and BDI as the cognitive core (Chapter 14), and agent-oriented/multi-agent programming with environments and organisations as first-class dimensions (Chapter 15). The DDD–AOSE bridge of this last section is the point where the whole course’s arc — architecture, methods, microservices, reactive systems, autonomous systems — closes back onto itself.
AgentSpeak(L) [Rao 1996] is a logic-based programming language for BDI agents, inspired by PRS, dMARS and BDI logics, conceived as an abstract language aimed at theoretical results — bridging specification logics and implemented systems. Plan structure: triggering event : context <- body — the event the plan handles, the circumstances in which it applies, and the course of action. The paper provides an operational and proof-theoretic semantics (a labelled transition system), making beliefs/desires/intentions ascribable to programs from an external viewpoint.
Jason is a BDI agent programming language and platform implementing the operational semantics of a variant of AgentSpeak(L) in Java, with practical extensions (MAS definition, communication, customisation). Runtime structures: belief base, set of events, plan library, set of intentions. Reasoning cycle: perceive and update beliefs; process messages; select an event; select relevant plans; select applicable plans (context check); create/update an intention; select the intention to execute.
Beliefs: annotated first-order literals f(term1,…,termn)[annotations], updated by perception (source(percept)), by intention (+/-, source(self)), by communication (tell/untell with the sender as source). Goals: same syntax prefixed by ! (achievement) or ? (test). Triggering events: +b, -b, +!g, -!g, +?g, -?g. Plans: event : context <- body, with belief operators, goal operators, internal actions, constraints and external actions; failure events (-!g) enable retry and meta-programming (askHow, add_plan).
AOP [Shoham 1993] is a new computational framework, a specialization of OOP, using mentalistic notions and a societal view of computation. The agent’s state is a mental state with components such as beliefs, decisions, capabilities, obligations, formalized in an extension of epistemic logics (temporalized knowledge/belief plus operators for obligation, decision, capability). Agents are controlled by agent programs with typed communication primitives in the spirit of speech act theory (informing, requesting, offering).
Agent dimension (AOP): mental state structures (beliefs, goals, events, capabilities, plans, reasoning rules) and the deliberation loop. Interaction dimension (IOP): speech-act communication and protocols. Environment dimension (EOP): resources, services, artifacts, workspaces — action effects, events/sense information, synchronisation, long-term operations. Organisation dimension (OOP): agents, roles, groups, norms, deadlines, sanctions — endogenous or exogenous control. Multi-agent oriented programming (MAOP) treats agent, environment and organisation as first-class integrated dimensions.
A&A [Omicini, Ricci, Viroli 2008]: agents are autonomous, goal-oriented, pro-active entities; artifacts are non-autonomous, function-oriented, stateful entities modelling tools and resources, exposing operations (usage interface), observable properties and observable events/signals; workspaces group agents and artifacts, defining the environment topology. Taxonomy: individual/personal artifacts (single agent use: agenda, library), social artifacts (structuring interaction: blackboard, game-board, coordination/organisation artifacts), boundary artifacts (external resources/services, GUI/console I/O).
Use: an action triggers the execution of an operation on the artifact’s usage interface; operation execution is process-based, asynchronous, possibly long-term and overlapping; action completion (success/failure, feedback) is generated by the environment. Observation: agents focus artifacts; observable properties map into dynamic knowledge (belief base) and signals into percepts about events. Linkability: artifacts linked through link interfaces enable inter-artifact interaction, designing distributed environments across workspaces. Predefined artifacts (workspace, node, console, blackboard/tuple space) provide a base action repertoire.
The structural specification (roles and groups: behaviour responsibilities, acquaintance/communication/authority links, group composition and well-formedness), the functional specification (social scheme decomposing organisational goals into sub-goals grouped into missions, with temporal constraints and time-to-fulfil), and the deontic specification (norms binding roles to missions: obligations, permissions, prohibitions). S-Moise+ is the middleware that enforces the organisational specification exogenously, so agents follow the organisation regardless of their language or architecture — suitable for heterogeneous, open MAS.
JaCaMo [BBHRS 2013] integrates Jason (agents), CArtAgO (artifact-based environments, A&A) and Moise (organisations). Synergies: A–E — agent actions map into artifact operations (dynamic action repertoire, process-based long-term actions, explicit success/failure semantics), and observable properties/events map into percepts/beliefs; O–E — the organisation is reified as organisational artifacts (OrgBoard, GroupBoard, SchemeBoard) providing actions (adoptRole, commitMissions, setGoalAchieved) and observable state; A–O — organisational goals are delegated to agents as obligations, which agents perceive and freely adopt as individual goals, preserving autonomy. The scheme is the program for social coordination and the SchemeBoard its interpreter.
The segment spans from programming-based agents (fully designed/programmed, e.g. BDI) to learning-based agents (purely trained, e.g. RL), exploring learning as a core feature integrated in the full engineering process (development and runtime), supported by the interpreter and languages. BDI+learning [Bosello & Ricci 2019]: hard plans (programmed/classic) + soft plans (learnt) — soft plans learned during development (“education”) and possibly refined at runtime; agent development as an education process (objective, technique, assessment, monitoring, integration).
DDD tackles structural complexity; AOSE tackles dynamic complexity. DDD can structure domain models in MAOP (Bounded Contexts as a vertical separation across dimensions, Ubiquitous Language for consistency), while agents address DDD’s blind spot for dynamic complexity. Modelling: a single Bounded Context can be a single agent (goals, beliefs, plans; hexagonal architecture preserved with percept/action ports), an agent plus environment (artifacts as aggregate roots of the environment), or a multi-agent system; multiple Bounded Contexts can be interacting agents (ACL-level interaction semantics) or an agent organisation (groups/roles, e.g. Moise). Agent/artifact concepts serve first as modelling abstractions, implementable with mainstream technologies like microservices.
MCP (tool/data integration) is contrasted with artifacts and A&A: both standardize how an agent accesses tools, resources and data sources — the environment dimension — with A&A providing a richer, MAS-grounded abstraction (observable state, events, workspaces). A2A (agent-to-agent communication) is contrasted with agent communication languages (FIPA ACL, KQML): both standardize agent–agent interaction. The research line: empowering the emerging agentic-AI standards with concepts and results from Autonomous Agents and MAS.