1 Introduction
2 Issues in debugging cognitive agent programs
2.1 Debugging and program comprehension
2.2 Challenges in designing a source-level debugger
finished
goal can originate as the result of two different points in the agent program (due to the random execution order of the main module, i.e., either the post-condition of the finish
action or the insert
action).
2.3 Languages and debugging tools for cognitive agents
2.3.1 2APL
2.3.2 Agent Factory
2.3.3 GOAL
2.3.4 JACK
2.3.5 Jadex
2.3.6 Jason
2.3.7 JIAC
2.3.8 Overview
3 Design approach for a debugger for cognitive agents
3.1 Principles and requirements
3.2 Designing a stepping diagram
Step 1
). The relevance of these code-based breakpoints to a user’s stepping process needs to be evaluated, leading to a set of points at which events that are important to an agent’s behaviour take place (Step 2a
). In addition, the agent’s decision cycle needs to be evaluated for important events that are not represented in the agent’s source in order to determine cycle-based breakpoints (Step 2b
). These points will then be used to define a stepping flow, i.e., identifying the result of a stepping action on each of those points in a stepping diagram (Step 3
). Finally, other required features such as user-defined breakpoints (Step 4
), visualization of the execution flow (Step 5
) and state inspection (Step 6
) need to be handled. As an example, we will provide a detailed design for the Goal agent programming language in this part, and afterwards we will discuss the design of a source-level debugger for some other agent programming languages that were discussed in Sect. 2 as well.3.2.1 Step 1: syntax tree
(
term
)
]’ represents a call to either a user-specified (environment) action or a module in the grammar (at action). In addition, each node in the syntax tree represents a specific type, but not an instance. For example, one module usually consists of multiple rules, as indicated by the labels on the edges. An edge indicates a syntactic link, whilst a broken edge indicates a semantic link. Relevant semantic links need to be added in order to represent program execution flow that is not based on the syntax structure alone.
module
| := |
useclause
\(^+\)
option
\(^*\)
module
id
(
term
)
{
rule
\(^+\)
}
|
useclause
| := | use
id [as
usecase] .
|
usecase
| := | knowledge | beliefs | goals | actionspec | module
|
option
| := | exit
=
exitoption
. | focus
=
focusoption
. | order
=
orderoption
.
|
rule
| := | if
csq
then actioncombo
. | forall
csq
do
actioncombo
.
|
csq
| := |
stateliteral ( ,
stateliteral)\(^*\)
|
stateliteral
| := |
stateop
(
term
) | not
(
stateop
(
term
) ) | true
|
stateop
| := | bel | goal | a-goal | goal-a | percept | sent
|
actioncombo
| := |
action ( +
action)\(^*\)
|
action
| := |
id[ (
term
) ] | generalaction
(
term
)
|
generalaction
| := | insert | delete | adopt | drop | send
|
term
| := |
a (composite) KR expression
|
specification
| := |
useclause
\(^+\)
actionspec
\(^+\)
|
useclause
| := | use
id [as
knowledge ] .
|
actionspec
| := | define
id[(
term
) ] with
pre
{
term
}
post
{
term
}
|
term
| := |
a (composite) KR expression
|
3.2.2 Step 2a: code-based breakpoints
3.2.3 Step 2b: cycle-based breakpoints
3.2.4 Step 3: stepping flow
-
Into traverse downward from the current node in the syntax diagram until we hit the next breakpoint. In other words, follow the edges going down in the tree’s levels until an indicated node is reached. If the current node is a leaf (i.e., we cannot go down any further), perform an over-step.
-
Over traverse to the next node (i.e., to the right) on the current level until we hit the next breakpoint. If there are none, perform an out-step.
-
Out traverse upward from the current node until we hit the next breakpoint, whilst remaining in the current context. In other words, the edges going back up in the tree’s levels should be traced until any applicable node, and then from there back down again until any indicated node is reached (like an into-step). Here, applicable refers to a ‘one-to-many’ edge of which not all cases have been processed yet.
3.2.5 Step 4: user-defined breakpoints
3.2.6 Step 5: visualization
3.2.7 Step 6: state inspection
3.3 Application to other agent programming languages
agent
| ::= |
belief
\(^*\)
plan
\(^+\)
|
belief
| ::= |
literal
.
|
plan
| ::= |
triggering_event
:
context <- body
.
|
triggering_event
| ::= | (+ | -) [! | ?] literal
|
context
| ::= |
literal (&
literal)\(^*\)
|
body
| ::= |
body_formula (;
body_formula)\(^*\)
|
body_formula
| ::= | [! | ? | + | -] literal
|
literal
| ::= |
a (composite) KR expression
|
Step 1
) based on this grammar is illustrated on the top part of Fig. 7. In that tree, the code-based breakpoints (Step 2a
) have been indicated as well, i.e., at each node that corresponds with an inspection or modification of an agent’s cognitive state. As represented in the decision cycle of a Jason agent in Fig. 6, Jason has three selection functions (i.e., for events, options, and intentions), a belief revision function, and it also has a goal achievement mechanism and a mechanism for handling events that have no applicable plans; these all represent cycle-based breakpoints (Step 2b
), as they represent important behaviour that is not present in an agent’s syntax tree. A toggle (setting) should be added for each of these events in order to allow suspending execution on them.
Step 3
). We assume that when for a certain event, the event triggers of an agent’s plans are evaluated, a successful evaluation of a trigger will lead to directly evaluating the corresponding context2. However, successful evaluation of both an event trigger and the context of a plan will not always directly lead to the execution of the corresponding plan body, as the deeds in the body will be processed into the intention set (by the option selection function), from which in turn a different deed might be selected to execute next (by the intention selection function). The execution of a deed usually leads to a new event, and thus the stepping flow will start again at the first node. Even when a plan is atomic (i.e., indicating that all actions in the plan’s body should be executed directly after each other), this flow will remain the same, as atomic plans only override the intention selection mechanism; each deed will still (generally) lead to a new event being generated, and thus the start of a new decision cycle.Step 5
). For user-defined breakpoints and state inspection (Step 4
and Step 6
), the same principles as for Goal can be applied to Jason.3.4 Implementation for GOAL
4 Evaluation
4.1 Quantitative
Question | Mean | Range |
---|---|---|
1. Total Time Spent | 11.1 | Number of hours |
2. Debugging and Testing | 34.5 % | Percentage of total time |
3. Using Debugger | 25.6 % | " " |
7. Debugger Effectiveness | 3.2 | 1 (not) to 5 (very) effective |
5f. Debug: Watch Express. | 2.8 | 1 (least) to 6 (most) useful feature |
5b. Debug: Interact. Console | 3.0 | " " |
5d. Debug: Breakpoints | 3.0 | " " |
5a. Debug: Logging | 3.7 | " " |
5e. Debug: State Inspection | 4.1 | " " |
5c. Debug: Stepping | 4.3 | " " |
6f. AOP: Multiple agents | 2.2 | 1 (least) to 6 (most) easy aspect |
6b. AOP: Ext. Environments | 3.3 | " " |
6d. AOP: Decision Cycles | 3.6 | " " |
6e. AOP: Rule-based Reas. | 3.7 | " " |
6a. AOP: Use of KR | 4.0 | " " |
6c. AOP: Cognit. States | 4.2 | " " |
4.2 Qualitative
-
I liked the visual Goal environment as it is much more relatable than a simple console. I liked its simplicity in separating logical processes.
-
Debugging with multiple agents was not as good as we expected it to. It was hard to see what each agent believed and percepted. You had to pause one agent, but the others would just continue to gather blocks. So by trying to debug you interfered with the program and you might get a different outcome that way. That is not what you want to happen when you are debugging.
-
Being able to look at the beliefs, goals, percepts and messages when the bots are paused was very helpful for debugging, as was seeing those update while stepping through a bot’s code. This especially helped with starting to learn the platform, as it was easy to see the effect of each line of code.
-
I found the debugger ineffective as when you use the debugger the agents act differently from without using the debugger. Also because when one agent hits a breakpoint the others keep going, making it very hard to determine what went wrong in the communication or teamwork.
-
We loved the debugging, this was really easy to understand and you could easily find the bugs. The pausing and stepping is clear and very useful!
-
I found it very annoying that the debugger and stepping apparently could yield very different behaviour, but it was something that you could work around with eventually. In a way it was a good thing because it also reminds you of its multi-threaded nature; make no assumptions about synchronization. I think this is partly what caused the most trouble for people using Goal. Using the debugger is an essential tool for figuring out when a rule is fired, namely by putting a (conditional) breakpoint at the ‘then’-line. I liked this a lot!