There is one special state which we call initial state. The initial state is a state like any other, with one exception: It is the first state that the system is found to be in when it is instantiated. Instantiation means to make available the system, or one version of the system. You know this from creating new object instances from classes.
| Obviously, there is only one initial state. |
It is possible that the system enters the initial state at a later point of time.
Another special kind of state is the final state. There may be more than one final state which we call set of final states.
The final state is a state which is considered to denote some result state of the system. When the system reaches a final state, the computation was successful and the system may stop here. It is possible that the system enters a non-final state after it was already in a final state.
| For practical reasons, the set of final states may be restricted to one. This is assumed for the context API. |
One step back. You probably remember your courses in automata theory. What we constructed here is a finite automaton:
A finite automaton is a 5-tuple
The input alphabet corresponds with the set of input message types.
Moreover, together with the output functionality, we get another kind of construct which we call transducer. A transducer can be used to translate input data to output data. Specifically, if the output is connected with the transition, we get a Mealy machine, while a Moore machine puts output in connection with reaching a state. It can be shown that both variants are equivalent.
Stability
States may be partitioned in three categories:
You remember some words of agent programming:
You shall not make your agent wait forever.

Stable state
Following this rule, there must not be any stable state in the agent because this will cause the agent to hang if it does not get further messages. But this can be handled differently: You can define timeouts, or you can start multiple threads or contexts. This will allow the agent to wait for the answer while continuing with another job.
Unstable states do not wait for messages. More specifically, they do not consume messages, leaving them in the queue unchanged.

Unstable state
Unstable states must not be the origin state of any transition which defines some non-empty input. In other words, all transitions leaving from the unstable state have null input; we call this epsilon transition. If the output type is also null, we have an empty transition. This is derived from the grammar research where the empty word is usually denoted by the Greek letter epsilon.

Semistable state
Here, we have a hybrid type of state: On one hand, the agent in this state would consume some incoming, matching message; on the other hand, it could also change to another state by an epsilon transition. That is, a semistable state must have at least two outgoing transitions.
| The message type need not be null; it can happen that the message is directed to another receiver or coming form another sender. But effectively, this is a null message for any other communication partner. |
We will take a closer look at senders and receivers.