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

Simple agents in Jade

~35 min read5 interactive widgets

In this chapter

  1. Agents (recap): encapsulating control
  2. The “weak” notion of agent
  3. Agents as autonomous entities
  4. What is Jade?
  5. Jade main ingredients and features
  6. FIPA architecture: platforms and containers
  7. AMS, DF and the ACC
  8. Agents in Jade
  9. The FIPA agent lifecycle
  10. Agent behaviours and scheduling
  11. The ACC: mailbox and ACL messages
  12. Communication primitives
  13. Fast Lab
  14. Check your understanding
Editor’s note

This chapter is the case-study deck C1 — Simple Agents in Jade, the first concrete platform of the course. It connects to everything that came before: Chapter 4’s autonomy and encapsulation become Java objects running on their own threads; Chapter 7’s BDI remains on the conceptual shelf (Jade agents are weak agents — no explicit goals); Chapter 10’s remark that Jade agents may need only the selection of a pre-defined course of action is exactly what behaviours implement; and Chapter 11’s complaint about FIPA — that it ignores pragmatic actions and focuses on communication only — becomes concrete here, where all the machinery is about ACL messages. Jade is the FIPA-compliant agent platform; later chapters (Jason, AgentSpeak(L)) will program intentional agents on top of a similar infrastructure. This chapter closes the current segment: the lab repository is the intended hands-on follow-up.

1. Agents (recap): encapsulating control

The deck opens by re-deriving the course’s core notion. If components in a distributed system encapsulate control, they will be able to keep on computing even without connection. A smart way to start engineering distributed systems is therefore to encapsulate computational autonomy within basic components — and computationally-autonomous components in (distributed) software systems are called agents. Properly-designed agents may provide not just fault tolerance, but even some degrees of liveness and consistence — at least at the individual component level.

This is Chapter 4’s argument restated in engineering terms: autonomy is not a luxury but the mechanism that keeps distributed components alive and consistent when the network fails them. Jade will make this concrete: each agent runs on its own thread, so an agent’s computation does not depend on the liveness of any other component.

2. The “weak” notion of agent

The deck introduces the hallmarks of agenthood as the literature standardly lists them [Jennings and Wooldridge, 1996]:

In the common acceptation of the agent literature, these are called weak agents [Wooldridge and Jennings, 1995]. The word “weak” is the key: nothing in this list requires beliefs, desires, intentions or explicit goals. Jade agents are weak agents — and the chapter will show how much can be built with just these four properties.

3. Agents as autonomous entities

The deck then gives the definition that Chapter 4 established and Chapter 11 reused:

Definition (Agent). Agents are autonomous computational entities [Omicini et al., 2008]: genus — agents are computational entities; differentia — agents are autonomous, in that they encapsulate control along with a criterion to govern it.

From autonomy, many other features stem: autonomous agents are interactive, social, proactive, and situated; they might have goals or tasks, or be reactive, intelligent, mobile; they live within MAS, and interact with other agents through communication actions, and with the environment with pragmatical actions. Every one of these words will find its Jade counterpart in the next sections.

4. What is Jade?

Jade [Bellifemine et al., 2007] stands for Java Agent DEvelopment Framework. Jade is a Java-based framework to develop agent-based applications in compliance with the FIPA specifications for interoperable, intelligent, multi-agent systems. FIPA stands for Foundation for Intelligent Physical Agents — the IEEE Computer Society standards organisation (currently inactive) that promotes agent-based technology and the interoperability of its standards with other technologies.

As an agent-oriented middleware, Jade pursues a twofold goal:

This is the classic middleware deal: the platform handles the hard, application-independent machinery; the developer writes only the agent-specific logic. Chapter 11’s complaint about FIPA becomes visible here: the platform is built around communication; pragmatical actions are left to the programmer.

5. Jade main ingredients and features

Jade’s two main ingredients mirror its twofold goal:

And the features Jade offers, which the deck lists as its selling points:

6. FIPA architecture: platforms and containers

A FIPA agent platform can be split onto several hosts, provided that:

Hence, Jade promotes a peer-to-peer interpretation of a MAS: there is no centralised agent hub — containers are peers coordinated through the main container’s registry.

MAIN CONTAINER REMOTE CONTAINER AMS DF ACC white pages yellow pages message passing a b c d e agents live in containers each host = a container registry main container keeps track A single (logical) Jade system split among networked hosts — a peer-to-peer interpretation of a MAS. AMS = Agent Management System · DF = Directory Facilitator · ACC = Agent Communication Channel
Plate 12.1 — Jade platform architecture. The main container hosts the three FIPA services (AMS, DF, ACC); remote containers host agents; the main container’s registry lets them discover each other.

7. AMS, DF and the ACC

The FIPA architecture is built on three services, each with a distinct role:

