Part V — Tools, artefacts and case studies · Chapter 13

Intentional agents in AgentSpeak(L) & Jason

~55 min read7 interactive widgets

In this chapter

  1. Implementing BDI architectures
  2. PRS: the first BDI architecture
  3. AgentSpeak(L): the language
  4. Syntax: beliefs, goals and events
  5. Syntax: plans
  6. An AgentSpeak(L) example
  7. Semantics: the agent configuration
  8. Semantics: deliberation steps
  9. Jason: the interpreter
  10. The Jason reasoning cycle
  11. The Jason programming language
  12. Internal actions and message passing
  13. Environments and hierarchical planning
  14. Conclusion
  15. Check your understanding
Editor’s note

This chapter is the case-study deck C2 — Programming Intentional Agents in AgentSpeak(L) & Jason, the second concrete platform of the course. Chapter 12 gave us Jade: a weak agent platform where autonomy is engineered through threads and behaviours, and where goals never appear. Here the course goes the other way: AgentSpeak(L) is an abstract language for programming intentional agents — agents built out of beliefs, goals and plans — and Jason is the platform that executes it. This is Chapter 7’s BDI architecture made into a programming language: beliefs, desires and intentions stop being a conceptual shelf and become syntax with an operational semantics. The chapter closes the case-study arc of Part V: the lab repository is the intended hands-on follow-up.

1. Implementing BDI architectures

The deck opens where Chapter 7 ended: the BDI architecture is a theory of practical reasoning, and the question now is how to implement it. The abstract control loop of BDI agents [Rao and Georgeff, 1995] gives the skeleton that every concrete architecture — PRS, dMARS, AgentSpeak(L), Jason — will fill in its own way:

1. initialize-state();
2. while true do
3.   options := option-generator(event-queue);
4.   selected-options := deliberate(options);
5.   update-intentions(selected-options);
6.   execute();
7.   get-new-external-events();
8.   drop-successful-attitudes();
9.   drop-impossible-attitudes();
10. end-while

The loop is the bridge between perception and action: events enter, options are generated from them, deliberation filters the options into intentions, intentions are executed, and the loop cleans up after itself — dropping attitudes that have been fulfilled (successful) or that can no longer be pursued (impossible). Notice what never appears in the loop: a global planner. Deliberation is a repeated, cheap step, not an expensive one-shot search — this is the deliberate/reactive tension of Chapter 7, resolved by interleaving.

Concrete BDI systems are built out of six constructs:

The architecture of a BDI agent [Wooldridge, 2009] wires these constructs together: sensors feed a belief revision function (BRF) that updates beliefs; an option generator produces options (desires) from beliefs and events; a filter turns desires into intentions; intentions drive action through effectors. The agent is literally the loop around that pipeline.

ENVIRONMENT situated agent: perceives and acts SENSORS perception BRF belief revision OPTION generator EFFECTORS action BELIEFS DESIRES INTENTIONS FILTER deliberation beliefs → options filter selects intentions intentions → action action changes the environment — the loop closes BRF = belief revision function · the cycle repeats: perceive, revise, generate options, deliberate, execute.
Plate 13.1 — Basic architecture of a BDI agent [Wooldridge, 2009]. Sensors feed the belief revision function; the option generator produces desires from beliefs and events; the filter selects intentions; intentions drive the effectors, and the environment feeds back.

2. PRS: the first BDI architecture

Before AgentSpeak(L), the deck places the ancestor: the Procedural Reasoning System (PRS) [Georgeff and Lansky, 1987], one of the first BDI architectures. PRS is a goal-directed and reactive planning system:

PRS was applied for high-level reasoning of robots, airport traffic control systems, and the like. Its architecture is the blueprint that AgentSpeak(L) will simplify into a language:

AGENT ENVIRONMENT SENSORS EFFECTORS DATA BASE (beliefs) KAS (plans) GOALS (desires) STACK (intentions) INTERPRETER (REASONER) MONITOR percepts actions one interpreter drives all four structures PRS = goal-directed (complex tasks) + reactive (real-time) — the ancestor of AgentSpeak(L).
Plate 13.2 — The PRS architecture [Georgeff and Lansky, 1987]. Beliefs, plans (KAS), desires (goals) and intentions (stack) are four structures interpreted by one reasoner; a monitor feeds perceptions, a command generator emits actions.

