mesa / mesa/mesa-llm

bug: Reasoning.execute_tool_call() and aexecute_tool_call() use model.steps which does not exist in Mesa 4.x

Open Beginner friendly
#216 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

## Describe the bug

`reasoning.py` base class uses `self.agent.model.steps` in both
`execute_tool_call()` and `aexecute_tool_call()`. `model.steps` was
removed in Mesa 4.x, causing `AttributeError` on every tool call
execution across all reasoning strategies — CoT, ReAct, and ReWOO all
call these methods internally.

## To Reproduce
```python
from mesa.model import Model
from mesa_llm.llm_agent import LLMAgent
from mesa_llm.reasoning.cot import CoTReasoning

class MyModel(Model):
def __init__(self):
super().__init__()
self.agent = LLMAgent(
model=self,
reasoning=CoTReasoning,
step_prompt="Do something"
)

model = MyModel()
model.agent.step() # crashes here — model.steps does not exist
```

## Expected behavior

Tool call execution should work correctly in Mesa 4.x using the internal
`_time` attribute as the step counter.

## Actual behavior
```
AttributeError: 'MyModel' object has no attribute 'steps'
```

## Root cause

`reasoning.py` lines 126 and 149:
```python
# Both occurrences — incorrect
plan = Plan(step=self.agent.model.steps, llm_plan=response_message, ttl=ttl)
```

## Fix
```python
plan = Plan(step=int(getattr(self.agent.model, "_time", 0)), llm_plan=response_message, ttl=ttl)
```

## Additional context

The same fix has already been applied in:
- `record_model.py` (PR #195)
- `st_lt_memory.py` (PR #199)

This is the last remaining occurrence of `model.steps` in the codebase.

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 reasoning.py at execute_tool_call() and aexecute_tool_call(), especially the two Plan constructions around lines 126 and 149. Compare the related changes in record_model.py and st_lt_memory.py, then run the provided Mesa 4.x reproduction to verify CoT, ReAct, and ReWOO tool calls no longer raise AttributeError and that no model.steps occurrences remain.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
ai
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
68/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.