docs: document how to use agents

ref: N25B-300
This commit is contained in:
2025-11-21 13:28:37 +01:00
parent 1c510c661e
commit 98d087417f
3 changed files with 32 additions and 10 deletions

View File

@@ -5,7 +5,8 @@ from control_backend.core.agent_system import BaseAgent as CoreBaseAgent
class BaseAgent(CoreBaseAgent):
"""
Base agent class for our agents to inherit from.
Base agent class for our agents to inherit from. This just ensures
all agents have a logger.
"""
logger: logging.Logger

View File

@@ -85,8 +85,6 @@ class BDICoreAgent(BaseAgent):
new_args = (agentspeak.Literal(arg) for arg in args)
term = agentspeak.Literal(name, new_args)
assert self.bdi_agent is not None
self.bdi_agent.call(
agentspeak.Trigger.addition,
agentspeak.GoalType.belief,
@@ -102,8 +100,6 @@ class BDICoreAgent(BaseAgent):
new_args = (agentspeak.Literal(arg) for arg in args)
term = agentspeak.Literal(name, new_args)
assert self.bdi_agent is not None
result = self.bdi_agent.call(
agentspeak.Trigger.removal,
agentspeak.GoalType.belief,
@@ -121,8 +117,6 @@ class BDICoreAgent(BaseAgent):
"""
Removes all beliefs that match the given `name`.
"""
assert self.bdi_agent is not None
relevant_groups = []
for key in self.bdi_agent.beliefs:
if key[0] == name:
@@ -142,7 +136,11 @@ class BDICoreAgent(BaseAgent):
self.logger.debug(f"Removed {removed_count} beliefs.")
def _add_custom_actions(self) -> None:
"""Add any custom actions here."""
"""
Add any custom actions here. Inside `@self.actions.add()`, the first argument is
the name of the function in the ASL file, and the second the amount of arguments
the function expects (which will be located in `term.args`).
"""
@self.actions.add(".reply", 1)
def _reply(agent, term, intention):