Skip to content

Commit 071161b

Browse files
fix: ReWOOReasoning.aplan() calls sync add_to_memory instead of async aadd_to_memory
1 parent 27f0f50 commit 071161b

File tree

2 files changed

+34
-1
lines changed

2 files changed

+34
-1
lines changed

mesa_llm/reasoning/rewoo.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ async def aplan(
200200
tool_choice="none",
201201
)
202202

203-
self.agent.memory.add_to_memory(
203+
await self.agent.memory.aadd_to_memory(
204204
type="plan", content={"content": rsp.choices[0].message.content}
205205
)
206206

tests/test_reasoning/test_rewoo.py

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -536,6 +536,39 @@ def test_remaining_tool_calls_decrement(self, mock_agent):
536536
assert reasoning.remaining_tool_calls == 0
537537
assert result3.llm_plan.tool_calls == [mock_tool_3] # index 2 (3-1=2)
538538

539+
def test_aplan_uses_async_memory_method(self, llm_response_factory, mock_agent):
540+
mock_agent.step_prompt = "Default step prompt"
541+
mock_agent.agenerate_obs = AsyncMock(
542+
return_value=Observation(step=1, self_state={}, local_state={})
543+
)
544+
mock_agent.memory = Mock()
545+
mock_agent.memory.format_long_term.return_value = ""
546+
mock_agent.memory.format_short_term.return_value = ""
547+
mock_agent.memory.aadd_to_memory = AsyncMock()
548+
mock_agent.memory.add_to_memory = Mock()
549+
mock_agent.llm = Mock()
550+
mock_agent.tool_manager = Mock()
551+
mock_agent.tool_manager.get_all_tools_schema.return_value = {}
552+
553+
mock_plan_response = llm_response_factory(content="Async plan content")
554+
mock_exec_response = llm_response_factory(
555+
content="Exec",
556+
tool_calls=[_tool_call("call_1")],
557+
)
558+
mock_agent.llm.agenerate = AsyncMock(
559+
side_effect=[mock_plan_response, mock_exec_response]
560+
)
561+
562+
reasoning = ReWOOReasoning(mock_agent)
563+
reasoning.aexecute_tool_call = AsyncMock(
564+
return_value=Plan(step=1, llm_plan=mock_exec_response.choices[0].message)
565+
)
566+
567+
asyncio.run(reasoning.aplan())
568+
569+
mock_agent.memory.aadd_to_memory.assert_awaited_once()
570+
mock_agent.memory.add_to_memory.assert_not_called()
571+
539572

540573
class TestReWOOSignatureConsistency:
541574
def test_plan_accepts_obs_kwarg(self):

0 commit comments

Comments
 (0)