mesa / mesa/mesa-llm

fix: codebase incompatible with Mesa 4.x (mesa.space removed)

Open
#152 0 comments 0 reactions 0 assignees View on GitHub
depedency mesa-4
Dominant language
Python
Stars
73
Forks
89
Avg merge
14d 58m
Merged PRs (30d)
2

Description

## Description

Mesa 4.x removed `mesa.space` entirely, which breaks the mesa-llm codebase with a `ModuleNotFoundError` on import. Running `python -m pytest tests/` on a fresh Mesa 4.x install fails with 24 test failures.

## Root Cause

The codebase uses the old Mesa 2.x/3.x space API:
- `from mesa.space import MultiGrid, SingleGrid, ContinuousSpace`

These classes no longer exist in Mesa 4.x.

## Fix

Migrate to the new Mesa 4.x APIs:

| Old | New |
|-----|-----|
| `mesa.space.MultiGrid` | `mesa.discrete_space.OrthogonalMooreGrid` |
| `mesa.space.SingleGrid` | `mesa.discrete_space.OrthogonalMooreGrid` |
| `mesa.space.ContinuousSpace` | `mesa.experimental.continuous_space.ContinuousSpace` |
| `grid.place_agent(agent, pos)` | `agent.cell = grid._cells[pos]` |
| `grid.get_neighbors()` | `cell.get_neighborhood(radius=vision)` |
| `model.steps` | `model.step` |

## Result

All 203 tests passing after migration.

## Files Affected
- `mesa_llm/llm_agent.py`
- `mesa_llm/tools/inbuilt_tools.py`
- `mesa_llm/recording/record_model.py`
- `tests/conftest.py`
- `tests/test_llm_agent.py`
- `tests/test_parallel_stepping.py`
- `tests/test_reasoning/test_cot.py`
- `tests/test_tools/test_inbuilt_tools.py`

Contributor guide

Open the contributing guide

Research direction

Start with the Mesa imports and grid usage in mesa_llm/llm_agent.py, mesa_llm/tools/inbuilt_tools.py, and mesa_llm/recording/record_model.py, then review the related fixtures and tests listed in the issue. Run python -m pytest tests/ before and after the migration. Done means the code uses Mesa 4.x APIs and all 203 tests pass.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
backend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.