Conversation
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the 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 |
|
Great, thanks for your work, it's really something that we would be interested in integrating. As Ewout said, since there is a lot of developpement on space in mesa right now, things may change (also in mesa-llm integration). So put the effort more into the thinking than the implementation since we might need to change thing soon ;) |
65cd6e8 to
9b96763
Compare
…taclass - Changed generic dict types to specific dict[str, Any] types - Updated type hints for better IDE autocomplete and type safety: - current_cell: dict[str, Any] | None - visible_cells: dict[str, dict[str, Any]] | None - statistics: dict[str, dict[str, float | int]] | None - global_environment: dict[str, Any] | None - Enhanced docstring with detailed field descriptions - Added documentation for new fields: objects, navigable, relative_bearing - Removed references to removed statistical fields (total, best_location, best_direction) - Added count field documentation to statistics This improves type safety and provides better developer experience with IDE autocompletion while maintaining backward compatibility.
- Implemented comprehensive object perception (perceive_objects parameter) - Added navigability detection (_is_cell_navigable) - Added bearing angle calculations for precise direction - Refactored internal observation logic into 20+ specific helper methods - Fixed OrthogonalGrid neighbor detection using BFS approach - Updated public API to use grid.properties instead of private attributes - Renamed max_cells_reported to max_visible_cells - Changed default perceive_environment to True - Removed deprecated parameters (perceive_properties, include_cell_distances, etc.) - Improved visible_cells structure with stringified keys and consistent data
- Renamed max_cells_reported to max_visible_cells - Removed deprecated perception parameters - Verified compatibility with new environmental perception behaviors - Ensured all 17 tests pass with the new implementation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #71 +/- ##
==========================================
- Coverage 90.03% 85.56% -4.47%
==========================================
Files 19 19
Lines 1435 1635 +200
==========================================
+ Hits 1292 1399 +107
- Misses 143 236 +93 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
environment_statework #71Location
mesa-llm/mesa_llm/reasoning/reasoning.pyEnvironmentalState | None(optional field inObservationdataclass)LLMAgent._get_environmental_state()inllm_agent.pyStructure (
EnvironmentalStatedataclass)Each Field Explained
1.
current_cell- What the agent is standing on{ "position": "(5, 5)", # Stringified coordinates "properties": { # PropertyLayer values at this cell "sugar": 8.0, "walkable": True }, "objects": [ # Non-agent entities at this location {"type": "Tree", "pickable": False}, {"type": "Gold", "pickable": True, "value": 100} ], "navigable": True, # Can agent move here? "agent_count": 1 # Number of agents (including self) }2.
visible_cells- What the agent can see nearby{ "(5, 6)": { # Stringified position key "distance": 1.0, # Euclidean distance from agent "direction": "east", # Cardinal direction "relative_bearing": 90.0, # Degrees (0=North, 90=East) "properties": {"sugar": 10.0}, "objects": [], "navigable": True, "agent_count": 0 }, "(6, 5)": { # Another visible cell "distance": 1.0, "direction": "south", "relative_bearing": 180.0, ... } }3.
statistics- Aggregated data across all visible cells{ "sugar": { "max": 10.0, # Maximum sugar in visible area "min": 2.0, # Minimum sugar in visible area "avg": 6.5, # Average sugar "count": 5 # Number of cells with this property }, "agent_count": { "total_visible": 3 # Total agents in visible area } }4.
global_environment- Model-level state{ "weather": "sunny", "temperature": 25.5, "time_of_day": "morning", "season": "spring", "market_price": 100.0 }How It's Generated
The flow in
LLMAgent:Configuration
Controlled by these
LLMAgentparameters:perceive_environmentTrueenvironment_stateis Noneperceive_objectsFalseFalse,"all","pickable","static"max_visible_cells10visible_cellsdictglobal_env_attributesvisionNoneUsage in Reasoning
The
environment_stateis passed to reasoning methods:Reasoning classes (CoT, ReAct, ReWOO) can access:
obs.environment_state.current_cell- Where am I?obs.environment_state.visible_cells- What's around me?obs.environment_state.statistics- What's the best direction?obs.environment_state.global_environment- What's the world state?@colinfrisch i m still working on it. not completed yet.