3. AgentSpeak(L): the language

AgentSpeak(L) is an abstract language used for describing and programming BDI agents. Its pedigree is explicit:

The main language constructs are three, mapping directly onto the BDI ontology:

The architecture of an AgentSpeak agent has four main components: a belief base, a plan library, a set of events, and a set of intentions. Everything else in the language — syntax and semantics — is a disciplined answer to the question: how do these four components interact?

4. Syntax: beliefs, goals and events

AgentSpeak(L) borrows the logical vocabulary the course already built in Chapters 8 and 9. Beliefs: if b is a predicate symbol and t1, ..., tn are (first-order) terms, then b(t1, ..., tn) is a belief atom; ground belief atoms are base beliefs; if Φ is a belief atom, then Φ and ¬Φ are belief literals.

Goals: if g is a predicate symbol and t1, ..., tn are terms, then !g(t1, ..., tn) and ?g(t1, ..., tn) are goals:

This single distinction encodes two kinds of questions an agent can pursue: “bring it about that…” (achievement) versus “find out whether…” (test). It is the language-level counterpart of Chapter 3’s distinction between acting on the world and knowing the world.

Events occur as a consequence of changes in the agent belief base or goal states. Events signal to the agent that some situation is requiring servicing (triggering events), and the agent is supposed to react to such events by finding a suitable plan — or plans. Because of events and goal processing, AgentSpeak(L) architectures are both reactive (they answer to external and internal change) and proactive (they pursue goals).

If b(t) is a belief atom and !g(t), ?g(t) are goals, the six triggering events are:

Let Φ be a literal: the triggering events are , −Φ, +!Φ, −!Φ, +?Φ, −?Φ. The key intuition: change itself is an event. Adding a belief, dropping a goal — each such change generates an event that can trigger a plan.

5. Syntax: plans

Plans are recipes for achieving goals. They declaratively define a workflow of actions; they come along with the triggering and the context conditions that must hold in order to initiate the execution; they represent the agent’s means to achieve goals — its know-how.

If e is a triggering event, b1, ..., bn are belief literals (the plan context), and h1, ..., hn are goals or actions (the plan body), then

e : b1 ∧ ... ∧ bn ← h1 ; ... ; hn

is a plan, where e : c is called the plan’s head. The general structure of an AgentSpeak plan is therefore:

triggering_event : context <- body.

Let Φ be a literal: the plan body (i.e., intentions in AgentSpeak) can include the following elements:

An intention is thus a stack of partially instantiated plans — the body of one plan pushes subgoals that resolve into further plans, and the stack grows and shrinks as the agent executes.

+!book_tickets(A,D,V) : not busy(phone) <- ?phone_number(V,N); !call(N); !choose_seats(A,D,V). TRIGGERING EVENT CONTEXT BODY (INTENTION) what to handle when usable course of action head = triggering event : context · body = goals & actions — the plan’s know-how. ?Φ test goal · !Φ achievement goal · +Φ/−Φ belief update · Φ action · .Φ internal action (Jason)
Plate 13.3 — Anatomy of an AgentSpeak plan. The head couples the triggering event with the context; the body is the sequence of goals and actions that becomes part of the agent’s intentions.

6. An AgentSpeak(L) example

The deck’s running example shows how all the pieces fit — beliefs, plans, triggering events, test and achievement goals:

/* Initial Beliefs */
likes(radiohead).
phone_number(covo,"05112345").

/* Belief addition */
+concert(Artist, Date, Venue)
  : likes(Artist)
  <- !book_tickets(Artist, Date, Venue).

/* Plan to book tickets */
+!book_tickets(A,D,V)
  : not busy(phone)
  <- ?phone_number(V,N);   /* Test Goal to Retrieve a Belief */
     !call(N);
     ...;
     !choose_seats(A,D,V).

The example reads as a story. The agent initially believes it likes Radiohead and knows Covo’s phone number. When a new belief arrives — a concert of an artist the agent likes, at a date and venue — the belief addition event +concert(...) fires, the context likes(Artist) is checked against the belief base, and the plan body launches the achievement goal !book_tickets(...). Booking tickets, in turn, is a plan whose context is not busy(phone); its body first asks a test goal?phone_number(V,N) retrieves the venue’s number from the beliefs — then calls, and finally chooses seats. Each ! pushes a sub-intention; the stack of plans grows and shrinks as the agent proceeds.