The mnemonic is simple: AMS answers “who is there?” (white pages), DF answers “who offers what?” (yellow pages), and ACC moves the messages.

8. Agents in Jade

Two sentences capture the essence of Jade agents:

Three consequences deserve emphasis. First, the single-thread rule is what makes autonomy safe: one agent, one thread — no interference from within. Second, the AID is the identity that makes communication possible — you need a name before you can have a mailbox. Third, “business logic must be expressed in terms of behaviours” is the discipline that makes the whole platform work — the topic of section 10.

9. The FIPA agent lifecycle

FIPA defines the states a Jade agent goes through, and the deck lists them precisely:

Notice how the lifecycle encodes autonomy: the AMS grants existence (registration), the agent itself decides when to wait, when to suspend, and when to die. The state explorer below lets you walk the transitions.

10. Agent behaviours and scheduling

Why behaviours at all? By definition, agents are autonomous entities, therefore they should act independently and concurrently with respect to one another. The need for efficiency drives toward the execution of Jade agents as a single Java thread each. However, agents need to perform complex activities, possibly composed by multiple tasks — even concurrently. How can such contrasting requirements be satisfied altogether?

The answer is the behaviour abstraction:

This is Chapter 10’s remark made concrete: Jade agents encapsulate procedural knowledge as behaviours, and “need just the selection of a (pre-defined) course of action most appropriate to the current situation” — the scheduler performs that selection, round-robin, one behaviour at a time.

SINGLE JAVA THREAD one agent = one thread B1 B2 B3 behaviour 1 behaviour 2 behaviour 3 round-robin: B1, B2, B3, B1, B2, B3, … non-preemptive scheduler — each behaviour runs to a completion point, then yields. behaviours are Java objects; concurrency is scheduled, not threaded.
Plate 12.2 — Jade’s non-preemptive, round-robin scheduler. Many behaviours, one thread: each behaviour takes its turn in sequence; the scheduler is hidden to the programmer.

11. The ACC: mailbox and ACL messages

Following the FIPA specification, Jade agents communicate via asynchronous message passing:

The autonomy point is subtle and worth underlining: delivery is asynchronous and notification-based, but processing is a choice. An autonomous agent may ignore a message; the platform cannot force it to react. That is the weak-notion autonomy of section 2, enforced by the middleware.

To understand each other, agents must agree on the format and semantics of the messages they exchange. An ACL message contains:

These are the FP/EE (or FP/RE) pairs Chapter 10 mentioned when discussing FIPA ACL — the same standard, now seen from the message side.

AN ACL MESSAGE :sender who sends the message (automatically set) :receiver who the message targets (possibly many) :performative the communication act (constrained by FIPA ontology) :content the actual information conveyed :language syntax used to encode :content :ontology semantic framework for :content … other fields SENDER send() → ACC RECEIVER mailbox ← notified ACC delivers asynchronous, distributed, serialised as FIPA ACL
Plate 12.3 — The anatomy of an ACL message and the mailbox model. The ACC delivers asynchronously to the receiver’s mailbox and notifies it; processing remains the agent’s own choice.

12. Communication primitives

To interact, Jade agents have a number of ready-to-use methods:

All the above methods are distribution-transparent: they choose the proper address and transport mechanism based upon sender and receiver locations. The agent writes send(msg); the ACC decides whether the message stays in the platform or crosses hosts.

13. Fast Lab

The deck ends with the hands-on assignment: clone the lab repository and follow the lead.

git clone https://dvcs.apice.unibo.it/pika-lab/courses/ise/ay2526/lab-jade
cd lab-jade
# and follow the lead

Everything in this chapter — containers, AMS, behaviours, ACL messages, mailboxes — becomes tangible in the lab: run a main container, spawn agents on it, make them exchange messages, and observe the lifecycle and the scheduler in the debugging tools.

Key idea

Jade is the course’s first concrete answer to the autonomy question: autonomy is engineered — one thread per agent, behaviours as the unit of activity, a scheduler hidden from the programmer, a lifecycle managed by the AMS, communication via asynchronous ACL messages delivered to a mailbox the agent chooses when to read. Chapter 4’s encapsulation, Chapter 10’s “selection of a pre-defined course of action”, and Chapter 11’s FIPA critique all converge here. And the single most important sentence for the exams: an agent is a Java object executed by a Java thread, and its business logic must be expressed in terms of behaviours.

Check your understanding

Why encapsulate computational autonomy in distributed systems?

If components in a distributed system encapsulate control, they will be able to keep on computing even without connection. Computationally-autonomous components in (distributed) software systems are called agents; properly-designed agents may provide not just fault tolerance, but even some degrees of liveness and consistence — at least at the individual component level.

List the four hallmarks of the “weak” notion of agent.

