fix: ReActReasoning.__repr__ AttributeError and STLTMemory Mesa 4.x model.steps compatibility#199
fix: ReActReasoning.__repr__ AttributeError and STLTMemory Mesa 4.x model.steps compatibility#199abhinavk0220 wants to merge 8 commits intomesa:mainfrom
Conversation
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment Tip You can disable sequence diagrams in the walkthrough.Disable the |
| agent=self.agent, | ||
| content=self.step_content, | ||
| step=self.agent.model.steps, | ||
| step=int(getattr(self.agent.model, "_time", 0)), |
There was a problem hiding this comment.
Same pattern as record_model.py model.steps doesn't exist in Mesa 4.x. Using int(getattr(self.agent.model, '_time', 0)) as the safe fallback. This only surfaces at runtime when memory consolidation triggers, which is why it wasn't caught earlier.
for more information, see https://pre-commit.ci
for more information, see https://pre-commit.ci
…odel.steps compat
5e0eaa5 to
18218c3
Compare
for more information, see https://pre-commit.ci
MultiGrid and SingleGrid were removed in Mesa 4.x. Replace all usages in tests with OrthogonalMooreGrid and fix place_agent() calls to use the Mesa 4.x cell-based API (agent.cell = grid._cells[pos]). Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Fixes #205
Fixes #204
Summary
Two small but real bugs fixed in this PR:
ReActReasoning.__repr__()crashes withAttributeErrorSTLTMemoryusesmodel.stepswhich does not exist in Mesa 4.xBug 1 —
ReActReasoning.__repr__()AttributeErrorReActReasoning.__repr__()was referencingself.remaining_tool_callswhich does not exist on
ReActReasoning. That attribute belongs toReWOOReasoningonly. Callingrepr()on anyReActReasoninginstancewould crash with:
Fix: Removed
remaining_tool_callsfromReActReasoning.__repr__().ReWOOReasoning.__repr__()correctly keeps it since that class does havethe attribute.
Bug 2 —
STLTMemoryusesmodel.steps(Mesa 4.x incompatibility)st_lt_memory.pywas usingself.agent.model.stepsto record the currentstep when consolidating memory entries.
model.stepsdoes not exist inMesa 4.x — it was removed. This causes
AttributeErrorduring anysimulation run that triggers memory consolidation.
The same fix was already applied to
record_model.py— this bringsst_lt_memory.pyin line with the same pattern.Testing
All existing tests pass:
GSoC contributor checklist
Context & motivation
Found these two bugs while auditing the codebase after fixing the Mesa 4.x
issues in PR #195.
ReActReasoning.__repr__()was referencingself.remaining_tool_callswhich only exists onReWOOReasoningcallingrepr()on anyReActReasoninginstance would crash silently. TheSTLTMemorybug surfaced the same pattern asrecord_model.pymodel.stepsremoved in Mesa 4.x but still used in the memory consolidation path.
What I learned
Small bugs in base classes and memory modules can be harder to catch than
bugs in tools because they only surface under specific conditions
__repr__only when you inspect an agent, memory consolidation only whenshort-term capacity is exceeded. Reading the codebase with fresh eyes after
fixing one bug is often how you find the next one.
Learning repo
🔗 My learning repo: https://github.com/abhinavk0220/GSoC-learning-space
🔗 Relevant model(s): https://github.com/abhinavk0220/GSoC-learning-space/tree/main/models
Readiness checks
pytest --cov=mesa tests/)ruff check . --fix)