Three details are worth stressing because they reappear in Jason. First, the same predicate can be both a belief and a goal: phone_number/2 is a belief here, and the test goal queries it. Second, contexts are belief formulae: not busy(phone) is checked against the belief base at plan-selection time, not when the plan was written. Third, the body is an intention: when the plan is selected, its body becomes part of the agent’s intention stack, and sub-goals are handled by finding further plans.

7. Semantics: the agent configuration

AgentSpeak(L) has an operational semantics defined in terms of an agent configuration

⟨B, P, E, A, I, Se, So, SI⟩

where:

The selection functions are the knobs where agent-specificity enters the semantics:

The semantics of intention execution is given by transition rules on the body of the currently executing plan. Each rule says what happens when the body starts with a given element:

If no plan is applicable for a generated −!ψ or −?ψ, then the whole intention is disregarded and an error message is printed. Failure handling is thus semantic: a failing sub-goal propagates a goal-deletion event up to the plan that generated it.

The configuration is then refined into a richer tuple ⟨ag, C, M, T, s⟩, where:

CONFIGURATION ⟨ag, C, M, T, s⟩ ag C M T beliefs plans I = intentions E = events (tr,i) A = actions In = inbox Out = outbox SI = suspended intentions R = relevant Ap = applicable ι ε ρ = current items program = static beliefs + plan library circumstance = the agent’s runtime state communication = messages ⟨id, agent, ilf, content⟩ temporary = one cycle’s working sets s = current step within the agent reasoning cycle · Se, So, SI = selection functions
Plate 13.4 — The AgentSpeak agent configuration ⟨ag, C, M, T, s⟩. The program provides beliefs and the plan library; the circumstance holds runtime intentions, events and actions; the communication component manages the mailbox; the temporary component holds the working sets of one reasoning cycle.

8. Semantics: deliberation steps

The current step s within an agent reasoning cycle is one of the following:

Read the list as a pipeline: the mailbox is drained first, then one event is picked, its relevant plans are collected from the library, their contexts are checked (applicable plans), one of them is selected as the intended means and pushed onto the intentions, an intention is chosen for execution, one step of it runs, and finished intentions are cleared. The next cycle starts again from the mailbox — this is the BDI control loop of section 1, made into a precise state machine.

9. Jason: the interpreter

Jason [Bordini et al., 2007], developed by Jomi F. Hübner and Rafael H. Bordini, implements the operational semantics of a variant of AgentSpeak [Bordini and Hübner, 2006]. Its design is a two-level deal:

Jason extends AgentSpeak with a set of powerful mechanisms to improve agent abilities, aimed at making it a more practical programming language; and it comes with a framework for developing multi-agent systems (jason.sourceforge.net). In the course’s terms: AgentSpeak is the theory — an abstract language with an operational semantics — and Jason is the engineering — a working interpreter plus a MAS framework. Chapter 12’s Jade was a FIPA platform for weak agents; Jason is a platform for intentional agents, where the ACL machinery of Chapter 11 becomes the M component of the configuration.

10. The Jason reasoning cycle

The Jason reasoning cycle makes the semantics operational in ten steps:

  1. perceiving the environment;
  2. updating the belief base;
  3. receiving communication from other agents;
  4. selecting ‘socially acceptable’ messages;
  5. selecting an event;
  6. retrieving all relevant plans;
  7. determining the applicable plans;
  8. selecting one applicable plan;
  9. selecting an intention for further execution;
  10. executing one step of an intention.

Steps 1–2 are perception and belief revision (the BRF of the abstract architecture); 3–4 handle the mailbox with a social-acceptance filter; 5–8 are event selection and means–end reasoning; 9–10 are intention selection and execution. The cycle repeats; an action produced in step 10 is dispatched to the environment.

1 PERCEIVE 2 BRF 3 CHECKMAIL 4 SOCACC 5 SELEV 6 RELPL 7 APPLPL 8 SELAPPL 9 SELINT 10 EXECINT ACT percepts belief base messages accepted event library contexts intended means intention one step action to env one cycle: perceive → revise → deliberate → execute → repeat
Plate 13.5 — The Jason reasoning cycle in ten steps. Steps 1–4 handle perception and the mailbox; 5–8 are event selection and plan selection (means–end reasoning); 9–10 select and execute an intention. The cycle repeats forever.

