Skip to content

Fix TypeError in find_combinations when evaluation_func is None#3112

Merged
tpike3 merged 2 commits intomesa:mainfrom
codebyNJ:fix/meta-agent-evaluate-combination-none-handling
Jan 19, 2026
Merged

Fix TypeError in find_combinations when evaluation_func is None#3112
tpike3 merged 2 commits intomesa:mainfrom
codebyNJ:fix/meta-agent-evaluate-combination-none-handling

Conversation

@codebyNJ
Copy link
Copy Markdown
Contributor

Summary

Fixed a TypeError that occurs when calling find_combinations() without an evaluation_func parameter.

Bug / Issue

In meta_agent.py, the find_combinations() function calls evaluate_combination() which returns None when evaluation_func is None. The code then attempts to unpack this None value:

group_set, result = evaluate_combination(candidate_group, model, evaluation_func)

This causes: TypeError: cannot unpack non-iterable NoneType object

Implementation

File changed: mesa_agent.py

Changed From:

group_set, result = evaluate_combination(candidate_group, model, evaluation_func)
if result:
    combinations.append((group_set, result))

To:

evaluation_result = evaluate_combination(candidate_group, model, evaluation_func)
if evaluation_result is not None:
    group_set, result = evaluation_result
    if result:
        combinations.append((group_set, result))

Testing

  • Added test test_find_combinations_without_evaluation_func that validates the fix
  • All 16 meta_agents tests pass
  • ruff checks pass

@github-actions
Copy link
Copy Markdown

Performance benchmarks:

Model Size Init time [95% CI] Run time [95% CI]
BoltzmannWealth small 🔵 +1.8% [+0.8%, +2.8%] 🔵 +0.1% [+0.0%, +0.2%]
BoltzmannWealth large 🔵 +0.5% [-0.4%, +1.2%] 🔴 +5.2% [+3.7%, +6.8%]
Schelling small 🔵 +1.0% [-0.1%, +2.1%] 🔵 +0.0% [-0.5%, +0.6%]
Schelling large 🔵 +1.2% [-0.4%, +3.9%] 🔵 +0.8% [-0.7%, +2.3%]
WolfSheep small 🔵 -0.5% [-0.8%, -0.3%] 🔵 -1.8% [-1.9%, -1.6%]
WolfSheep large 🔵 -1.4% [-7.0%, +4.6%] 🔵 -4.0% [-5.9%, -2.0%]
BoidFlockers small 🔵 +1.5% [+1.2%, +1.8%] 🔵 +1.3% [+1.2%, +1.5%]
BoidFlockers large 🔵 +2.0% [+1.4%, +2.6%] 🔵 +0.5% [+0.3%, +0.7%]

@quaquel
Copy link
Copy Markdown
Member

quaquel commented Jan 11, 2026

I am not sure this is the right fix. The entire function is pointless if evaluation_func is None. So, my guess is that either evaluation_func should become an argument or calling it with None should raise a ValueError. @tpike3, can you clarify your intent here?

@EwoutH EwoutH requested a review from tpike3 January 17, 2026 22:08
Copy link
Copy Markdown
Member

@tpike3 tpike3 left a comment

Choose a reason for hiding this comment

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

@codebyNJ Thanks for the catch and fix!

@tpike3 tpike3 merged commit ea1c165 into mesa:main Jan 19, 2026
14 checks passed
@EwoutH
Copy link
Copy Markdown
Member

EwoutH commented Jan 19, 2026

I am not sure this is the right fix. The entire function is pointless if evaluation_func is None. So, my guess is that either evaluation_func should become an argument or calling it with None should raise a ValueError. @tpike3, can you clarify your intent here?

I would still be interested in this.

@EwoutH EwoutH added the bug Release notes label label Feb 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

0 - Triage bug Release notes label

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants