Create an FSM App skill
Recall that an FSM App is the core part of an agent forming a service. Developing the FSM App is perhaps the most challenging step from the development process pipeline.
For this reason, in order to simplify and speed up the development of agent services, the Open Autonomy framework provides an FSM App scaffold tool that allows you to auto-generate functional, skeleton classes with all the boilerplate code in place. Therefore, you can focus on implementing the actual business logic of the of the service itself.
What you will learn
In this guide, you will learn how to use the FSM App scaffold tool to generate the skeleton classes that define the FSM App skill of an agent service.
Before starting this guide, ensure that your machine satisfies the framework requirements and that you have followed the set up guide. As a result you should have a Pipenv workspace folder.
Before you continue, ensure that you have an initialized local registry and that your terminal is located in the folder containing the local registry.
Create the FSM specification file. Create a file named
fsm_specification.yaml, which encodes the states, transitions and transition function of the FSM that defines the business logic of the service.
Example of an
Given a sketch of the FSM, the structure of the
fsm_specification.yamlfile is quite straightforward. Below we show the FSM specification file of the Hello World demo service.
alphabet_in: - DONE - NO_MAJORITY - RESET_TIMEOUT - ROUND_TIMEOUT default_start_state: RegistrationRound final_states:  label: packages.valory.skills.hello_world_abci.rounds.HelloWorldAbciApp start_states: - RegistrationRound states: - PrintMessageRound - RegistrationRound - ResetAndPauseRound - SelectKeeperRound transition_func: (PrintMessageRound, DONE): ResetAndPauseRound (PrintMessageRound, ROUND_TIMEOUT): RegistrationRound (RegistrationRound, DONE): SelectKeeperRound (ResetAndPauseRound, DONE): SelectKeeperRound (ResetAndPauseRound, NO_MAJORITY): RegistrationRound (ResetAndPauseRound, RESET_TIMEOUT): RegistrationRound (SelectKeeperRound, DONE): PrintMessageRound (SelectKeeperRound, NO_MAJORITY): RegistrationRound (SelectKeeperRound, ROUND_TIMEOUT): RegistrationRound
Generate the template classes. Using the scaffold tool to generate the skeleton for the classes for the skill:This command will generate the FSM App skill with its corresponding classes: rounds, payloads, behaviours, and the
autonomy scaffold -tlr fsm <fsm_app_skill_name> --spec fsm_specification.yaml
AbciAppclass. The FSM App skill will be generated in the folder
Fill in the business logic code of the FSM App. By default, the generated classes are initialized to empty values. It is your turn to define what actions are occurring at each state of the service, by filling up the code of the template FSM App skill generated above. You should also define a number of test classes. You can review how the demo services are implemented, or read about the internals of FSM Apps to learn more.
Push the generated skill to the remote registry. Once you have finished coding and testing the FSM App skill, you can push it to a remote registry. This will allow to add and reuse the FSM App skill in newly developed agents.