In the interpreter, the cycle is literally a Java method, reasoningCycle() in jason.asSemantics.TransitionSystem:

public void reasoningCycle() {
    try {
        C.reset();    // C is the actual Circumstance
        if (nrcslbr >= setts.nrcbp()) {
            nrcslbr = 0;
            ag.buf(agArch.perceive());
            agArch.checkMail();
        }
        nrcslbr++;        // counting number of cycles
        if (canSleep()) {
            if (ag.pl.getIdlePlans() != null) {
                logger.fine("generating idle event");
                C.addExternalEv(PlanLibrary.TE_IDLE);
            } else {
                agArch.sleep();
                return;
            }
        }
        step = State.StartRC;
        do {
            if (!agArch.isRunning()) return;
            applySemanticRule();
        } while (step != State.StartRC);
        ActionExec action = C.getAction();
        if (action != null) {
            C.getPendingActions().put(action.getIntention().getId(), action);
            agArch.act(action, C.getFeedbackActions());
        }
    } catch (Exception e) {
        conf.C.create(); // ERROR in the transition system, creating a new C
    }
}

Three engineering details stand out. Perception and mail checking happen only every nrcbp cycles (a configurable budget — the environment is sampled, not polled). If nothing can be done, the agent sleeps — autonomy includes the right to be idle. And the inner do…while applies semantic rules until the step returns to StartRC: the cycle is a sequence of semantic-rule applications, exactly as the operational semantics dictates.

11. The Jason programming language

Jason includes all the syntax and the semantics already defined for AgentSpeak, plus the operators a programmer expects: boolean operators ==, <, <=, >, >=, &, |, \==, not; arithmetic +, , /, *, **, mod, div.

Then Jason includes several extensions. Let Φ be a literal: a Jason plan body can include the following additional elements:

Belief annotations. Jason introduces the notion of annotated predicates:

ps(t1, ..., tn)[a1, ..., am]

where the ai are first-order terms. All predicates in the belief base have a special annotation source(si), where si ∈ {self, percept} ∪ AgId:

myLocation(6,5)[source(self)].
red(box1)[source(percept)].
blue(box1)[source(ag1)].

The developer can define customised annotations too — e.g. a degree of certainty on a belief:

colourblind(ag1)[source(self),doc(0.7)].
lier(ag1)[source(self),doc(0.2)].

Strong negation (operator ~) is another Jason extension to AgentSpeak, allowing both closed-world and open-world assumptions. The distinction is between “not believed” (not) and “believed to be false” (~). The deck’s pit-stop example shows all three cases:

+!pit_stop(fuel(T), tires(_))
  : not raining & not ~raining   /* Lack of knowledge: no belief of raining, no belief of ~raining */
  <- -+tires(intermediate);        /* Atomic Belief Update */
     !fuel(T+2); ...
+!pit_stop(fuel(T), tires(_))
  : raining                       /* There is a belief indicating raining */
  <- -+tires(rain);
     !fuel(T+5); ...
+!pit_stop(fuel(T), tires(_))
  : ~raining                      /* There is a belief indicating ~raining */
  <- -+tires(slick);
     !fuel(T); ...

Three different plans for the same goal pit_stop, distinguished only by context: rain tyres when it is believed raining, slick tyres when it is believed not raining, intermediate tyres when the agent simply does not know. Open world: absence of evidence is a third case, not a fallback.

Belief rules. In Jason, beliefs (and their annotations) can be pre-processed with Prolog-like rules — Chapter 8’s logic meets Chapter 13’s annotations:

likely_color(Obj,C)
  :- colour(Obj,C)[degOfCert(D1)]
     & not (
        colour(Obj,_)[degOfCert(D2)]
        & D2 > D1 )
     & not ~colour(Obj,C).

12. Internal actions and message passing

Internal actions () are self-contained actions whose code is packed and atomically executed as part of the agent reasoning cycle. They can be used for special-purpose activities: to interact with Java objects, to invoke legacy systems elegantly, and — as the rest of the course will show — to use artefacts in A&A systems. An example of a user-defined internal action:

userLibrary.userAction(X,Y,R)

can be used to manipulate parameters X and Y and unify the result of that manipulation in R — exactly the input/output discipline of a Prolog predicate, Chapter 8 again.

