Reflecting on Agent Programming with AgentSpeak(L)
Summary (3 min read)
1 Introduction
- The Agent-Oriented Programming (AOP) paradigm is nearly 25 years old.
- Over the years, it has become apparent that developers become uneasy when stripped of their traditional supports and that this engenders a feeling that the languages are not production quality.
- The authors focus on understanding the relationship between AgentSpeak(L) and OOP with the goal of trying to reduce the perceived cognitive gap.
2 Relating AgentSpeak(L) to OOP
- AgentSpeak(L) can be prosaically described as an event-driven language where event handlers are fired based on both the triggering event and some context.
- It follows then, that an AgentSpeak(L) agent consists of an event queue, a set of beliefs , a set of plan rules (event handlers), and a set of intentions that are used to represent the execution of plan rules.
- In OOP, state is defined in terms of a set of fields that hold values (or object references).
- To be fully precise, beliefs and fields are not the same.
- The benefit of doing this is that someone who is proficient in OOP can use these mappings as a starting point for their study of the language.
3 Exploring the Implications
- The mapping developed in Section 2 is not only potentially useful to developers aiming to learn AgentSpeak(L), but it is also useful from a language developer’s perspective as it raises questions about the set of features that may be appropriate for AgentSpeak(L)-style languages.
- The authors explore some of the consequences of adopting the above mapping.
3.1 Beliefs are like fields
- Understanding the role of beliefs in AOP languages can be one of the most challenging concepts to grasp.
- As was discussed above, one simple way of associating beliefs with object state is to demonstrate that beliefs are like fields.
- In AgentSpeak(L), it is possible to do something similar, namely to declare a fact, whose predicate corresponds to the field name, and which takes a single argument, the value associated with the field, for example name("Rem");.
- Within AOP, type systems can be applied at the agent level, and at the language level.
- The potential benefits of this are: – improved readability: the meaning of the belief is clearer when the types are known.
3.2 Plans Rules as Methods
- To investigate this in more detail, the authors decided to implement a common algorithm using AgentSpeak(L).
- Hidden code arises because AgentSpeak(L) has such limited semantics that it is not able to directly perform simple operations such as swapping two values.
- Loss of readability due to the number of rules and the convoluted control flow that results from it understanding the agent code is far more difficult than understanding the pseudo code.
3.3 Intentions as Threads
- In the mapping, the authors equate intentions with threads.
- Agents are commonly presented as being active objects, with their own thread of control.
- The reality is that AgentSpeak(L) agents are more like multi-threaded processes, with each intention being an individual thread.
- One solution would be to introduce support for mutual exclusion into AgentSpeak(L).
- This would overcome the issue, but would require the mutual exclusion to be applied prior to the first invocation of the !outerLoop(L, S, X) sub-goal.
3.4 Events are like messages
- Perhaps the most contentious part of the mapping is the association of AOP events and OOP messages.
- Further, the design of AgentSpeak(L) did not consider inter-agent communication.
- Here, a subset of KQML is identified and the chosen speech acts are closely integrated with the language.
- Receipt of a tell message results in the adoption a belief based on the content of the message together with an annotation identifying the sender of the message.
- This approach fits the mapping presented in this paper because the semantics of the receipt of messages are hidden from the programmer.
4 ASTRA: AgentSpeak(L) with bells and whistles
- The mapping presented in this paper is aimed at reducing the cognitive gap for developers who are familiar with OOP and who wish to learn an AOP language.
- In order to evaluate whether such a mapping can help, the authors have developed a new implementation of AgentSpeak(L) called ASTRA.
- In line with the rest of this paper, the syntax of ASTRA is based upon Java syntax, which has been chosen so that the language will seem more familiar to the user.
- The authors present only the most pertinent details of ASTRA that reflect the points made in the paper.
- For more information on the language, the reader is directed to [6].
4.1 The ASTRA Type System
- ASTRA as a statically typed language that provides a typical set of primitive types for use.
- Instances of objects cannot be directly represented within the language but can be stored and passed to internal and environment operations.
- The design of these libraries is inspired by the use of annotations in CArtAgo [17].
- Terms represent basic calculations that can return a value.
- Formula methods are constructors that return any logical formula instance in ASTRA (these can be simple boolean values or more complex formulae).
4.2 Extended Plan Syntax
- ASTRA includes a number of extensions to the traditional AgentSpeak(L) plan syntax.
- The usefulness of constructs such as these is emphasised by Jason’s inclusion of some of these procedural-style constructs (e.g. if statements, loops) in its extended version of AgentSpeak(L).
- While loop traditional method of repetition in programming Foreach loop repeats the same actions for every matching binding of a formula.
- Try-recover block allows for the recovery from failed actions Local variable declaration declares a variable for use within a plan rule Assignment allows the value of a local variable to be changed Query bind the values of beliefs to variables.
- Wait pauses execution until condition if true.
4.3 Mutual Exclusion Support
- In Section 3.3, the link between intentions and threads was established.
- Code contained within a synchonized block can only be executed by a single intention at a time.
- Once an intention enters a synchronized block, all synchronized blocks with the same identifier are locked and cannot be entered until the current intention is completed.
- Figure 5 shows an example of ASTRA code with race conditions.
- This program invokes the !init goal twice, creating 2 intentions.
5 Evaluation
- In order to evaluate the concepts discussed in this paper, a survey was conducted using 20 students from the M.Sc. in Advanced Software Engineering programme in University College Dublin.
- The students are full-time software engineers with an average experience of 7.65 years in industry.
- Q1 Agents are a useful level of abstraction.
- The results from the second group of questions show that 75% of the participants believe that static typing is important.
6 Conclusions
- The authors have presented a practical conceptual mapping between AgentSpeak(L) and Object-Oriented Programming (OOP).
- Certainly, Jason includes support for atomic behaviours and has an extended suite of plan operators.
- The principal outcome of their work has been to drive the development of ASTRA, an implementation of AgentSpeak(L) that is targeted towards reducing the cognitive gap.
- Students learned ASTRA over a 5-day period, during which they wrote a range of programs.
- The authors believe that the feedback positively reflects their decision to include both the language level type system and the suite of plan operators into ASTRA.
Did you find this useful? Give us your feedback
Citations
2 citations
Cites methods from "Reflecting on Agent Programming wit..."
...For validation, a prototype has been developed that has been integratedwith the ASTRA agent programming language [6][5][12]....
[...]
2 citations
Cites methods from "Reflecting on Agent Programming wit..."
...Specifically we will use the ASTRA language [8], which is a variation of AgentSpeak(L) [26] together with CArtAgO [27] a framework that supports the modeling of the agents environment in terms of shared objects known as artifacts....
[...]
1 citations
Cites background from "Reflecting on Agent Programming wit..."
..., CAN [11], Jason [1], ASTRA [2], and Gwendolen [3]) — have pitfalls that long-term experience has helped surface....
[...]
...The plan model adopted in all concrete BDI-based computational platforms — from the very early days (e.g., PRS [7], dMARS [4], AgentSpeak(L) [9], JAM [6], JACK [13], and SPARK [8]) to more recent programming languages (e.g., CAN [11], Jason [1], ASTRA [2], and Gwendolen [3]) — have pitfalls that long-term experience has helped surface....
[...]
...CCS CONCEPTS •Computingmethodologies→ Intelligent agents; • Software and its engineering → Context specific languages; KEYWORDS Agent-Oriented Programming; Agent Programming Languages; BDI; AgentSpeak(L); Jason; ASTRA; AgentSpeak(ER) ACM Reference Format: Rafael H. Bordini, Rem Collier, Jomi F. Hübner, and Alessandro Ricci....
[...]
...In particular, two extensions have been developed: Jason(ER) and ASTRA(ER), available as an opensource project.1 To have a taste of the extension, in the following we revisit the CNP example in Jason(ER) — other examples are available in the project distribution....
[...]
...Similar results are obtained with ASTRA(ER)....
[...]
Cites background from "Reflecting on Agent Programming wit..."
...been largely overlooked by industry efforts [9], already advocated for several principles that are today observed in the microservices paradigm, such as decentralization over monolithic organization, distributed environments, amongst others [6]....
[...]
...vices paradigm as a framework for building modern MAS, in an attempt to shorten this gap between industry and academic efforts [6][9][18]....
[...]
References
1,846 citations
1,342 citations
"Reflecting on Agent Programming wit..." refers background in this paper
...10 A[j+1] = temp 11 return A 1 !do_sort ([7, 5, 12, 15, 3]);...
[...]
...Perhaps the most common explanation of the relationship between AOP and OOP is the comparison table presented in [12]....
[...]
1,173 citations
875 citations
"Reflecting on Agent Programming wit..." refers background in this paper
...During the course, the students are exposed to an AgentSpeak(L)-based language, which has been one of AF-AgentSpeak [5], Jason [4], and our most recent agent-programming language, ASTRA [6]....
[...]
...ASTRA is based upon Jason, but includes a number of features that are inspired by the mapping presented in this paper....
[...]
...The usefulness of constructs such as these is emphasised by Jason’s inclusion of some of these procedural-style constructs (e.g. if statements, loops) in its extended version of AgentSpeak(L)....
[...]
...The first approach is the approach adopted in Jason....
[...]
...Certainly, Jason includes support for atomic behaviours and has an extended suite of plan operators....
[...]
394 citations
"Reflecting on Agent Programming wit..." refers background in this paper
...Since its inception, a number of established AOP languages have emerged, with the most prominent being: 2/3APL [1, 2], GOAL [3] and Jason [4]....
[...]
Related Papers (5)
Frequently Asked Questions (11)
Q2. What have the authors stated for future works in "Reflecting on agent programming with agentspeak(l)" ?
The authors believe that the feedback positively reflects their decision to include both the language level type system and the suite of plan operators into ASTRA.
Q3. Why is it an issue in AgentSpeak(L)?
2. Returning results is an issue in AgentSpeak(L) because the basic version of the language does not allow values to be returned from a sub-goal call.
Q4. What is the consequence of this diversity?
The consequence of this diversity is that it is more appropriate to compare specific styles of AOP language with OOP rather than trying to over-generalise.
Q5. What is the main benefit of AgentSpeak(L) mapping?
In addition to the benefit such a mapping provides for those wishing to learn AgentSpeak(L), a second benefit is that it provides language designers with valuable insights into how their languages might be used in practice.
Q6. What is the way to handle the receipt of a tell message?
Invoking a behaviour based on the receipt of a tell message thus requires the creation of a plan rule whose triggering event matches the belief adoption event created by the receipt of the message.
Q7. What is the advantage of adding new event types?
The benefit of adding new event types is that the events can be specified in a way that all of the relevant data is encoded in the event.
Q8. What are the typical criticisms of AOP?
The common response has been “no”, with typical criticisms being the lack of tool support and the perceived learning curve required to master an AOP language.
Q9. What is the purpose of this mapping?
The purpose of this mapping has been to attempt to find a way of reducing the cognitive gap for developers, experienced in OOP, who wish to learn Agent-Oriented Programming (AOP).
Q10. What are the types of actions that can be performed?
Actions represent internal actions that can be performed, returning a boolean value indicating if the action was successfully performed.
Q11. How many participants believe that static typing makes ASTRA code easier to read?
Regardless of the necessity of static typing, 65% of the participants believed that static typing made ASTRA code easier to read.