mesa / mesa/mesa-llm

bug: ContinuousSpace boundary check allows agents to move outside bounds

Open
#198 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
73
Forks
89
Avg merge
14d 58m
Merged PRs (30d)
2

Description

Describe the bug

move_one_step() in inbuilt_tools.py uses pos[i] > hi for the upper
boundary check in ContinuousSpace. This allows an agent to land exactly
on the boundary value, which is outside the valid space.

To Reproduce

from mesa.model import Model
from mesa.agent import Agent
from mesa.experimental.continuous_space import ContinuousSpace
from mesa_llm.tools.inbuilt_tools import move_one_step

class DummyModel(Model):
    def __init__(self):
        super().__init__()

class DummyAgent(Agent):
    def step(self): pass

model = DummyModel()
model.space = ContinuousSpace(dimensions=[[0, 10.0], [0, 10.0]], torus=False)

agent = DummyAgent(model=model)
agent.pos = (2.0, 9.0)

move_one_step(agent, "North")
print(agent.pos)  # prints (2.0, 10.0) — WRONG, agent is outside bounds

Expected behavior

Agent at (2.0, 9.0) moving North in a [0, 10.0] space should stay at
(2.0, 9.0) — the boundary is reached, movement should be blocked.

Actual behavior

Agent moves to (2.0, 10.0) which is outside the defined space dimensions.

Root cause

_is_out_of_bounds() checks pos[i] > hi instead of pos[i] >= hi.
Since the upper bound is exclusive, a position exactly equal to hi is
out of bounds but the check misses it.

Fix

Change pos[i] > hi to pos[i] >= hi in _is_out_of_bounds().

This fix is included in PR #195.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in mesa_llm/tools/inbuilt_tools.py and inspect _is_out_of_bounds(), then reproduce the boundary case from the issue with ContinuousSpace and move_one_step(). Done means an agent at the upper boundary does not move outside the defined dimensions; note that the issue says this fix is already included in PR #195.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
tooling
Issue type
Bug
Difficulty
1/5
Estimated time
Under an hour
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.