Defining a new internal action is writing a Java class. The deck’s example, myLib.randomInt(M, N), unifies N with a random int between 0 and M:

package myLib;

import jason.JasonException;
import jason.asSemantics.*;
import jason.asSyntax.*;

public class randomInt extends DefaultInternalAction {

    private java.util.Random random = new java.util.Random();

    @Override
    public Object execute(TransitionSystem ts, Unifier un, Term[] args) throws Exception {
        if (!args[0].isNumeric() || !args[1].isVar())
                throw new JasonException("check arguments");
        try {
            int R = random.nextInt( ((NumberTerm)args[0]).solve() );
            return
                 un.unifies(args[1], new NumberTermImpl(R));
        } catch (Exception e) {
            throw new JasonException("Error in internal action 'randomInt'", e);
        }
    }
}

Many internal actions are available for printing, sorting, list/string operations, manipulating beliefs/annotations/plan library, waiting/generating events, etc. (see jason.stdlib). Predefined internal actions have an empty library name:

Message passing uses internal actions. A sender agent A sends a message to agent B via:

.send(B, ilf, m(X))
.broadcast(ilf, m(X))

The receiver agent B receives the message from A as a triggering event, and handles it by customising a reaction:

+m(X)[source(A)] : true
<- dosomething; ...

The annotation [source(A)] is how the receiver knows who sent the message — the source annotation of section 11, used at runtime. The ilf performatives are Chapter 10’s FIPA communicative acts, repurposed: tell informs, achieve asks the receiver to adopt a goal, askOne/askAll request information, tellHow shares plans.

13. Environments and hierarchical planning

To build and deploy a MAS you need to rely on some sort of environment where the agents are situated; the environment has to be designed and implemented as well. There are two ways to do this:

  1. Defining perceptions and actions so as to operate on specific environments — done in Java by defining lower-level mechanisms and by specialising the Agent Architecture and Agent classes;
  2. Creating a ‘simulated’ environment — done in Java by extending Jason’s Environment class and using methods such as addPercept(String Agent, Literal Percept).
import jason.*;
import ...;
public class myEnv extends Environment {

   public myEnv() {
      Literal loc = Literal.parseLiteral("location(3,5)");
      addPercept(loc);
   }

   public boolean executeAction(String ag, Term action) {
      if (action.equals(...)) {
          addPercept(ag,
                     Literal.parseLiteral("location(table,c(3,4))"));
      }
      ...
      return true;
   }
}

The environment is where Chapter 4’s situatedness becomes code: the agent perceives what the environment publishes (addPercept), and the environment reacts to the actions the agents execute (executeAction).

Hierarchical planning. The deck closes the language tour with an advanced BDI aspect. Hierarchical abstraction is a well-known principle, exhibiting great effectiveness in planning: it is used to reduce a composite intention — or a given task — to a greater number of independent sub-intentions — or sub-tasks — placed at a lower level of abstraction. An agent can manage at runtime an alternating hierarchy of (meta)goals and plans, emerging from top-level goals over plans to subgoals and so forth. This highly simplifies the structure of plans, and allows plans to be conceived around self-contained actions — the leaves of the goal hierarchy — which can be reused for different purposes too. The hierarchy is defined having in mind the problem domain (the goal to be achieved) and trying to imagine those fine-grained actions which in turn are supposed to accomplish the required activities.

The crucial contrast is with traditional planning systems: they mainly make offline planning — creating plans to achieve goals by composing actions in a repertoire. Intentional systems, differently, need to plan in dynamic environments and cope with changing contexts and situations [Sardina et al., 2006]. BDI planning is a hybrid approach: plans are defined at design time and at the language level, but their execution is ruled by the architecture (means–end reasoning) according to context conditions — as in Jason and Jadex — or planning rules, as in 2APL.

GOAL HIERARCHY — composite intention → sub-intentions → leaf actions !TOP_GOAL !SUB_GOAL_1 !SUB_GOAL_2 !SUB_GOAL_3 action a1 action a2 action a3 action a4 ... plans are defined at design time; execution is ruled at runtime by means–end reasoning (Jason, Jadex) or planning rules (2APL).
Plate 13.6 — Hierarchical planning in BDI languages. A composite intention reduces to sub-intentions, down to reusable leaf actions; the hierarchy is defined at design time, the selection is done at runtime by the architecture.

