-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
explicit meta_attributes/meta_methods are overwritten by inferred constituent values #3471
Copy link
Copy link
Closed
Description
Describe the bug
In create_meta_agent, when assume_constituting_agent_attributes=True or assume_constituting_agent_methods=True, inferred values from constituting agents can overwrite explicitly provided meta_attributes / meta_methods with the same key/name. This makes user-supplied configuration non-authoritative and can change behavior unexpectedly.
Expected behavior
Explicit meta_attributes and meta_methods passed by the caller should take precedence over inferred values. Inference should only fill missing keys/names.
To Reproduce
from mesa import Agent, Model
from mesa.experimental.meta_agents.meta_agent import create_meta_agent
class A(Agent):
def __init__(self, model):
super().__init__(model)
self.custom_attribute = "from_agent"
def custom_method(self):
return "from_agent"
model = Model()
a = A(model)
meta = create_meta_agent(
model,
"MetaBug",
[a],
Agent,
meta_attributes={"custom_attribute": "explicit"},
meta_methods={"custom_method": lambda self: "explicit"},
assume_constituting_agent_attributes=True,
assume_constituting_agent_methods=True,
)
print(meta.custom_attribute) # expected: "explicit"
print(meta.custom_method()) # expected: "explicit"Observed behavior (buggy behavior): explicit values may be replaced by inferred ones from constituent agents.
Additional context
- Area:
mesa.experimental.meta_agents.meta_agent.create_meta_agent(add_attributes/add_methodshelpers).
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels