fix: LLM backend async api_base and enhance agent observation robustness#96
fix: LLM backend async api_base and enhance agent observation robustness#96uday-codes69 wants to merge 4 commits intomesa:mainfrom
Conversation
…key error messages
- Fixed hardcoded vision radius in LLMAgent._build_observation - Fixed missing neighbor detection logic for ContinuousSpace in LLMAgent - Updated ModuleLLM return type hints to match litellm's ModelResponse - Added InternalServerError and ServiceUnavailableError to retryable exceptions
|
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)
Tip Try Coding Plans. Let us write the prompt for your AI agent so you can ship faster (with fewer bugs). 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 |
- inbuilt_tools: fix TypeError in teleport_to_location for ContinuousSpace move_agent() is an instance method; passing agent.model.space as the first argument caused it to be bound twice. Fixed to agent.model.space.move_agent(agent, pos). - inbuilt_tools: fix variable shadowing in speak_to return string The list comprehension '[agent.unique_id for agent in listener_agents]' shadowed the outer 'agent' function parameter, returning the last listener's id instead of the sender's. Renamed loop var to 'la'. - st_memory: fix potential IndexError and unbound variable in process_step Accessing self.short_term_memory[-1] without first checking emptiness raises IndexError when post_step is called without a prior pre_step. Also guarded the display call with 'new_entry is not None' to prevent an UnboundLocalError when the elif branch is not taken. - rewoo: add missing ttl and obs parameters to plan() and aplan() ReWOOReasoning.plan() was missing the 'ttl' parameter required by the Reasoning ABC, and aplan() was missing both 'obs' and 'ttl', silently breaking callers that pass these by keyword or position. - __init__: remove duplicate entries in __all__ 'step_agents_parallel' and 'step_agents_parallel_sync' were each listed twice in __all__, causing redundancy and potential confusion for tooling that relies on the exported names list. All 178 tests pass.
Overview
This PR addresses several critical issues in the
mesa-llmlibrary to improve backend flexibility and the accuracy of agent-based modeling simulations.🛠️ Changes Implemented
1. Fixed
ModuleLLMAsync API Base BugProblem:
The
agenerate(async) method was ignoring theapi_baseparameter, preventing local providers such as Ollama from working correctly in async simulations.Fix:
Updated
agenerateto correctly passapi_baseto thelitellm.acompletioncall.2. Enhanced Observation Logic for
LLMAgentContinuousSpace Support
Improved neighbor detection for agents using
ContinuousSpace, ensuring compatibility with both:model.gridmodel.spaceVision Radius for Cell-Grids
Implemented proper multi-radius search for:
OrthogonalMooreGridOrthogonalVonNeumannGridPreviously, these only supported distance-1 neighbors.
Now, agents correctly respect their configured
visionparameter.3. Improved Message Formatting
Updated
ModuleLLM.get_messagesto natively handle pre-formatted message dictionaries.This allows users to:
4. Expanded Test Coverage
Added new test cases to:
tests/test_module_llm.pytests/test_llm_agent.pyThese tests verify:
api_base