14. Conclusion

The deck concludes by positioning the two artefacts of the chapter:

Two books anchor the literature: Programming Multi-Agent Systems in AgentSpeak using Jason [Bordini et al., 2007] and Multi-Agent Oriented Programming [Boissier et al., 2020] — the latter opening the road toward JaCaMo, the A&A (agents & artefacts) framework the course’s later modules build upon.

Key idea

Chapter 12’s Jade engineered autonomy without mental states; AgentSpeak(L) does the opposite — it makes mental states the syntax: beliefs are literals, goals are ! and ? prefixes, plans are triggering_event : context <- body rules, and the whole machine has an operational semantics (configuration ⟨ag, C, M, T, s⟩, selection functions, deliberation steps). Jason is that semantics made executable: a ten-step reasoning cycle, belief annotations with sources, strong negation, internal actions, ACL-style message passing, and Java as the escape hatch for environments and custom mechanisms. For the exams: an AgentSpeak plan is “triggering event : context <- body”, the body is an intention, and the cycle is perceive → revise → deliberate → execute.

Check your understanding

Write the BDI abstract control loop.

initialize-state(); then, while true: options := option-generator(event-queue); selected-options := deliberate(options); update-intentions(selected-options); execute(); get-new-external-events(); drop-successful-attitudes(); drop-impossible-attitudes() [Rao and Georgeff, 1995].

List the six constructs BDI architectures are based on.

A set of beliefs; a set of desires (or goals); a set of intentions (a subset of the goals with an associated stack of plans for achieving them — the intended actions); a set of internal events (elicited by belief or goal changes); a set of external events (perceptive events from interaction with external entities); and a plan library (repertoire of actions) as a further static component.

What is PRS and why is it relevant?

PRS (Procedural Reasoning System) [Georgeff and Lansky, 1987] is one of the first BDI architectures: a goal-directed and reactive planning system. Goal-directedness allows reasoning about and performing complex tasks; reactiveness allows handling real-time behaviour in dynamic environments. It was applied to robots, airport traffic control, etc. Its architecture (beliefs data base, KAS of plans, goals, intention stack, interpreter) is the blueprint of AgentSpeak(L).

What is AgentSpeak(L)? Give its pedigree.

An abstract language used for describing and programming BDI agents. Inspired by PRS, dMARS and BDI Logics; originally proposed by Anand S. Rao [Rao, 1996]; extended to a practical agent programming language [Bordini and Hübner, 2006]; programs can be executed by the Jason platform [Bordini et al., 2007]; it has an operational semantics providing a computational semantics for BDI concepts.

What are the main constructs of AgentSpeak, and the four components of its agent architecture?

Beliefs (current state of the agent, information about the environment and other agents), goals (states the agent desires to achieve, about which it reasons based on internal and external stimuli), plans (recipes of procedural means to change the world and achieve goals). The architecture has four components: belief base, plan library, set of events, set of intentions.

Define beliefs, goals and triggering events in AgentSpeak(L) syntax.

If b is a predicate symbol and t1..tn are first-order terms, b(t1..tn) is a belief atom; ground atoms are base beliefs; Φ and ¬Φ are belief literals. If g is a predicate symbol, !g(t1..tn) is an achievement goal (goal to do, pointing at practical actions) and ?g(t1..tn) a test goal (goal to know, pointing at epistemic actions). Triggering events: +Φ belief addition, −Φ belief deletion, +!Φ achievement-goal addition, −!Φ achievement-goal deletion, +?Φ test-goal addition, −?Φ test-goal deletion.

Give the general structure of an AgentSpeak plan and the elements a plan body can include.

triggering_event : context <- body. The triggering event denotes the events the plan handles; the context is a logical expression, typically a conjunction of literals checked against the belief base; the body is the course of action (a sequence of actions and sub-goals). The body can include: !Φ achievement goals, ?Φ test goals, +Φ belief addition, −Φ belief deletion, Φ actions, .Φ internal actions (a Jason extension).

Explain the semantics of intention execution for a failing sub-goal.

