Skip to content

Naming collision in meta-agents add_atrributes#3239

Merged
tpike3 merged 2 commits intomesa:mainfrom
tpike3:meta-collision
Feb 5, 2026
Merged

Naming collision in meta-agents add_atrributes#3239
tpike3 merged 2 commits intomesa:mainfrom
tpike3:meta-collision

Conversation

@tpike3
Copy link
Copy Markdown
Member

@tpike3 tpike3 commented Feb 4, 2026

Summary

If users set assume_consituting_agent_attirbutes=True in create_meta_agent this creates naming collision in mesa Agent attributes.

Bug / Issue

Naming collisions will occur when new meta-agents are created and the meta-agent will assume critical attributes that mesa uses for bookkeeping For example, users create agent with agent.unique_id=1 and then create_meta_agent with assume_consituting_agent_attributes=True and agent 1 as a constituting_agent a naming collision occurs and no meta_agent unique_id is now 1.

Implementation

In the add_attributes function added mesa_primitives = [ "unique_id", "model", "pos", "name", "random", "rng", ] and then excluded these in attribute adoption loop and as well as _ to ignore internal use only attributes.

Testing

No testing changes

Additional Notes

With a planned focus on meta-agent, this is just a quick fix to address the immediate bug. add_methods has some protections to prevent a similar issue, but I did not give it a more thorough review to ensure they are sufficient.

@tpike3 tpike3 added the bug Release notes label label Feb 4, 2026
@github-actions
Copy link
Copy Markdown

github-actions bot commented Feb 4, 2026

Performance benchmarks:

Model Size Init time [95% CI] Run time [95% CI]
BoltzmannWealth small 🔵 -0.4% [-1.4%, +0.7%] 🔵 -0.8% [-1.0%, -0.6%]
BoltzmannWealth large 🔵 +1.3% [+0.4%, +2.2%] 🔵 +0.4% [-2.7%, +3.9%]
Schelling small 🔵 +0.8% [+0.5%, +1.2%] 🔵 -0.4% [-0.6%, -0.2%]
Schelling large 🔵 +0.0% [-0.3%, +0.4%] 🔵 -0.2% [-3.1%, +3.4%]
WolfSheep small 🔵 +1.3% [+0.4%, +2.3%] 🔵 -0.2% [-0.5%, +0.0%]
WolfSheep large 🔵 -2.9% [-4.1%, -1.7%] 🔵 -4.0% [-5.1%, -3.0%]
BoidFlockers small 🔵 +0.4% [-0.8%, +1.7%] 🟢 -4.0% [-4.2%, -3.7%]
BoidFlockers large 🔵 -0.5% [-1.4%, +0.5%] 🔵 -2.8% [-3.2%, -2.4%]

@tpike3 tpike3 changed the title Naming collision bug in meta-agents add_atrributes Naming collision in meta-agents add_atrributes Feb 4, 2026
Comment on lines +214 to +223
# Prevent collision of attributes with meta-agent instantiation
mesa_primitives = [
"unique_id",
"model",
"pos",
"name",
"random",
"rng",
]

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am fine with fixing it this way, but it is fragile. Any change on the model side has knock-on effects here.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can't disagree with it being fragile.

In preparation for a potential GSoC contributor I am rethinking the whole architecture.

@tpike3 tpike3 merged commit 6c0f97a into mesa:main Feb 5, 2026
15 checks passed
@tpike3 tpike3 deleted the meta-collision branch February 5, 2026 13:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Release notes label

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants