## AgentSpeak(L): programming with beliefs, desires and intentions

Anand S. Rao (1996). AgentSpeak(L): BDI Agents speak out in a logical computable language.

Rao's AgentSpeak(L) is a Prolog-like resolution-based language, but which is extended to support agent-based programming in several ways, most importantly:

1. It extends the language, so that clauses can talk about not just satisfaction of predicates, but also of an agent desiring to bring about a predicate, and desiring to find out whether a predicate is true; and to distinguish between normal goals and special goals relevant to the BDI model (Belief-Desire-Intention model);
2. It amends the resolution engine to support what Rao calls reactive concurrency, where agents form plans via a process resembling SLD-resolution, but plans are formed or abandoned on the basis of agent-internal reactions called triggering events.

Rao and Georgeff's work on BDI agents and procedural reasoning together constitutes one of the most important contributions to the theory of agents in AI, a topic which hasn't been discussed much here on LtU, but was raised in the Agent Oriented Programming story.

## Comment viewing options

### Jason

The Jason language is an interpreter for an extended version of AgentSpeak(L). There is a lot of research around this language, such as integrating ontological reasoning (via a description logic reasoner), support for belief revision, adding support for more sophisticated scheduling of intentions (AgentSpeak(XL)), and so on. Also related is 2APL ("double AP, L" - A Practical Agent Programming Language), which has similar goals and almost identical syntax. Both languages embed a Prolog-subset as the belief base and then layer a rule language over the top.

Having used Jason a lot in the last couple of years, I'd say it still has a way to go until it is a really general purpose language. Some things are good, such as the support for persistent belief bases (via JDBC), relatively straight-forward distribution, and the high-level speech-act based communications layer. On the negative side, there is no element of decomposition apart from the agent (above the rule level), and it is difficult to compose agents into larger agents. Some sort of module system would be good for this. I also worry about slinging everything into a single global belief base. Finer control over scope of beliefs (perhaps per-module belief bases) would be nice (I believe there is some experimental code along these lines). On a smaller scale, using the Prolog subset for everything is a bit cumbersome, especially as many useful standard predicates are missing or limited. Concurrency support is also not as good as it could be: concurrent intentions have to communicate via the belief base, which then requires you to think about consistency and interleaving of execution. While Jason supports atomic annotations on plans, it still feels a bit low-level (essentially these annotations are equivalent to Java synchronized blocks). It would be nice to have something like futures or dataflow variables for this purpose (I think Jason could learn a lot from Oz). Support for user-defined functions in the term language would also be convenient (there is some limited support for expressions already), rather than using Prolog and having to name intermediate results. Also, the Prolog implementation in Jason doesn't support cut, making certain operations hard to implement efficiently (I've had to drop out to Java a fair bit). Personally, I'd prefer the belief base sub-language to be based on Datalog rather than Prolog, as the inference procedure is nicer (always terminates), and would be better suited for persistent implementations. Finally, the definition of the language (Jason) leaves several crucial elements of the semantics left as user-defined functions (e.g., picking which events to process, which plans to select, etc). This makes it hard to analyse the behaviour a program without knowing exactly which functions will be used in the implementation. Overall, I'm not entirely convinced that Jason represents much of an advantage over just writing things in e.g. Prolog, Scheme or (Alice) ML and adding some small convenience helpers for belief-bases etc.

### Different language

Confusingly, Rao was involved in the design of not one, but two languages called AgentSpeak: the Prolog like AgentSpeak(L) this story introduces, and the concurrent rules-based OO AgentSpeak that Jason implements. Both are abstractions from the existing dMARS systems that Rao was involved in implementing. I think Jason is not based on dMARS.

The older AgentSpeak was written up in D Weerasooriya, A Rao, K Ramamohanarao (1994); Design of a Concurrent Agent-Oriented Language.

### AgentSpeak(L)

No, Jason is definitely based on AgentSpeak(L) rather than the older AgentSpeak. Almost all references to "AgentSpeak" in the literature seem to refer to AgentSpeak(L) rather than the older OO language.

### Mea culpa

That would have taken me about 90 seconds to check...

Looking at the Jason FAQ rather reminds me of the worst corners of Prolog programming, which, in turn, suggests that maybe layering the BDI model on, say, AliceML would work out better.

Are there any respects in which doing this would be more awkward to code? It looks like it would be straightfoward to translate Jason clauses, but maybe I am missing something.

### AS(L) over Alice ML

I don't think it would be too hard. Alice ML's support for concurrency, distribution, and SQLite (for persistent beliefs) make it quite attractive as a platform for BDI agents. You could write a simple definitional AgentSpeak(L) interpreter quite quickly, I imagine. It could be a really nice environment.

### Toys

Overall, I'm not entirely convinced that Jason represents much of an advantage over just writing things in e.g. Prolog, Scheme or (Alice) ML and adding some small convenience helpers for belief-bases etc.

I can't speak for Jason, but AgentSpeak(L) is really a toy language, meant to illuminate what agent-based programming and the BDI model are about rather than to be used in serious implementations.

### This is true of

This is true of AgentSpeak(L). It provides a nice simple formal semantics of a language based on the PRS/dMARS/IRMA BDI model. Jason, on the other hand, definitely aims to be a practical programming language, and I believe one of the aims of AgentSpeak(L) was to bridge the "gap between theory and practice". (The theory here being the various modal BDI logics, described elsewhere by Georgeff and Rao, as well as e.g. Cohen and Levesque's theory of intentions, both based on Bratman's theory - see e.g. this chapter from the Handbook of Knowledge Representation for an overview). The introduction of AgentSpeak(L) is important, as the possible worlds semantics of modal logics can be difficult to transform into computational models, so providing an operational semantics helps a lot in transferring theory to practice.