When the body starts with !φ (or ?φ), event +!φ (or +?φ) is generated; if there is no applicable plan for it, the plan is removed and a −!ψ (or −?ψ) event is generated if tr = +!ψ (or +?ψ). If an action φ or internal action .φ fails, the plan is removed and the same goal-deletion event is generated. If no plan is applicable for the generated −!ψ or −?ψ, the whole intention is disregarded and an error message is printed.

Describe the AgentSpeak agent configuration ⟨ag, C, M, T, s⟩.

ag is the AgentSpeak program (beliefs and plans). C = ⟨I, E, A⟩ is the circumstance: intentions (stacks of partially instantiated plans), events (pairs (tr, i), with i an intention or T for external events), actions to be performed in the environment. M = ⟨In, Out, SI⟩ is the communication component: inbox, outbox, suspended intentions; messages are ⟨messageid, agentid, ilf, content⟩. T = ⟨R, Ap, ι, ε, ρ⟩ is temporary information: relevant plans, applicable plans, and the current intention/event/applicable plan. s is the current step within the reasoning cycle.

List the deliberation steps of an AgentSpeak reasoning cycle.

ProcMsg (process a message from the inbox), SelEv (select an event), RelPl (retrieve relevant plans), ApplPl (check which are applicable), SelAppl (select one applicable plan, the intended means), AddIM (add the intended means to the intentions), SelInt (select an intention), ExecInt (execute the selected intention), ClrInt (clear finished intentions or intended means).

What is Jason, and what is its two-level design?

Jason [Bordini et al., 2007], developed by Jomi F. Hübner and Rafael H. Bordini, implements the operational semantics of a variant of AgentSpeak. Design: AgentSpeak as the high-level language to define goal-oriented agent behaviour; Java as the low-level language to realise mechanisms (internal functions) and customise the architecture. It comes with a framework for developing multi-agent systems and is highly customisable and open source.

Enumerate the ten steps of the Jason reasoning cycle.

1. Perceiving the environment; 2. updating the belief base; 3. receiving communication from other agents; 4. selecting 'socially acceptable' messages; 5. selecting an event; 6. retrieving all relevant plans; 7. determining the applicable plans; 8. selecting one applicable plan; 9. selecting an intention for further execution; 10. executing one step of an intention.

What are belief annotations in Jason, and what is the source annotation?

Annotated predicates: ps(t1,...,tn)[a1,...,am] where ai are first-order terms. All predicates in the belief base have a special annotation source(si) with si ∈ {self, percept} ∪ AgId — e.g. red(box1)[source(percept)], blue(box1)[source(ag1)]. Developers can define customised annotations, e.g. doc(0.7) for a degree of certainty. The source annotation is also how message receivers know the sender: +m(X)[source(A)].

Explain strong negation (~) and the three pit_stop contexts.

Strong negation allows both closed-world and open-world assumptions: not p means no belief of p; ~p means a belief of p being false. The pit_stop example has three plans for +!pit_stop: context "not raining & not ~raining" (lack of knowledge → intermediate tyres), context "raining" (→ rain tyres), context "~raining" (→ slick tyres). Absence of evidence is a third case, not a fallback.

What are internal actions? Give examples of predefined ones and of message-passing ones.

Internal actions (.Φ) are self-contained actions packed and atomically executed as part of the reasoning cycle; they interact with Java objects, invoke legacy systems, and (later in the course) use A&A artefacts. Predefined (jason.stdlib): .print, .union, .desire, .intend, .drop_desire, .drop_intention. Message passing: .send(B, ilf, m(X)) and .broadcast(ilf, m(X)) with ilf ∈ {tell, untell, achieve, unachieve, askOne, askAll, askHow, tellHow, untellHow}; the receiver handles +m(X)[source(A)].

What are the two ways to build an environment in Jason?

1. Defining perceptions and actions to operate on specific environments, by defining Java lower-level mechanisms and specialising the Agent Architecture and Agent classes; 2. creating a 'simulated' environment by extending Jason's Environment class and using methods such as addPercept(String Agent, Literal Percept).

How does BDI hierarchical planning differ from traditional planning?

Traditional planning systems mainly make offline planning, composing actions in a repertoire to create plans. BDI planning is a hybrid approach: plans are defined at design time and at the language level, but execution is ruled by the architecture (means–end reasoning) according to context conditions (Jason, Jadex) or planning rules (2APL). A composite intention reduces to independent sub-intentions at lower abstraction levels, down to self-contained, reusable leaf actions.