Autonomy (performing problem solving without direct intervention, with control over own actions and internal state); social ability (interacting when appropriate with other agents and humans); responsiveness (perceiving the environment and responding timely to changes); proactiveness (opportunistic, goal-directed behaviour, taking the initiative) [Jennings and Wooldridge, 1996]. These are called weak agents [Wooldridge and Jennings, 1995].

Give the definition of agent as autonomous computational entity.

Agents are autonomous computational entities [Omicini et al., 2008]: genus — agents are computational entities; differentia — agents are autonomous, in that they encapsulate control along with a criterion to govern it. From autonomy stem interactivity, sociality, proactiveness, situatedness; goals or tasks; reactivity, intelligence, mobility; communication actions with agents, pragmatical actions with the environment.

What is Jade, and what does FIPA stand for?

Jade [Bellifemine et al., 2007] is the Java Agent DEvelopment Framework: a Java-based framework to develop agent-based applications in compliance with the FIPA specifications for interoperable, intelligent, multi-agent systems. FIPA is the Foundation for Intelligent Physical Agents — the IEEE Computer Society standards organisation that promotes agent-based technology and interoperability.

What twofold goal does Jade pursue as an agent-oriented middleware?

Being a full-fledged FIPA-compliant agent platform — taking charge of application-independent aspects such as agent lifecycle management, communication, distribution transparency — and a simple yet comprehensive agent development framework providing Java developers a set of APIs to build customisations.

List Jade’s main features.

A distributed agent platform (a single logical Jade system split among different networked hosts); transparent distributed message passing service; transparent distributed naming service; white pages and yellow pages discovering facilities; intra-platform agent mobility (code and context, to some extent); debugging and monitoring graphical tools; and much more.

Describe the FIPA platform/container architecture.

A FIPA agent platform can be split onto several hosts: each host acts as a container of agents (a complete runtime environment for Jade agents execution); at least one container acts as the main container (the first started), responsible for maintaining a registry of all other containers in the same Jade platform, through which agents can discover each other. Hence Jade promotes a peer-to-peer interpretation of a MAS.

What are the roles of AMS, DF and ACC?

AMS (Agent Management System): a single one per platform, keeps track of all agents (even in remote containers); agents do not even exist until registered; provides the white pages service (location-transparent naming). DF (Directory Facilitator): a single one per platform, keeps track of all advertised services; provides the default yellow pages service, according to the publish/subscribe paradigm. ACC (Agent Communication Channel): the distributed message passing system controlling message exchange within the platform, providing asynchronous communication and managing FIPA ACL serialisation/deserialisation.

An agent in Jade: Java object and beyond.

Jade agents are first of all Java objects — user-defined agents must extend jade.core.Agent, inheriting ready-to-use methods. Beyond being objects: each agent is executed by a single Java thread; each has a globally unique name (agent ID, AID), by default local name @ platform name; business logic must be expressed in terms of behaviours; agents communicate by exchanging FIPA ACL messages.

Describe the six states of the FIPA agent lifecycle.

Initiated: object built, not registered to the AMS, no AID. Active: registered, can access all Jade features, executing its behaviours. Waiting: blocked, waiting for something to happen (typically an ACL message). Suspended: stopped, none of its behaviours being executed. Transit: started a migration process, stays until migration ends. Unknown: dead, deregistered to the AMS.

Why behaviours? How do Jade agents reconcile concurrency with a single thread?

Agents are autonomous and should act independently and concurrently; efficiency drives toward one Java thread per agent; but agents need complex, possibly concurrent activities. Behaviours solve this: a behaviour is an activity to perform with the goal of completing a task, proactive or reactive; Jade implements behaviours as Java objects executed concurrently, still by a single Java thread, using a non-preemptive, round-robin scheduler internal to the agent class but hidden to the programmer.

How does asynchronous communication work in the ACC?

Each agent has a message queue (a mailbox) where the ACC delivers ACL messages sent by other agents. Whenever a new entry is added, the receiving agent is notified — no need to block or keep asking. If and when the agent actually processes a message is up to the agent itself (or the programmer), for the sake of agent autonomy.

List the fields of an ACL message.

:sender (who sends, automatically set), :receiver (who it targets, possibly many), :performative (the communication act, constrained by a FIPA ontology), :content (the actual information), :language (the syntax encoding the content), :ontology (the semantic framework for the content), and other fields.

What are the Jade communication primitives?

send (send a message to a recipient); receive (asynchronously retrieve the first message in the mailbox, if any); timed receive (timed, synchronous receive; timeout causes the agent to resume execution); selective receive (retrieve a message matching a given message template, bypassing queue order). All are distribution-transparent: they choose the proper address and transport based on sender and receiver locations.

What is the Fast Lab for this case study?

Clone the repository https://dvcs.apice.unibo.it/pika-lab/courses/ise/ay2526/lab-jade and follow the lead: run the platform, create simple agents, and exercise behaviours and message passing.