@@ -242,17 +242,17 @@ async def step(self, step_info: Optional[CustomAgentStepInfo] = None) -> None:
242
242
logger .info (f"🧠 All Memory: \n { step_info .memory } " )
243
243
self ._save_conversation (input_messages , model_output )
244
244
if self .model_name != "deepseek-reasoner" :
245
- # remove pre- prev message
246
- self .message_manager ._remove_last_state_message ( )
245
+ # remove prev message
246
+ self .message_manager ._remove_state_message_by_index ( - 1 )
247
247
except Exception as e :
248
248
# model call failed, remove last state message from history
249
- self .message_manager ._remove_last_state_message ( )
249
+ self .message_manager ._remove_state_message_by_index ( - 1 )
250
250
raise e
251
251
252
+ actions : list [ActionModel ] = model_output .action
252
253
result : list [ActionResult ] = await self .controller .multi_act (
253
- model_output . action , self .browser_context
254
+ actions , self .browser_context
254
255
)
255
- actions : list [ActionModel ] = model_output .action
256
256
if len (result ) != len (actions ):
257
257
# I think something changes, such information should let LLM know
258
258
for ri in range (len (result ), len (actions )):
@@ -261,6 +261,9 @@ async def step(self, step_info: Optional[CustomAgentStepInfo] = None) -> None:
261
261
error = f"{ actions [ri ].model_dump_json (exclude_unset = True )} is Failed to execute. \
262
262
Something new appeared after action { actions [len (result ) - 1 ].model_dump_json (exclude_unset = True )} " ,
263
263
is_done = False ))
264
+ if len (actions ) == 0 :
265
+ # TODO: fix no action case
266
+ result = [ActionResult (is_done = True , extracted_content = step_info .memory , include_in_memory = True )]
264
267
self ._last_result = result
265
268
self ._last_actions = actions
266
269
if len (result ) > 0 and result [- 1 ].is_done :
0 commit comments