-
-
Notifications
You must be signed in to change notification settings - Fork 19
Open
Description
I noticed that the move_one_step
mesa-llm/mesa_llm/tools/inbuilt_tools.py
Line 32 in db703ea
| def move_one_step(agent: "LLMAgent", direction: str) -> str: |
North, South, East etc.) and directly indexes into direction_map.
This is in contrast to the tools used in the Mesa LLM examples that raise ValueError() for invalid arguments.
Describe the bug
Since this tool is intended to be called by an LLM the input is not guaranteed to match the expected values exactly. The LLM may produce variations such as
- Different casing ("north")
- Alternate spellings ("north east")
- Other invalid directions
This results in an unhandledKeyError
Current behavior
dx, dy = direction_map[direction]
Can result in KeyError if direction is invalid.
Proposed Fix
Add explicit input validation and raise a clear ValueError when an invalid direction is provided that mentions the valid directions.
If this is accepted, I would also like to update the tests to reflect this change.
Metadata
Metadata
Assignees
Labels
No labels