From 626bbc0d09fbd57958fb34a9cb02d09ce48e414f Mon Sep 17 00:00:00 2001 From: mrebollo Date: Tue, 7 Apr 2026 19:59:58 +0200 Subject: [PATCH 1/3] fix: change Literal(agent.name) to str(agent.name) in .my_name function to return string instead of Literal --- agentspeak/stdlib.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/agentspeak/stdlib.py b/agentspeak/stdlib.py index 4050456..e91385e 100644 --- a/agentspeak/stdlib.py +++ b/agentspeak/stdlib.py @@ -187,7 +187,8 @@ def _fail(agent, term, intention): @actions.add(".my_name", 1) @agentspeak.optimizer.function_like def _my_name(agent, term, intention): - if agentspeak.unify(term.args[0], Literal(agent.name), intention.scope, intention.stack): + # MRP: sustituido Literal(agent.name) por str(agent.name). + if agentspeak.unify(term.args[0], str(agent.name), intention.scope, intention.stack): yield From d3be25c6ab405a85c86a5c13c60d2ec825dd6ec3 Mon Sep 17 00:00:00 2001 From: mrebollo Date: Wed, 8 Apr 2026 13:10:14 +0200 Subject: [PATCH 2/3] fix: enable .my_name in counting example to validate name resolution --- examples/counting/counting.asl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/counting/counting.asl b/examples/counting/counting.asl index 4b64c93..e1193b8 100644 --- a/examples/counting/counting.asl +++ b/examples/counting/counting.asl @@ -13,6 +13,6 @@ max_count(5). -+actual_count(NewCount); !count. -+!count : actual_count(X) & max_count(Y) & X >= Y. /* ++!count : actual_count(X) & max_count(Y) & X >= Y <- .my_name(Name); - .print(Name, " terminated count"). */ + .print(Name, " terminated count"). From eeefffddbead7c18aa83b50b952900e765c46091 Mon Sep 17 00:00:00 2001 From: mrebollo Date: Wed, 8 Apr 2026 17:14:09 +0200 Subject: [PATCH 3/3] fix: add source(self) annotation when adding beliefs without source --- agentspeak/runtime.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/agentspeak/runtime.py b/agentspeak/runtime.py index 7de126b..62feda1 100644 --- a/agentspeak/runtime.py +++ b/agentspeak/runtime.py @@ -622,6 +622,13 @@ def add_belief(self, term, scope): if term.functor is None: raise AslError("expected belief literal") + # Add source(self) annotation if not already present + has_source = any(ann.functor == "source" for ann in term.annots) + if not has_source: + term = term.with_annotation( + agentspeak.Literal("source", (agentspeak.Literal("self"), )) + ) + self.beliefs[(term.functor, len(term.args))].add(term) def test_belief(self, term, intention):