ASTRA Syntax at a Glance
This page is a quick map of the main forms in an ASTRA agent. Follow the links for explanations and examples.
Agent structure
An agent is declared in a .astra file whose name matches the agent class. Its body can contain module declarations, type declarations, initial beliefs and goals, plans, inference rules, and teleo-reactive functions:
agent Hello {
module Console console;
plan +!main(list args) {
console.println("Hello");
}
}
The keyword rule can be used in place of plan; the two are equivalent. The ASTRA archetype and the LLM libraries use rule.
See AgentSpeak(L) and ASTRA for the agent model and Declaring Variables for variable forms.
Common plan triggers
Form |
Meaning |
|---|---|
|
A belief was added. |
|
A belief was removed. |
|
A goal was adopted. |
|
A plan for an adopted goal completed. |
|
An adopted goal failed. |
|
An adopted goal has no plan that applies. |
|
A test goal needs a plan to find an answer. |
|
A message arrived. |
Plans may include a context after : and a body in braces. See Beliefs and Inference, Encapsulated Goals, Test Goals, Failure Handling, and Agent Communication.
Types and expressions
Declare formula signatures in a types block. Common types include int, long, float, double, char, boolean, string, list, and funct. See Types and Operators for the full table, expression precedence, and examples.
Describing beliefs, goals and rules
Since ASTRA 2.7.8, a types block can name the parameters of its formulas, declare goals with goal !name(...), and describe each entry with @Description. Rules take @Description too:
types grid {
@Description("The agent is in cell (x, y)")
formula at(int x, int y);
@Description("Be in the cell called place", hints=["Move one cell at a time"])
goal !reach(string place);
}
@Description("Report where the agent is")
rule +!where(string where) : at(int X, int Y) { where = X + "," + Y; }
Descriptions are for tools and language models, and do not change how the agent runs.
Statements
Common statements include sub-goals (!goal(...)), test goals (?formula(...)), belief updates (+belief(...) and -belief(...)), queries (query(...)), conditionals (if (...) { ... }), loops (while (...) { ... }), and module actions (module.action(...)). See Variables, Choice and Repetition for control flow and Failure Handling for try/recover.
The statements activate function(...); and deactivate; start and stop a teleo-reactive function. See Teleo-Reactive Functions.