diff --git a/vision_agent/agent/vision_agent.py b/vision_agent/agent/vision_agent.py index 39f79e8a..76fc8df5 100644 --- a/vision_agent/agent/vision_agent.py +++ b/vision_agent/agent/vision_agent.py @@ -492,19 +492,10 @@ def chat_with_artifacts( } ) + code_action = response.get("execute_python", None) # sometimes it gets stuck in a loop, so we force it to exit if last_response == response: response["let_user_respond"] = True - - finished = response.get("let_user_respond", False) - - code_action = response.get("execute_python", None) - if code_action is not None: - code_action = use_extra_vision_agent_args( - code_action, test_multi_plan, custom_tool_names - ) - - if last_response == response: self.streaming_message( { "role": "assistant", @@ -514,7 +505,7 @@ def chat_with_artifacts( "value": "Agent is stuck in conversation loop, exited", "traceback_raw": [], }, - "finished": finished and code_action is None, + "finished": code_action is None, } ) else: @@ -524,10 +515,18 @@ def chat_with_artifacts( "content": new_format_to_old_format( add_step_descriptions(response) ), - "finished": finished and code_action is None, + "finished": response.get("let_user_respond", False) + and code_action is None, } ) + finished = response.get("let_user_respond", False) + + if code_action is not None: + code_action = use_extra_vision_agent_args( + code_action, test_multi_plan, custom_tool_names + ) + if code_action is not None: result, obs = execute_code_action( artifacts,